use of org.gradle.api.artifacts.ConfigurationContainer in project gradle by gradle.
the class IdeaPlugin method setupScopes.
private void setupScopes(GenerateIdeaModule ideaModule) {
Map<String, Map<String, Collection<Configuration>>> scopes = Maps.newLinkedHashMap();
for (GeneratedIdeaScope scope : GeneratedIdeaScope.values()) {
Map<String, Collection<Configuration>> plusMinus = Maps.newLinkedHashMap();
plusMinus.put(IdeaDependenciesProvider.SCOPE_PLUS, Lists.<Configuration>newArrayList());
plusMinus.put(IdeaDependenciesProvider.SCOPE_MINUS, Lists.<Configuration>newArrayList());
scopes.put(scope.name(), plusMinus);
}
Project project = ideaModule.getProject();
ConfigurationContainer configurations = project.getConfigurations();
Collection<Configuration> provided = scopes.get(GeneratedIdeaScope.PROVIDED.name()).get(IdeaDependenciesProvider.SCOPE_PLUS);
provided.add(configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME));
Collection<Configuration> runtime = scopes.get(GeneratedIdeaScope.RUNTIME.name()).get(IdeaDependenciesProvider.SCOPE_PLUS);
runtime.add(configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME));
Collection<Configuration> test = scopes.get(GeneratedIdeaScope.TEST.name()).get(IdeaDependenciesProvider.SCOPE_PLUS);
test.add(configurations.getByName(JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME));
test.add(configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME));
ideaModule.getModule().setScopes(scopes);
}
use of org.gradle.api.artifacts.ConfigurationContainer in project gradle by gradle.
the class SigningExtension method getDefaultConfiguration.
/**
* Provides the configuration that signature artifacts are added to. Called once during construction.
*/
protected Configuration getDefaultConfiguration() {
ConfigurationContainer configurations = project.getConfigurations();
Configuration configuration = configurations.findByName(DEFAULT_CONFIGURATION_NAME);
return configuration != null ? configuration : configurations.create(DEFAULT_CONFIGURATION_NAME);
}
use of org.gradle.api.artifacts.ConfigurationContainer in project gradle by gradle.
the class ArtifactRepositoryPluginResolver method exists.
/*
* Checks whether the implementation artifact exists in the backing artifact repository.
*/
private boolean exists(PluginRequestInternal request) {
Dependency dependency = resolution.getDependencyHandler().create(getMarkerDependency(request));
ConfigurationContainer configurations = resolution.getConfigurationContainer();
Configuration configuration = configurations.detachedConfiguration(dependency);
configuration.setTransitive(false);
return !configuration.getResolvedConfiguration().hasError();
}
use of org.gradle.api.artifacts.ConfigurationContainer in project gradle by gradle.
the class JavaPlugin method configureConfigurations.
private void configureConfigurations(Project project) {
ConfigurationContainer configurations = project.getConfigurations();
Configuration defaultConfiguration = configurations.getByName(Dependency.DEFAULT_CONFIGURATION);
Configuration compileConfiguration = configurations.getByName(COMPILE_CONFIGURATION_NAME);
Configuration implementationConfiguration = configurations.getByName(IMPLEMENTATION_CONFIGURATION_NAME);
Configuration runtimeConfiguration = configurations.getByName(RUNTIME_CONFIGURATION_NAME);
Configuration runtimeOnlyConfiguration = configurations.getByName(RUNTIME_ONLY_CONFIGURATION_NAME);
Configuration compileTestsConfiguration = configurations.getByName(TEST_COMPILE_CONFIGURATION_NAME);
Configuration testImplementationConfiguration = configurations.getByName(TEST_IMPLEMENTATION_CONFIGURATION_NAME);
Configuration testRuntimeConfiguration = configurations.getByName(TEST_RUNTIME_CONFIGURATION_NAME);
Configuration testRuntimeOnlyConfiguration = configurations.getByName(TEST_RUNTIME_ONLY_CONFIGURATION_NAME);
compileTestsConfiguration.extendsFrom(compileConfiguration);
testImplementationConfiguration.extendsFrom(implementationConfiguration);
testRuntimeConfiguration.extendsFrom(runtimeConfiguration);
testRuntimeOnlyConfiguration.extendsFrom(runtimeOnlyConfiguration);
Configuration apiElementsConfiguration = configurations.maybeCreate(API_ELEMENTS_CONFIGURATION_NAME);
apiElementsConfiguration.setVisible(false);
apiElementsConfiguration.setDescription("API elements for main.");
apiElementsConfiguration.setCanBeResolved(false);
apiElementsConfiguration.setCanBeConsumed(true);
apiElementsConfiguration.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, Usage.FOR_COMPILE);
apiElementsConfiguration.extendsFrom(compileConfiguration, runtimeConfiguration);
Configuration runtimeElementsConfiguration = configurations.maybeCreate(RUNTIME_ELEMENTS_CONFIGURATION_NAME);
runtimeElementsConfiguration.setVisible(false);
runtimeElementsConfiguration.setCanBeConsumed(true);
runtimeElementsConfiguration.setCanBeResolved(false);
runtimeElementsConfiguration.setDescription("Elements of runtime for main.");
runtimeElementsConfiguration.getAttributes().attribute(USAGE_ATTRIBUTE, FOR_RUNTIME);
runtimeElementsConfiguration.extendsFrom(implementationConfiguration, runtimeOnlyConfiguration, runtimeConfiguration);
defaultConfiguration.extendsFrom(runtimeElementsConfiguration);
}
use of org.gradle.api.artifacts.ConfigurationContainer in project gradle by gradle.
the class BasePlugin method configureConfigurations.
private void configureConfigurations(final Project project) {
ConfigurationContainer configurations = project.getConfigurations();
project.setStatus("integration");
Configuration archivesConfiguration = configurations.maybeCreate(Dependency.ARCHIVES_CONFIGURATION).setDescription("Configuration for archive artifacts.");
configurations.maybeCreate(Dependency.DEFAULT_CONFIGURATION).setDescription("Configuration for default artifacts.");
final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create("defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts());
configurations.all(new Action<Configuration>() {
public void execute(Configuration configuration) {
configuration.getArtifacts().all(new Action<PublishArtifact>() {
public void execute(PublishArtifact artifact) {
defaultArtifacts.addCandidate(artifact);
}
});
}
});
}
Aggregations