Search in sources :

Example 1 with ConfigurationInternal

use of org.gradle.api.internal.artifacts.configurations.ConfigurationInternal in project gradle by gradle.

the class DefaultConfigurationComponentMetaDataBuilder method addConfigurations.

public void addConfigurations(BuildableLocalComponentMetadata metaData, Collection<? extends ConfigurationInternal> configurations) {
    for (ConfigurationInternal configuration : configurations) {
        addConfiguration(metaData, configuration);
        dependenciesConverter.addDependencyDescriptors(metaData, configuration);
        OutgoingVariant outgoingVariant = configuration.convertToOutgoingVariant();
        metaData.addArtifacts(configuration.getName(), outgoingVariant.getArtifacts());
        for (OutgoingVariant variant : outgoingVariant.getChildren()) {
            metaData.addVariant(configuration.getName(), variant);
        }
    }
}
Also used : OutgoingVariant(org.gradle.api.internal.artifacts.configurations.OutgoingVariant) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)

Example 2 with ConfigurationInternal

use of org.gradle.api.internal.artifacts.configurations.ConfigurationInternal in project gradle by gradle.

the class DefaultLocalComponentMetadataBuilder method addConfigurations.

public void addConfigurations(BuildableLocalComponentMetadata metaData, Collection<? extends ConfigurationInternal> configurations) {
    for (ConfigurationInternal configuration : configurations) {
        addConfiguration(metaData, configuration);
        metaData.addDependenciesAndExcludesForConfiguration(configuration, configurationMetadataBuilder);
        OutgoingVariant outgoingVariant = configuration.convertToOutgoingVariant();
        metaData.addArtifacts(configuration.getName(), outgoingVariant.getArtifacts());
        for (OutgoingVariant variant : outgoingVariant.getChildren()) {
            metaData.addVariant(configuration.getName(), variant);
        }
    }
}
Also used : OutgoingVariant(org.gradle.api.internal.artifacts.configurations.OutgoingVariant) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)

Example 3 with ConfigurationInternal

use of org.gradle.api.internal.artifacts.configurations.ConfigurationInternal in project gradle by gradle.

the class DefaultLocalComponentMetadataBuilder method addConfiguration.

@Override
public BuildableLocalConfigurationMetadata addConfiguration(BuildableLocalComponentMetadata metaData, ConfigurationInternal configuration) {
    BuildableLocalConfigurationMetadata configurationMetadata = createConfiguration(metaData, configuration);
    metaData.addDependenciesAndExcludesForConfiguration(configuration, configurationMetadataBuilder);
    ComponentConfigurationIdentifier configurationIdentifier = new ComponentConfigurationIdentifier(metaData.getId(), configuration.getName());
    configuration.collectVariants(new ConfigurationInternal.VariantVisitor() {

        @Override
        public void visitArtifacts(Collection<? extends PublishArtifact> artifacts) {
            metaData.addArtifacts(configuration.getName(), artifacts);
        }

        @Override
        public void visitOwnVariant(DisplayName displayName, ImmutableAttributes attributes, Collection<? extends Capability> capabilities, Collection<? extends PublishArtifact> artifacts) {
            metaData.addVariant(configuration.getName(), configuration.getName(), configurationIdentifier, displayName, attributes, ImmutableCapabilities.of(capabilities), artifacts);
        }

        @Override
        public void visitChildVariant(String name, DisplayName displayName, ImmutableAttributes attributes, Collection<? extends Capability> capabilities, Collection<? extends PublishArtifact> artifacts) {
            metaData.addVariant(configuration.getName(), configuration.getName() + "-" + name, new NestedVariantIdentifier(configurationIdentifier, name), displayName, attributes, ImmutableCapabilities.of(capabilities), artifacts);
        }
    });
    return configurationMetadata;
}
Also used : ComponentConfigurationIdentifier(org.gradle.internal.component.model.ComponentConfigurationIdentifier) ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) DisplayName(org.gradle.internal.DisplayName) BuildableLocalConfigurationMetadata(org.gradle.internal.component.local.model.BuildableLocalConfigurationMetadata) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)

Example 4 with ConfigurationInternal

use of org.gradle.api.internal.artifacts.configurations.ConfigurationInternal in project gradle by gradle.

the class DefaultJvmPluginServices method useDefaultTargetPlatformInference.

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public <COMPILE extends AbstractCompile & HasCompileOptions> void useDefaultTargetPlatformInference(Configuration configuration, TaskProvider<COMPILE> compileTask) {
    ConfigurationInternal configurationInternal = (ConfigurationInternal) configuration;
    Set<TaskProvider<?>> compileTasks = configurationToCompileTasks.computeIfAbsent(configurationInternal, key -> {
        HashSet<TaskProvider<?>> taskProviders = new HashSet<>();
        configurationInternal.beforeLocking(configureDefaultTargetPlatform(configuration.isCanBeConsumed(), (Set) taskProviders));
        return taskProviders;
    });
    compileTasks.add(compileTask);
}
Also used : Set(java.util.Set) SourceSet(org.gradle.api.tasks.SourceSet) HashSet(java.util.HashSet) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal) TaskProvider(org.gradle.api.tasks.TaskProvider) HashSet(java.util.HashSet)

Example 5 with ConfigurationInternal

use of org.gradle.api.internal.artifacts.configurations.ConfigurationInternal in project gradle by gradle.

