本文整理了Java中org.gradle.api.Project.getDependencies()
方法的一些代码示例,展示了Project.getDependencies()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.getDependencies()
方法的具体详情如下:
包路径:org.gradle.api.Project
类名称:Project
方法名:getDependencies
暂无
代码示例来源:origin: f2prateek/dart
public void addDartAndHensonDependenciesToVariantConfigurations(String dartVersionName) {
DependencyHandler dependencies = project.getDependencies();
dependencies.add("implementation", format("com.f2prateek.dart:henson:%s", dartVersionName));
}
}
代码示例来源:origin: uber/okbuck
public void fetchLintDeps(String version) {
// Invalidate lint deps when versions change
File lintVersionFile = project.file(LINT_VERSION_FILE);
try {
if (!lintVersionFile.exists()
|| !version.equals(
new String(Files.readAllBytes(lintVersionFile.toPath()), StandardCharsets.UTF_8))) {
FileUtils.deleteDirectory(lintVersionFile.getParentFile());
lintVersionFile.getParentFile().mkdirs();
Files.write(lintVersionFile.toPath(), Collections.singleton(version));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
project.getConfigurations().maybeCreate(LINT_DEPS_CONFIG);
project.getDependencies().add(LINT_DEPS_CONFIG, LINT_GROUP + ":" + LINT_MODULE + ":" + version);
getLintDepsCache();
}
代码示例来源:origin: uber/okbuck
@SuppressWarnings("ResultOfMethodCallIgnored")
public void setupKotlinHome(String kotlinVersion) {
this.kotlinHomeEnabled = true;
this.kotlinVersion = kotlinVersion;
Configuration kotlinConfig = project.getConfigurations().maybeCreate(KOTLIN_DEPS_CONFIG);
DependencyHandler handler = project.getDependencies();
kotlinModules
.stream()
.map(module -> String.format("%s:%s:%s", KOTLIN_GROUP, module, kotlinVersion))
.forEach(dependency -> handler.add(KOTLIN_DEPS_CONFIG, dependency));
dependencies =
new DependencyCache(project, ProjectUtil.getDependencyManager(project)).build(kotlinConfig);
}
代码示例来源:origin: uber/okbuck
public void setupJetifier(String version) {
if (!version.equals(JetifierExtension.DEFAULT_JETIFIER_VERSION)) {
LOG.warn(
"Using jetifier version other than %s; This might result in problems with the tool",
JetifierExtension.DEFAULT_JETIFIER_VERSION);
}
Configuration jetifierConfig = project.getConfigurations().maybeCreate(JETIFIER_DEPS_CONFIG);
DependencyHandler handler = project.getDependencies();
JETIFIER_MODULES
.stream()
.map(module -> String.format("%s:%s:%s", JETIFIER_GROUP, module, version))
.forEach(dependency -> handler.add(JETIFIER_DEPS_CONFIG, dependency));
handler.add(JETIFIER_DEPS_CONFIG, COMMONS_CLI_DEP);
dependencies =
new DependencyCache(project, ProjectUtil.getDependencyManager(project))
.build(jetifierConfig);
}
代码示例来源:origin: uber/okbuck
public void setupBuckBinary() {
OkBuckExtension okbuckExt = ProjectUtil.getOkBuckExtension(rootProject);
// Create dependency cache for buck binary if needed
if (okbuckExt.buckBinary != null) {
Configuration buckConfig =
rootProject.getConfigurations().maybeCreate(BUCK_BINARY_CONFIGURATION);
rootProject
.getRepositories()
.maven(mavenArtifactRepository -> mavenArtifactRepository.setUrl(JITPACK_URL));
rootProject.getDependencies().add(BUCK_BINARY_CONFIGURATION, okbuckExt.buckBinary);
Set<File> resolvedFiles = buckConfig.getResolvedConfiguration().getFiles();
Preconditions.checkArgument(resolvedFiles.size() == 1);
realBuckBinaryPath = resolvedFiles.iterator().next().toPath();
}
}
代码示例来源:origin: uber/okbuck
public void download() {
ImmutableSet.Builder<Configuration> runtimeDeps = ImmutableSet.builder();
Set<API> apisToDownload;
Set<String> configuredApis =
ProjectUtil.getOkBuckExtension(rootProject).getTestExtension().robolectricApis;
if (configuredApis != null) {
apisToDownload = configuredApis.stream().map(API::from).collect(Collectors.toSet());
} else {
apisToDownload = EnumSet.allOf(API.class);
}
for (API api : apisToDownload) {
Configuration runtimeApi =
rootProject.getConfigurations().maybeCreate(ROBOLECTRIC_RUNTIME + "_" + api.name());
rootProject.getDependencies().add(runtimeApi.getName(), api.getCoordinates());
runtimeDeps.add(runtimeApi);
}
DependencyCache dependencyCache =
new DependencyCache(rootProject, ProjectUtil.getDependencyManager(rootProject));
dependencies =
runtimeDeps
.build()
.stream()
.map(dependencyCache::build)
.flatMap(Set::stream)
.collect(com.uber.okbuck.core.util.MoreCollectors.toImmutableSet());
}
代码示例来源:origin: uber/okbuck
DependencyHandler dependencies = project.getDependencies();
代码示例来源:origin: uber/okbuck
@SuppressWarnings("ResultOfMethodCallIgnored")
public Set<ExternalDependency> setupScalaHome(String scalaVersion) {
Configuration scalaConfig = rootProject.getConfigurations().maybeCreate(SCALA_DEPS_CONFIG);
rootProject
.getDependencies()
.add(SCALA_DEPS_CONFIG, "org.scala-lang:scala-compiler:" + scalaVersion);
dependencies =
new DependencyCache(rootProject, ProjectUtil.getDependencyManager(rootProject))
.build(scalaConfig);
return dependencies;
}
代码示例来源:origin: uber/okbuck
@SuppressWarnings("ResultOfMethodCallIgnored")
public void setupGroovyHome() {
Configuration groovyConfig = rootProject.getConfigurations().maybeCreate(GROOVY_DEPS_CONFIG);
rootProject
.getDependencies()
.add(GROOVY_DEPS_CONFIG, "org.codehaus.groovy:groovy:" + groovyVersion);
dependencies =
new DependencyCache(rootProject, ProjectUtil.getDependencyManager(rootProject))
.build(groovyConfig);
}
代码示例来源:origin: uber/okbuck
public void fetchManifestMergerDeps() {
Configuration manifestMergerConfiguration =
rootProject.getConfigurations().maybeCreate(CONFIGURATION_MANIFEST_MERGER);
rootProject
.getDependencies()
.add(
CONFIGURATION_MANIFEST_MERGER,
MANIFEST_MERGER_GROUP
+ ":"
+ MANIFEST_MERGER_MODULE
+ ":"
+ ProjectUtil.findVersionInClasspath(
rootProject, MANIFEST_MERGER_GROUP, MANIFEST_MERGER_MODULE));
dependencies =
ImmutableSet.copyOf(
new DependencyCache(rootProject, ProjectUtil.getDependencyManager(rootProject))
.build(manifestMergerConfiguration));
}
代码示例来源:origin: diffplug/spotless
/**
* Creates a Provisioner for the given repositories.
*
* The first time a project is created, there are ~7 seconds of configuration
* which will go away for all subsequent runs.
*
* Every call to resolve will take about 1 second, even when all artifacts are resolved.
*/
private static Supplier<Provisioner> createLazyWithRepositories(Consumer<RepositoryHandler> repoConfig) {
// Running this takes ~3 seconds the first time it is called. Probably because of classloading.
return Suppliers.memoize(() -> {
Project project = ProjectBuilder.builder().build();
repoConfig.accept(project.getRepositories());
return (withTransitives, mavenCoords) -> {
Dependency[] deps = mavenCoords.stream()
.map(project.getDependencies()::create)
.toArray(Dependency[]::new);
Configuration config = project.getConfigurations().detachedConfiguration(deps);
config.setTransitive(withTransitives);
config.setDescription(mavenCoords.toString());
try {
return config.resolve();
} catch (ResolveException e) {
/* Provide Maven coordinates in exception message instead of static string 'detachedConfiguration' */
throw new ResolveException(config.getDescription(), e);
}
};
});
}
代码示例来源:origin: spring-gradle-plugins/dependency-management-plugin
/**
* Creates a new {@code MavenPomResolver}. Properties from the given {@code project} will be used during resolution.
* The given {@code configurationContainer} will be used to create configurations to resolve the poms.
*
* @param project the project
* @param configurationContainer the configuration container
*/
public MavenPomResolver(Project project, DependencyManagementConfigurationContainer configurationContainer) {
this.configurationContainer = configurationContainer;
this.effectiveModelBuilder = new EffectiveModelBuilder(project, configurationContainer);
this.dependencyHandler = project.getDependencies();
}
代码示例来源:origin: spring-gradle-plugins/dependency-management-plugin
private FileModelSource resolveModel(String coordinates) {
Dependency dependency = this.project.getDependencies().create(coordinates);
Configuration configuration = this.configurationContainer.newConfiguration(dependency);
return new FileModelSource(configuration.resolve().iterator().next());
}
代码示例来源:origin: com.netflix.nebula/nebula-dependency-recommender
@Override
public ModelSource2 resolveModel(String groupId, String artifactId, String version) throws UnresolvableModelException {
String notation = groupId + ":" + artifactId + ":" + version + "@pom";
org.gradle.api.artifacts.Dependency dependency = project.getDependencies().create(notation);
Configuration configuration = project.getConfigurations().detachedConfiguration(dependency);
try {
File file = configuration.getFiles().iterator().next();
return new SimpleModelSource(new FileInputStream(file));
} catch (Exception e) {
throw new UnresolvableModelException(e, groupId, artifactId, version);
}
}
代码示例来源:origin: purplejs/purplejs
private void addDependencies()
{
final DependencyHandler handler = this.project.getDependencies();
handler.add( "compile", this.ext.dependency( "boot" ) );
handler.add( "testCompile", this.ext.dependency( "testing" ) );
}
代码示例来源:origin: io.freefair.gradle/lombok-plugin
private void configureForSpotbugs(JavaPluginConvention javaPluginConvention) {
lombokExtension.getConfig().put("lombok.extern.findbugs.addSuppressFBWarnings", "true");
CodeQualityExtension spotbugsExtension = (CodeQualityExtension) project.getExtensions().getByName("spotbugs");
javaPluginConvention.getSourceSets().all(sourceSet ->
project.getDependencies().add(
sourceSet.getCompileOnlyConfigurationName(),
"com.github.spotbugs:spotbugs-annotations:" + spotbugsExtension.getToolVersion()
));
}
代码示例来源:origin: org.openjfx/javafx-plugin
private void updateJavaFXDependencies() {
clearJavaFXDependencies();
JavaFXModule.getJavaFXModules(this.modules).forEach(javaFXModule -> {
project.getDependencies().add("implementation",
String.format("%s:%s:%s:%s", MAVEN_JAVAFX_ARTIFACT_GROUP_ID, javaFXModule.getArtifactName(),
getVersion(), getPlatform().getClassifier()));
});
}
代码示例来源:origin: gradle.plugin.org.gosu-lang.gosu/gradle-gosu-plugin
private void addGosuRuntimeDependencies() {
Set<ResolvedArtifact> buildScriptDeps = _project.getBuildscript().getConfigurations().getByName("classpath").getResolvedConfiguration().getResolvedArtifacts();
ResolvedArtifact gosuCore = GosuPlugin.getArtifactWithName("gosu-core", buildScriptDeps);
ResolvedArtifact gosuCoreApi = GosuPlugin.getArtifactWithName("gosu-core-api", buildScriptDeps);
//inject Gosu jar dependencies into the classpath of the project implementing this plugin
_project.getDependencies().add("runtime", gosuCore.getModuleVersion().getId().toString());
_project.getDependencies().add("compile", gosuCoreApi.getModuleVersion().getId().toString());
}
代码示例来源:origin: com.android.tools.build/gradle-core
@Override
public void execute(ResolvableDependencies resolvableDependencies) {
if (config.getDependencies().isEmpty()) {
config.getDependencies().add(project.getDependencies().create(
"org.jacoco:org.jacoco.agent:" + jacocoVersion));
}
}
});
代码示例来源:origin: gradle.plugin.org.wildfly.build/wildfly-gradle-tools
public GradleArtifactFileResolver(Project project, boolean autoAddRepositories) {
this.project = project;
this.dependencies = project.getDependencies();
this.configurations = project.getConfigurations();
this.knownPublications = extractPublishingExtensions( project.getRootProject().getAllprojects() );
this.logger = project.getLogger();
this.autoAddRepositories = autoAddRepositories;
}
内容来源于网络,如有侵权,请联系作者删除!