本文整理了Java中org.gradle.api.Project.getConfigurations()
方法的一些代码示例,展示了Project.getConfigurations()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.getConfigurations()
方法的具体详情如下:
包路径:org.gradle.api.Project
类名称:Project
方法名:getConfigurations
暂无
代码示例来源:origin: uber/okbuck
private Set<ExternalDependency> resolved(Collection<ExternalDependency> externalDependencies) {
Configuration detached =
project
.getConfigurations()
.detachedConfiguration(
externalDependencies
.stream()
.map(ExternalDependency::getAsGradleDependency)
.toArray(Dependency[]::new));
return DependencyUtils.resolveExternal(
project, detached, externalDependenciesExtension, jetifierExtension);
}
代码示例来源:origin: uber/okbuck
@Nullable
public static Configuration useful(String configuration, Project project) {
try {
Configuration config = project.getConfigurations().getByName(configuration);
return useful(config);
} catch (UnknownConfigurationException ignored) {
return null;
}
}
代码示例来源:origin: alipay/sofa-boot
private Configuration createBootArchivesConfiguration(Project project) {
Configuration bootArchives = project.getConfigurations().create(
BOOT_ARCHIVES_CONFIGURATION_NAME);
bootArchives.setDescription("Configuration for Spring Boot archive artifacts.");
return bootArchives;
}
代码示例来源: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
private Map<Set<Dependency>, Scope> createProcessorScopes(
Project project, Set<Dependency> dependencies, boolean groupDependencies) {
ImmutableMap.Builder<Set<Dependency>, Scope> currentBuilder = new ImmutableMap.Builder<>();
// Creates a scope using a detached configuration and the given dependency set.
Function<Set<Dependency>, Scope> computeScope =
depSet -> {
Dependency[] depArray = depSet.toArray(new Dependency[0]);
Configuration detached = project.getConfigurations().detachedConfiguration(depArray);
return Scope.builder(project).configuration(detached).build();
};
if (groupDependencies) {
// Creates one scope for all the dependencies if not
// already present and adds it to the current builder.
ImmutableSet<Dependency> dependencySet = ImmutableSet.copyOf(dependencies);
Scope scope = dependencyToScopeMap.computeIfAbsent(dependencySet, computeScope);
currentBuilder.put(dependencySet, scope);
} else {
// Creates one scope per dependency if not already
// found and adds it to the current builder.
dependencies.forEach(
dependency -> {
ImmutableSet<Dependency> dependencySet = ImmutableSet.of(dependency);
Scope scope = dependencyToScopeMap.computeIfAbsent(dependencySet, computeScope);
currentBuilder.put(dependencySet, scope);
});
}
return currentBuilder.build();
}
代码示例来源: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
@Nullable
private Configuration getConfigurationFromVariant(@Nullable BaseVariant variant) {
@Var Configuration configuration = null;
if (isKapt) {
configuration =
getProject()
.getConfigurations()
.getByName("kapt" + StringUtils.capitalize(getBaseVariant().getName()));
} else if (variant != null) {
configuration = variant.getAnnotationProcessorConfiguration();
}
return configuration;
}
代码示例来源:origin: uber/okbuck
@Nullable
public static String getProguardJarPath(Project project) {
String proguardVersion =
ProjectUtil.findVersionInClasspath(project, PROGUARD_GROUP, PROGUARD_MODULE);
Configuration proguardConfiguration =
project
.getConfigurations()
.detachedConfiguration(
new DefaultExternalModuleDependency(
PROGUARD_GROUP, PROGUARD_MODULE, proguardVersion));
DependencyCache cache = new DependencyCache(project, ProjectUtil.getDependencyManager(project));
Set<ExternalDependency> dependencies = cache.build(proguardConfiguration);
Optional<ExternalDependency> proguardDependency =
dependencies
.stream()
.filter(
dependency ->
dependency.getGroup().equals(PROGUARD_GROUP)
&& dependency.getName().equals(PROGUARD_MODULE))
.findAny();
return proguardDependency.map(BuckRuleComposer::external).orElse(null);
}
}
代码示例来源:origin: jooby-project/jooby
public Set<File> classpath() {
SourceSet sourceSet = sourceSet(project);
// conf & public
Set<File> cp = new LinkedHashSet<>(sourceSet.getResources().getSrcDirs());
// classes/main, resources/main + jars
cp.addAll(sourceSet.getRuntimeClasspath().getFiles());
// provided?
Configuration provided = project.getConfigurations().findByName("provided");
if (provided != null) {
cp.addAll(provided.getFiles());
}
return cp;
}
代码示例来源: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
public DependencyCache getLintDepsCache() {
if (lintDepCache == null) {
lintDepCache = new DependencyCache(project, ProjectUtil.getDependencyManager(project));
dependencies =
lintDepCache.build(
project.getRootProject().getConfigurations().getByName(LINT_DEPS_CONFIG));
}
return lintDepCache;
}
代码示例来源:origin: ManbangGroup/Phantom
private Set<String> getCompileArtifactsForAgp2x() {
Set<String> compileLibs = new HashSet<>();
Configuration configuration = project.getConfigurations().getByName("compile");
if (configuration.isCanBeResolved()) {
ResolvableDependencies incoming = configuration.getIncoming();
ResolutionResult resolutionResult = incoming.getResolutionResult();
Set<ResolvedComponentResult> components = resolutionResult.getAllComponents();
for (ResolvedComponentResult result : components) {
ModuleVersionIdentifier identifier = result.getModuleVersion();
if (identifier != null && !"unspecified".equals(identifier.getVersion())) {
compileLibs.add(
String.join(":", identifier.getGroup(), identifier.getName(), identifier.getVersion()));
}
}
}
return compileLibs;
}
代码示例来源: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: alipay/sofa-boot
private void unregisterUnresolvedDependenciesAnalyzer(Project project) {
UnresolvedDependenciesAnalyzer unresolvedDependenciesAnalyzer = new UnresolvedDependenciesAnalyzer();
project.getConfigurations().all((configuration) -> {
ResolvableDependencies incoming = configuration.getIncoming();
incoming.afterResolve((resolvableDependencies) -> {
if (incoming.equals(resolvableDependencies)) {
unresolvedDependenciesAnalyzer.analyze(configuration
.getResolvedConfiguration().getLenientConfiguration()
.getUnresolvedModuleDependencies());
}
});
});
project.getGradle().buildFinished(
(buildResult) -> unresolvedDependenciesAnalyzer.buildFinished(project));
}
代码示例来源:origin: uber/okbuck
rootProject.getConfigurations().maybeCreate(TransformManager.CONFIGURATION_TRANSFORM);
rootProject.getConfigurations().maybeCreate(FORCED_OKBUCK);
cacheName ->
rootBuckProject
.getConfigurations()
.maybeCreate(cacheName + "ExtraDepCache")));
.forEach(
bp -> {
bp.getConfigurations().maybeCreate(BUCK_LINT);
代码示例来源: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);
}
};
});
}
内容来源于网络,如有侵权,请联系作者删除!