Search in sources :

Example 1 with ConfigurationContainer

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);
}
Also used : Project(org.gradle.api.Project) IdeaProject(org.gradle.plugins.ide.idea.model.IdeaProject) Configuration(org.gradle.api.artifacts.Configuration) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) Collection(java.util.Collection) FileCollection(org.gradle.api.file.FileCollection) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) GeneratedIdeaScope(org.gradle.plugins.ide.idea.model.internal.GeneratedIdeaScope)

Example 2 with ConfigurationContainer

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);
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer)

Example 3 with ConfigurationContainer

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();
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) Dependency(org.gradle.api.artifacts.Dependency)

Example 4 with ConfigurationContainer

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);
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer)

Example 5 with ConfigurationContainer

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);
                }
            });
        }
    });
}
Also used : Action(org.gradle.api.Action) DefaultArtifactPublicationSet(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet) Configuration(org.gradle.api.artifacts.Configuration) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) PublishArtifact(org.gradle.api.artifacts.PublishArtifact)

Aggregations

ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)10 Configuration (org.gradle.api.artifacts.Configuration)8 Project (org.gradle.api.Project)2 SourceSet (org.gradle.api.tasks.SourceSet)2 File (java.io.File)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Action (org.gradle.api.Action)1 Task (org.gradle.api.Task)1 Dependency (org.gradle.api.artifacts.Dependency)1 PublishArtifact (org.gradle.api.artifacts.PublishArtifact)1 FileCollection (org.gradle.api.file.FileCollection)1 ConventionMapping (org.gradle.api.internal.ConventionMapping)1 DefaultExternalModuleDependency (org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency)1 DefaultJavaSourceSet (org.gradle.api.internal.java.DefaultJavaSourceSet)1 DefaultJvmResourceSet (org.gradle.api.internal.java.DefaultJvmResourceSet)1 ClassDirectoryBinarySpecInternal (org.gradle.api.internal.jvm.ClassDirectoryBinarySpecInternal)1 DefaultClassDirectoryBinarySpec (org.gradle.api.internal.jvm.DefaultClassDirectoryBinarySpec)1 DefaultArtifactPublicationSet (org.gradle.api.internal.plugins.DefaultArtifactPublicationSet)1