Search in sources :

Example 1 with DeprecatableConfiguration

use of org.gradle.internal.deprecation.DeprecatableConfiguration in project gradle by gradle.

the class AbstractCodeQualityPlugin method createConfigurations.

protected void createConfigurations() {
    Configuration configuration = project.getConfigurations().create(getConfigurationName());
    configuration.setVisible(false);
    configuration.setTransitive(true);
    configuration.setDescription("The " + getToolName() + " libraries to be used for this project.");
    ((DeprecatableConfiguration) configuration).deprecateForConsumption(deprecation -> deprecation.willBecomeAnErrorInGradle8().withUpgradeGuideSection(7, "plugin_configuration_consumption"));
    // Don't need these things, they're provided by the runtime
    configuration.exclude(excludeProperties("ant", "ant"));
    configuration.exclude(excludeProperties("org.apache.ant", "ant"));
    configuration.exclude(excludeProperties("org.apache.ant", "ant-launcher"));
    configuration.exclude(excludeProperties("org.slf4j", "slf4j-api"));
    configuration.exclude(excludeProperties("org.slf4j", "jcl-over-slf4j"));
    configuration.exclude(excludeProperties("org.slf4j", "log4j-over-slf4j"));
    configuration.exclude(excludeProperties("commons-logging", "commons-logging"));
    configuration.exclude(excludeProperties("log4j", "log4j"));
    configureConfiguration(configuration);
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) DeprecatableConfiguration(org.gradle.internal.deprecation.DeprecatableConfiguration) DeprecatableConfiguration(org.gradle.internal.deprecation.DeprecatableConfiguration)

Example 2 with DeprecatableConfiguration

use of org.gradle.internal.deprecation.DeprecatableConfiguration in project gradle by gradle.

the class JavaPlugin method configureConfigurations.