the class JavaBasePlugin method defineConfigurationsForSourceSet.

private void defineConfigurationsForSourceSet(SourceSet sourceSet, ConfigurationContainer configurations) {
    String implementationConfigurationName = sourceSet.getImplementationConfigurationName();
    String runtimeOnlyConfigurationName = sourceSet.getRuntimeOnlyConfigurationName();
    String compileOnlyConfigurationName = sourceSet.getCompileOnlyConfigurationName();
    String compileClasspathConfigurationName = sourceSet.getCompileClasspathConfigurationName();
    String annotationProcessorConfigurationName = sourceSet.getAnnotationProcessorConfigurationName();
    String runtimeClasspathConfigurationName = sourceSet.getRuntimeClasspathConfigurationName();
    String sourceSetName = sourceSet.toString();
    Configuration implementationConfiguration = configurations.maybeCreate(implementationConfigurationName);
    implementationConfiguration.setVisible(false);
    implementationConfiguration.setDescription("Implementation only dependencies for " + sourceSetName + ".");
    implementationConfiguration.setCanBeConsumed(false);
    implementationConfiguration.setCanBeResolved(false);
    DeprecatableConfiguration compileOnlyConfiguration = (DeprecatableConfiguration) configurations.maybeCreate(compileOnlyConfigurationName);
    compileOnlyConfiguration.setVisible(false);
    compileOnlyConfiguration.setCanBeConsumed(false);
    compileOnlyConfiguration.setCanBeResolved(false);
    compileOnlyConfiguration.setDescription("Compile only dependencies for " + sourceSetName + ".");
    ConfigurationInternal compileClasspathConfiguration = (ConfigurationInternal) configurations.maybeCreate(compileClasspathConfigurationName);
    compileClasspathConfiguration.setVisible(false);
    compileClasspathConfiguration.extendsFrom(compileOnlyConfiguration, implementationConfiguration);
    compileClasspathConfiguration.setDescription("Compile classpath for " + sourceSetName + ".");
    compileClasspathConfiguration.setCanBeConsumed(false);
    jvmPluginServices.configureAsCompileClasspath(compileClasspathConfiguration);
    ConfigurationInternal annotationProcessorConfiguration = (ConfigurationInternal) configurations.maybeCreate(annotationProcessorConfigurationName);
    annotationProcessorConfiguration.setVisible(false);
    annotationProcessorConfiguration.setDescription("Annotation processors and their dependencies for " + sourceSetName + ".");
    annotationProcessorConfiguration.setCanBeConsumed(false);
    annotationProcessorConfiguration.setCanBeResolved(true);
    jvmPluginServices.configureAsRuntimeClasspath(annotationProcessorConfiguration);
    Configuration runtimeOnlyConfiguration = configurations.maybeCreate(runtimeOnlyConfigurationName);
    runtimeOnlyConfiguration.setVisible(false);
    runtimeOnlyConfiguration.setCanBeConsumed(false);
    runtimeOnlyConfiguration.setCanBeResolved(false);
    runtimeOnlyConfiguration.setDescription("Runtime only dependencies for " + sourceSetName + ".");
    ConfigurationInternal runtimeClasspathConfiguration = (ConfigurationInternal) configurations.maybeCreate(runtimeClasspathConfigurationName);
    runtimeClasspathConfiguration.setVisible(false);
    runtimeClasspathConfiguration.setCanBeConsumed(false);
    runtimeClasspathConfiguration.setCanBeResolved(true);
    runtimeClasspathConfiguration.setDescription("Runtime classpath of " + sourceSetName + ".");
    runtimeClasspathConfiguration.extendsFrom(runtimeOnlyConfiguration, implementationConfiguration);
    jvmPluginServices.configureAsRuntimeClasspath(runtimeClasspathConfiguration);
    sourceSet.setCompileClasspath(compileClasspathConfiguration);
    sourceSet.setRuntimeClasspath(sourceSet.getOutput().plus(runtimeClasspathConfiguration));
    sourceSet.setAnnotationProcessorPath(annotationProcessorConfiguration);
    compileClasspathConfiguration.deprecateForDeclaration(implementationConfigurationName, compileOnlyConfigurationName);
    runtimeClasspathConfiguration.deprecateForDeclaration(implementationConfigurationName, compileOnlyConfigurationName, runtimeOnlyConfigurationName);
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) DeprecatableConfiguration(org.gradle.internal.deprecation.DeprecatableConfiguration) DeprecatableConfiguration(org.gradle.internal.deprecation.DeprecatableConfiguration) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)

Aggregations

ConfigurationInternal (org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)13 File (java.io.File)3 PublicationAwareRepository (org.gradle.api.internal.artifacts.repositories.PublicationAwareRepository)3 Configuration (org.gradle.api.artifacts.Configuration)2 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)2 Module (org.gradle.api.internal.artifacts.Module)2 ModuleVersionPublisher (org.gradle.api.internal.artifacts.ModuleVersionPublisher)2 OutgoingVariant (org.gradle.api.internal.artifacts.configurations.OutgoingVariant)2 DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)2 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Callable (java.util.concurrent.Callable)1 BiFunction (java.util.function.BiFunction)1 Inject (javax.inject.Inject)1 InvokerHelper (org.codehaus.groovy.runtime.InvokerHelper)1 Action (org.gradle.api.Action)1