private void configureConfigurations(Project project, JavaPluginExtension extension, SourceSet mainSourceSet) {
    ConfigurationContainer configurations = project.getConfigurations();
    Configuration defaultConfiguration = configurations.getByName(Dependency.DEFAULT_CONFIGURATION);
    Configuration implementationConfiguration = configurations.getByName(IMPLEMENTATION_CONFIGURATION_NAME);
    Configuration runtimeOnlyConfiguration = configurations.getByName(RUNTIME_ONLY_CONFIGURATION_NAME);
    Configuration testImplementationConfiguration = configurations.getByName(TEST_IMPLEMENTATION_CONFIGURATION_NAME);
    Configuration testRuntimeOnlyConfiguration = configurations.getByName(TEST_RUNTIME_ONLY_CONFIGURATION_NAME);
    testImplementationConfiguration.extendsFrom(implementationConfiguration);
    testRuntimeOnlyConfiguration.extendsFrom(runtimeOnlyConfiguration);
    final DeprecatableConfiguration apiElementsConfiguration = (DeprecatableConfiguration) jvmServices.createOutgoingElements(API_ELEMENTS_CONFIGURATION_NAME, builder -> builder.fromSourceSet(mainSourceSet).providesApi().withDescription("API elements for main."));
    final DeprecatableConfiguration runtimeElementsConfiguration = (DeprecatableConfiguration) jvmServices.createOutgoingElements(RUNTIME_ELEMENTS_CONFIGURATION_NAME, builder -> builder.fromSourceSet(mainSourceSet).providesRuntime().withDescription("Elements of runtime for main.").extendsFrom(implementationConfiguration, runtimeOnlyConfiguration));
    defaultConfiguration.extendsFrom(runtimeElementsConfiguration);
    apiElementsConfiguration.deprecateForDeclaration(IMPLEMENTATION_CONFIGURATION_NAME, COMPILE_ONLY_CONFIGURATION_NAME);
    runtimeElementsConfiguration.deprecateForDeclaration(IMPLEMENTATION_CONFIGURATION_NAME, COMPILE_ONLY_CONFIGURATION_NAME, RUNTIME_ONLY_CONFIGURATION_NAME);
    createSourcesVariant(project, extension, mainSourceSet);
}
Also used : NamedDomainObjectProvider(org.gradle.api.NamedDomainObjectProvider) ConfigurationVariantInternal(org.gradle.api.internal.artifacts.ConfigurationVariantInternal) ConfigurationPublications(org.gradle.api.artifacts.ConfigurationPublications) NamedDomainObjectContainer(org.gradle.api.NamedDomainObjectContainer) AdhocComponentWithVariants(org.gradle.api.component.AdhocComponentWithVariants) LibraryElements(org.gradle.api.attributes.LibraryElements) Task(org.gradle.api.Task) Provider(org.gradle.api.provider.Provider) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) TaskProvider(org.gradle.api.tasks.TaskProvider) JavaConfigurationVariantMapping(org.gradle.api.plugins.internal.JavaConfigurationVariantMapping) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) LazyPublishArtifact(org.gradle.api.internal.artifacts.dsl.LazyPublishArtifact) OpaqueComponentIdentifier(org.gradle.internal.component.local.model.OpaqueComponentIdentifier) Project(org.gradle.api.Project) Collection(java.util.Collection) ArtifactView(org.gradle.api.artifacts.ArtifactView) VerificationType(org.gradle.api.attributes.VerificationType) LIBRARY_ELEMENTS_ATTRIBUTE(org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE) ArtifactTypeDefinition(org.gradle.api.artifacts.type.ArtifactTypeDefinition) JvmPluginServices(org.gradle.api.plugins.jvm.internal.JvmPluginServices) DeprecatableConfiguration(org.gradle.internal.deprecation.DeprecatableConfiguration) DependencyFactory(org.gradle.api.internal.artifacts.dsl.dependencies.DependencyFactory) ProcessResources(org.gradle.language.jvm.tasks.ProcessResources) BuildOutputCleanupRegistry(org.gradle.internal.execution.BuildOutputCleanupRegistry) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) Category(org.gradle.api.attributes.Category) BuildableJavaComponent(org.gradle.api.internal.component.BuildableJavaComponent) FileCollection(org.gradle.api.file.FileCollection) JvmTestSuite(org.gradle.api.plugins.jvm.JvmTestSuite) SourceSet(org.gradle.api.tasks.SourceSet) Bundling(org.gradle.api.attributes.Bundling) Inject(javax.inject.Inject) Configuration(org.gradle.api.artifacts.Configuration) ConfigurationVariant(org.gradle.api.artifacts.ConfigurationVariant) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) Test(org.gradle.api.tasks.testing.Test) Usage(org.gradle.api.attributes.Usage) DefaultArtifactPublicationSet(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet) Jar(org.gradle.api.tasks.bundling.Jar) JvmPluginsHelper(org.gradle.api.plugins.internal.JvmPluginsHelper) TestingExtension(org.gradle.testing.base.TestingExtension) File(java.io.File) USAGE_ATTRIBUTE(org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE) JvmPluginsHelper.configureJavaDocTask(org.gradle.api.plugins.internal.JvmPluginsHelper.configureJavaDocTask) ObjectFactory(org.gradle.api.model.ObjectFactory) SoftwareComponentFactory(org.gradle.api.component.SoftwareComponentFactory) DEFAULT_TEST_SUITE_NAME(org.gradle.api.plugins.JvmTestSuitePlugin.DEFAULT_TEST_SUITE_NAME) Dependency(org.gradle.api.artifacts.Dependency) Collections(java.util.Collections) Plugin(org.gradle.api.Plugin) ComponentRegistry(org.gradle.api.internal.component.ComponentRegistry) DeprecatableConfiguration(org.gradle.internal.deprecation.DeprecatableConfiguration) Configuration(org.gradle.api.artifacts.Configuration) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) DeprecatableConfiguration(org.gradle.internal.deprecation.DeprecatableConfiguration)

Example 3 with DeprecatableConfiguration

use of org.gradle.internal.deprecation.DeprecatableConfiguration in project gradle by gradle.

the class BasePlugin method configureConfigurations.

private void configureConfigurations(final Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    ((ProjectInternal) project).getInternalStatus().convention("integration");
    final DeprecatableConfiguration archivesConfiguration = (DeprecatableConfiguration) configurations.maybeCreate(Dependency.ARCHIVES_CONFIGURATION).setDescription("Configuration for archive artifacts.");
    final DeprecatableConfiguration defaultConfiguration = (DeprecatableConfiguration) configurations.maybeCreate(Dependency.DEFAULT_CONFIGURATION).setDescription("Configuration for default artifacts.");
    final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create("defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts());
    archivesConfiguration.deprecateForResolution(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME, JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME);
    defaultConfiguration.deprecateForResolution(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME, JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME);
    archivesConfiguration.deprecateForDeclaration(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, JavaPlugin.API_CONFIGURATION_NAME);
    defaultConfiguration.deprecateForDeclaration(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, JavaPlugin.API_CONFIGURATION_NAME);
    configurations.all(configuration -> {
        if (!configuration.equals(archivesConfiguration)) {
            configuration.getArtifacts().configureEach(artifact -> {
                if (configuration.isVisible()) {
                    defaultArtifacts.addCandidate(artifact);
                }
            });
        }
    });
}
Also used : DefaultArtifactPublicationSet(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) DeprecatableConfiguration(org.gradle.internal.deprecation.DeprecatableConfiguration)

Example 4 with DeprecatableConfiguration

use of org.gradle.internal.deprecation.DeprecatableConfiguration 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)

Example 5 with DeprecatableConfiguration

use of org.gradle.internal.deprecation.DeprecatableConfiguration in project gradle by gradle.

the class JavaLibraryPlugin method deprecateConfigurationsForDeclaration.

private void deprecateConfigurationsForDeclaration(SourceSetContainer sourceSets, ConfigurationContainer configurations) {
    SourceSet sourceSet = sourceSets.getByName("main");
    DeprecatableConfiguration apiElementsConfiguration = (DeprecatableConfiguration) configurations.getByName(sourceSet.getApiElementsConfigurationName());
    DeprecatableConfiguration runtimeElementsConfiguration = (DeprecatableConfiguration) configurations.getByName(sourceSet.getRuntimeElementsConfigurationName());
    DeprecatableConfiguration compileClasspathConfiguration = (DeprecatableConfiguration) configurations.getByName(sourceSet.getCompileClasspathConfigurationName());
    DeprecatableConfiguration runtimeClasspathConfiguration = (DeprecatableConfiguration) configurations.getByName(sourceSet.getRuntimeClasspathConfigurationName());
    String implementationConfigurationName = sourceSet.getImplementationConfigurationName();
    String compileOnlyConfigurationName = sourceSet.getCompileOnlyConfigurationName();
    String runtimeOnlyConfigurationName = sourceSet.getRuntimeOnlyConfigurationName();
    String apiConfigurationName = sourceSet.getApiConfigurationName();
    apiElementsConfiguration.deprecateForDeclaration(implementationConfigurationName, apiConfigurationName, compileOnlyConfigurationName);
    runtimeElementsConfiguration.deprecateForDeclaration(implementationConfigurationName, apiConfigurationName, compileOnlyConfigurationName, runtimeOnlyConfigurationName);
    compileClasspathConfiguration.deprecateForDeclaration(implementationConfigurationName, apiConfigurationName, compileOnlyConfigurationName);
    runtimeClasspathConfiguration.deprecateForDeclaration(implementationConfigurationName, apiConfigurationName, compileOnlyConfigurationName, runtimeOnlyConfigurationName);
}
Also used : SourceSet(org.gradle.api.tasks.SourceSet) DeprecatableConfiguration(org.gradle.internal.deprecation.DeprecatableConfiguration)

Aggregations

DeprecatableConfiguration (org.gradle.internal.deprecation.DeprecatableConfiguration)9 Configuration (org.gradle.api.artifacts.Configuration)7 SourceSet (org.gradle.api.tasks.SourceSet)5 File (java.io.File)3 Plugin (org.gradle.api.Plugin)3 Project (org.gradle.api.Project)3 Task (org.gradle.api.Task)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 Inject (javax.inject.Inject)2 Action (org.gradle.api.Action)2 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)2 DependencyHandler (org.gradle.api.artifacts.dsl.DependencyHandler)2 DefaultArtifactPublicationSet (org.gradle.api.internal.plugins.DefaultArtifactPublicationSet)2 ExtensionAware (org.gradle.api.plugins.ExtensionAware)2 JavaPluginExtension (org.gradle.api.plugins.JavaPluginExtension)2 SpotlessExtension (com.diffplug.gradle.spotless.SpotlessExtension)1 SpotlessPlugin (com.diffplug.gradle.spotless.SpotlessPlugin)1 VersionsPlugin (com.github.benmanes.gradle.versions.VersionsPlugin)1 DependencyUpdatesTask (com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1