diff --git a/platforms/documentation/docs/src/docs/userguide/releases/upgrading/upgrading_version_8.adoc b/platforms/documentation/docs/src/docs/userguide/releases/upgrading/upgrading_version_8.adoc index 710ff9675496..3b6e0a509565 100644 --- a/platforms/documentation/docs/src/docs/userguide/releases/upgrading/upgrading_version_8.adoc +++ b/platforms/documentation/docs/src/docs/userguide/releases/upgrading/upgrading_version_8.adoc @@ -47,6 +47,99 @@ JaCoCo has been updated to https://www.jacoco.org/jacoco/trunk/doc/changes.html[ === Deprecations +[[register_feature_main_source_set]] +==== Deprecated calling `registerFeature` using the `main` source set + +Calling `link:{javadocPath}/org/gradle/api/plugins/JavaPluginExtension.html#registerFeature-java.lang.String-org.gradle.api.Action-[registerFeature]` on the `link:{javadocPath}/org/gradle/api/plugins/JavaPluginExtension.html[java]` extension using the `main` source set is deprecated and will change behavior in Gradle 9.0. + +Currently, features created while calling `link:{javadocPath}/org/gradle/api/plugins/FeatureSpec.html#usingSourceSet-org.gradle.api.tasks.SourceSet-[usingSourceSet]` with the `main` source set are initialized differently than features created while calling `usingSourceSet` with any other source set. +Previously, when using the `main` source set, new `implementation`, `compileOnly`, `runtimeOnly`, `api`, and `compileOnlyApi` configurations were created, and the compile and runtime classpaths of the `main` source set were configured to extend these configurations. + +Starting in Gradle 9.0, the `main` source set will be treated like any other source set. +With the `java-library` plugin applied (or any other plugin that applies the `java` plugin), calling `usingSourceSet` with the `main` source set will throw an exception. +This is because the `java` plugin already configures a main feature. +Only if the `java` plugin is not applied will the `main` source set be permitted when calling `usingSourceSet`. + +Code that currently registers features with the main source set, like so: +===== +[.multi-language-sample] +====== +.build.gradle.kts +[source,kotlin] +---- +plugins { + id("java-library") +} + +java { + registerFeature("feature") { + usingSourceSet(sourceSets["main"]) + } +} +---- +====== +[.multi-language-sample] +====== +.build.gradle +[source,groovy] +---- +plugins { + id("java-library") +} + +java { + registerFeature("feature") { + usingSourceSet(sourceSets.main) + } +} +---- +====== +===== + +Should instead create a separate source set for the feature, and register the feature with that source set: +===== +[.multi-language-sample] +====== +.build.gradle.kts +[source,kotlin] +---- +plugins { + id("java-library") +} + +sourceSets { + create("feature") +} + +java { + registerFeature("feature") { + usingSourceSet(sourceSets["feature"]) + } +} +---- +====== +[.multi-language-sample] +====== +.build.gradle +[source,groovy] +---- +plugins { + id("java-library") +} + +sourceSets { + feature +} + +java { + registerFeature("feature") { + usingSourceSet(sourceSets.feature) + } +} +---- +====== +===== + [[deprecated_artifact_identifier]] ==== Deprecated `ArtifactIdentifier` The `ArtifactIdentifier` class has been deprecated for removal in Gradle 9.0. diff --git a/platforms/jvm/plugins-java-base/src/main/java/org/gradle/api/plugins/internal/DefaultJavaFeatureSpec.java b/platforms/jvm/plugins-java-base/src/main/java/org/gradle/api/plugins/internal/DefaultJavaFeatureSpec.java index 28034229ec75..d3541c50f5a4 100644 --- a/platforms/jvm/plugins-java-base/src/main/java/org/gradle/api/plugins/internal/DefaultJavaFeatureSpec.java +++ b/platforms/jvm/plugins-java-base/src/main/java/org/gradle/api/plugins/internal/DefaultJavaFeatureSpec.java @@ -18,16 +18,18 @@ import org.gradle.api.InvalidUserCodeException; import org.gradle.api.capabilities.Capability; import org.gradle.api.internal.project.ProjectInternal; +import org.gradle.api.plugins.FeatureSpec; import org.gradle.api.plugins.jvm.internal.DefaultJvmFeature; import org.gradle.api.plugins.jvm.internal.JvmFeatureInternal; import org.gradle.api.tasks.SourceSet; import org.gradle.internal.component.external.model.DefaultImmutableCapability; import org.gradle.internal.component.external.model.ProjectDerivedCapability; +import org.gradle.internal.deprecation.DeprecationLogger; import java.util.LinkedHashSet; import java.util.Set; -public class DefaultJavaFeatureSpec implements FeatureSpecInternal { +public class DefaultJavaFeatureSpec implements FeatureSpec { private final String name; private final Set capabilities = new LinkedHashSet<>(1); private final ProjectInternal project; @@ -67,12 +69,10 @@ public void disablePublication() { allowPublication = false; } - @Override public boolean isPublished() { return allowPublication; } - @Override public JvmFeatureInternal create() { if (sourceSet == null) { throw new InvalidUserCodeException("You must specify which source set to use for feature '" + name + "'"); @@ -82,6 +82,14 @@ public JvmFeatureInternal create() { capabilities.add(new ProjectDerivedCapability(project, name)); } + if (SourceSet.isMain(sourceSet)) { + DeprecationLogger.deprecateBehaviour(String.format("The '%s' feature was created using the main source set.", name)) + .withAdvice("The main source set is reserved for production code and should not be used for features. Use another source set instead.") + .willBecomeAnErrorInGradle9() + .withUpgradeGuideSection(8, "deprecate_register_feature_main_source_set") + .nagUser(); + } + JvmFeatureInternal feature = new DefaultJvmFeature(name, sourceSet, capabilities, project, true, SourceSet.isMain(sourceSet)); feature.withApi(); diff --git a/platforms/jvm/plugins-java-base/src/main/java/org/gradle/api/plugins/internal/DefaultJavaPluginExtension.java b/platforms/jvm/plugins-java-base/src/main/java/org/gradle/api/plugins/internal/DefaultJavaPluginExtension.java index 1214c518fa1b..fef9a26adedb 100644 --- a/platforms/jvm/plugins-java-base/src/main/java/org/gradle/api/plugins/internal/DefaultJavaPluginExtension.java +++ b/platforms/jvm/plugins-java-base/src/main/java/org/gradle/api/plugins/internal/DefaultJavaPluginExtension.java @@ -213,7 +213,7 @@ public boolean getAutoTargetJvmDisabled() { */ @Override public void registerFeature(String name, Action configureAction) { - FeatureSpecInternal spec = new DefaultJavaFeatureSpec(validateFeatureName(name), project); + DefaultJavaFeatureSpec spec = new DefaultJavaFeatureSpec(validateFeatureName(name), project); configureAction.execute(spec); JvmFeatureInternal feature = spec.create(); diff --git a/platforms/jvm/plugins-java-base/src/main/java/org/gradle/api/plugins/internal/FeatureSpecInternal.java b/platforms/jvm/plugins-java-base/src/main/java/org/gradle/api/plugins/internal/FeatureSpecInternal.java deleted file mode 100644 index 65b35b2f8b9b..000000000000 --- a/platforms/jvm/plugins-java-base/src/main/java/org/gradle/api/plugins/internal/FeatureSpecInternal.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.gradle.api.plugins.internal; - -import org.gradle.api.plugins.FeatureSpec; -import org.gradle.api.plugins.jvm.internal.JvmFeatureInternal; - -public interface FeatureSpecInternal extends FeatureSpec { - boolean isPublished(); - JvmFeatureInternal create(); -} diff --git a/platforms/jvm/plugins-java/src/integTest/groovy/org/gradle/api/plugins/JavaPluginTest.groovy b/platforms/jvm/plugins-java/src/integTest/groovy/org/gradle/api/plugins/JavaPluginTest.groovy index b2bcb45e1ba3..d89b2e8fb010 100644 --- a/platforms/jvm/plugins-java/src/integTest/groovy/org/gradle/api/plugins/JavaPluginTest.groovy +++ b/platforms/jvm/plugins-java/src/integTest/groovy/org/gradle/api/plugins/JavaPluginTest.groovy @@ -474,23 +474,26 @@ class JavaPluginTest extends AbstractProjectBuilderSpec { project.pluginManager.apply(JavaPlugin) commonProject.pluginManager.apply(JavaPlugin) commonProject.group = "group" - commonProject.extensions.configure(JavaPluginExtension) { - it.registerFeature("other") { - it.usingSourceSet(commonProject.sourceSets.main) + commonProject.extensions.configure(JavaPluginExtension) { java -> + java.sourceSets.create("other") + java.registerFeature("other") { + it.usingSourceSet(java.sourceSets.other) } } middleProject.pluginManager.apply(JavaPlugin) middleProject.group = "group" - middleProject.extensions.configure(JavaPluginExtension) { - it.registerFeature("other") { - it.usingSourceSet(middleProject.sourceSets.main) + middleProject.extensions.configure(JavaPluginExtension) { java -> + java.sourceSets.create("other") + java.registerFeature("other") { + it.usingSourceSet(java.sourceSets.other) } } appProject.pluginManager.apply(JavaPlugin) appProject.group = "group" - appProject.extensions.configure(JavaPluginExtension) { - it.registerFeature("other") { - it.usingSourceSet(appProject.sourceSets.main) + appProject.extensions.configure(JavaPluginExtension) { java -> + java.sourceSets.create("other") + java.registerFeature("other") { + it.usingSourceSet(java.sourceSets.other) } } diff --git a/platforms/software/dependency-management/src/crossVersionTest/groovy/org/gradle/integtests/resolve/GradleMetadataJavaLibraryCrossVersionIntegrationTest.groovy b/platforms/software/dependency-management/src/crossVersionTest/groovy/org/gradle/integtests/resolve/GradleMetadataJavaLibraryCrossVersionIntegrationTest.groovy index a8ee99c00dbf..e37f44c41526 100644 --- a/platforms/software/dependency-management/src/crossVersionTest/groovy/org/gradle/integtests/resolve/GradleMetadataJavaLibraryCrossVersionIntegrationTest.groovy +++ b/platforms/software/dependency-management/src/crossVersionTest/groovy/org/gradle/integtests/resolve/GradleMetadataJavaLibraryCrossVersionIntegrationTest.groovy @@ -69,8 +69,11 @@ class GradleMetadataJavaLibraryCrossVersionIntegrationTest extends CrossVersionI java { if (JavaPluginExtension.metaClass.respondsTo(delegate, 'registerFeature')) { + sourceSets { + hibernateSupport + } registerFeature("hibernateSupport") { - usingSourceSet(sourceSets.main) + usingSourceSet(sourceSets.hibernateSupport) capability("com.acme", "producer-hibernate-support", "1.0") } } diff --git a/platforms/software/ivy/src/integTest/groovy/org/gradle/api/publish/ivy/IvyPublishFeaturesJavaPluginIntegTest.groovy b/platforms/software/ivy/src/integTest/groovy/org/gradle/api/publish/ivy/IvyPublishFeaturesJavaPluginIntegTest.groovy index 193f64cc7122..82c9209bbc03 100644 --- a/platforms/software/ivy/src/integTest/groovy/org/gradle/api/publish/ivy/IvyPublishFeaturesJavaPluginIntegTest.groovy +++ b/platforms/software/ivy/src/integTest/groovy/org/gradle/api/publish/ivy/IvyPublishFeaturesJavaPluginIntegTest.groovy @@ -23,9 +23,13 @@ class IvyPublishFeaturesJavaPluginIntegTest extends AbstractIvyPublishFeaturesJa given: buildFile << """ + sourceSets { + feature + } + java { registerFeature("feature") { - usingSourceSet(sourceSets.main) + usingSourceSet(sourceSets.feature) } } @@ -50,7 +54,7 @@ class IvyPublishFeaturesJavaPluginIntegTest extends AbstractIvyPublishFeaturesJa noMoreDependencies() } javaLibrary.parsedModuleMetadata.variant("featureRuntimeElements") { - assert files*.name == ['publishTest-1.9.jar'] + assert files*.name == ['publishTest-1.9-feature.jar'] dependency('org', 'optionaldep', '1.0') noMoreDependencies() } @@ -65,7 +69,7 @@ class IvyPublishFeaturesJavaPluginIntegTest extends AbstractIvyPublishFeaturesJa resolveRuntimeArtifacts(javaLibrary) { optionalFeatureCapabilities << "org.gradle.test:publishTest-feature:1.0" withModuleMetadata { - expectFiles "publishTest-1.9.jar", "optionaldep-1.0.jar" + expectFiles "publishTest-1.9.jar", "publishTest-1.9-feature.jar", "optionaldep-1.0.jar" } withoutModuleMetadata { // documents the current behavior - ivy does not use variant matching and hence the requested capability is ignored and the default configuration is selected @@ -80,9 +84,13 @@ class IvyPublishFeaturesJavaPluginIntegTest extends AbstractIvyPublishFeaturesJa given: buildFile << """ + sourceSets { + feature + } + java { registerFeature("feature") { - usingSourceSet(sourceSets.main) + usingSourceSet(sourceSets.feature) } } @@ -112,7 +120,7 @@ class IvyPublishFeaturesJavaPluginIntegTest extends AbstractIvyPublishFeaturesJa noMoreDependencies() } javaLibrary.parsedModuleMetadata.variant("featureRuntimeElements") { - assert files*.name == ["${name}-${version}.jar"] + assert files*.name == ["${name}-${version}-feature.jar"] dependency('org', 'optionaldep', '1.0') noMoreDependencies() } @@ -127,7 +135,7 @@ class IvyPublishFeaturesJavaPluginIntegTest extends AbstractIvyPublishFeaturesJa resolveRuntimeArtifacts(javaLibrary) { optionalFeatureCapabilities << "$group:${name}-feature:1.0" withModuleMetadata { - expectFiles "${name}-${version}.jar", "optionaldep-1.0.jar" + expectFiles "${name}-${version}.jar", "${name}-${version}-feature.jar", "optionaldep-1.0.jar" } withoutModuleMetadata { // documents the current behavior - ivy does not use variant matching and hence the requested capability is ignored and the default configuration is selected diff --git a/platforms/software/maven/src/integTest/groovy/org/gradle/api/publish/maven/MavenPublishFeaturesJavaPluginIntegTest.groovy b/platforms/software/maven/src/integTest/groovy/org/gradle/api/publish/maven/MavenPublishFeaturesJavaPluginIntegTest.groovy index 9489e73446e7..adbd62b473d1 100644 --- a/platforms/software/maven/src/integTest/groovy/org/gradle/api/publish/maven/MavenPublishFeaturesJavaPluginIntegTest.groovy +++ b/platforms/software/maven/src/integTest/groovy/org/gradle/api/publish/maven/MavenPublishFeaturesJavaPluginIntegTest.groovy @@ -23,9 +23,15 @@ class MavenPublishFeaturesJavaPluginIntegTest extends AbstractMavenPublishFeatur given: buildFile << """ + sourceSets { + feature + } + + repositories { maven { url "${mavenRepo.uri}" } } + java { registerFeature("feature") { - usingSourceSet(sourceSets.main) + usingSourceSet(sourceSets.feature) } } @@ -53,7 +59,7 @@ class MavenPublishFeaturesJavaPluginIntegTest extends AbstractMavenPublishFeatur noMoreDependencies() } javaLibrary.parsedModuleMetadata.variant("featureRuntimeElements") { - assert files*.name == ['publishTest-1.9.jar'] + assert files*.name == ['publishTest-1.9-feature.jar'] dependency('org', 'optionaldep', '1.0') noMoreDependencies() } @@ -70,7 +76,7 @@ class MavenPublishFeaturesJavaPluginIntegTest extends AbstractMavenPublishFeatur resolveRuntimeArtifacts(javaLibrary) { optionalFeatureCapabilities << "org.gradle.test:publishTest-feature:1.0" withModuleMetadata { - expectFiles "publishTest-1.9.jar", "optionaldep-1.0.jar" + expectFiles "publishTest-1.9.jar", "publishTest-1.9-feature.jar", "optionaldep-1.0.jar" } withoutModuleMetadata { shouldFail { @@ -87,9 +93,15 @@ class MavenPublishFeaturesJavaPluginIntegTest extends AbstractMavenPublishFeatur given: buildFile << """ + sourceSets { + feature + } + + repositories { maven { url "${mavenRepo.uri}" } } + java { registerFeature("feature") { - usingSourceSet(sourceSets.main) + usingSourceSet(sourceSets.feature) } } @@ -119,7 +131,7 @@ class MavenPublishFeaturesJavaPluginIntegTest extends AbstractMavenPublishFeatur noMoreDependencies() } javaLibrary.parsedModuleMetadata.variant("featureApiElements") { - assert files*.name == ["${name}-${version}.jar"] + assert files*.name == ["${name}-${version}-feature.jar"] noMoreDependencies() } javaLibrary.parsedModuleMetadata.variant("featureRuntimeElements") { @@ -139,7 +151,7 @@ class MavenPublishFeaturesJavaPluginIntegTest extends AbstractMavenPublishFeatur resolveRuntimeArtifacts(javaLibrary) { optionalFeatureCapabilities << "$group:${name}-feature:1.0" withModuleMetadata { - expectFiles "${name}-${version}.jar", "optionaldep-1.0.jar" + expectFiles "${name}-${version}.jar", "${name}-${version}-feature.jar", "optionaldep-1.0.jar" } withoutModuleMetadata { shouldFail { diff --git a/subprojects/architecture-test/src/changes/archunit_store/internal-api-nullability.txt b/subprojects/architecture-test/src/changes/archunit_store/internal-api-nullability.txt index f7aef39ee145..39754cc56de4 100644 --- a/subprojects/architecture-test/src/changes/archunit_store/internal-api-nullability.txt +++ b/subprojects/architecture-test/src/changes/archunit_store/internal-api-nullability.txt @@ -1025,7 +1025,6 @@ Class is not annot Class is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (DefaultJavaPluginExtension.java:0) Class is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (DefaultJavaPluginExtension.java:0) Class is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (DefaultWarPluginConvention.java:0) -Class is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (FeatureSpecInternal.java:0) Class is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (HelpBuiltInCommand.java:0) Class is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (HelpTasksAutoApplyAction.java:0) Class is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (JavaConfigurationVariantMapping.java:0) diff --git a/subprojects/plugins/src/integTest/groovy/org/gradle/java/JavaLibraryFeatureCompilationIntegrationTest.groovy b/subprojects/plugins/src/integTest/groovy/org/gradle/java/JavaLibraryFeatureCompilationIntegrationTest.groovy index e558f4c7435f..b0836d59cc25 100644 --- a/subprojects/plugins/src/integTest/groovy/org/gradle/java/JavaLibraryFeatureCompilationIntegrationTest.groovy +++ b/subprojects/plugins/src/integTest/groovy/org/gradle/java/JavaLibraryFeatureCompilationIntegrationTest.groovy @@ -39,9 +39,13 @@ class JavaLibraryFeatureCompilationIntegrationTest extends AbstractIntegrationSp buildFile << """ apply plugin: 'java-library' + sourceSets { + myFeature + } + java { registerFeature("myFeature") { - usingSourceSet(sourceSets.main) + usingSourceSet(sourceSets.myFeature) } } @@ -59,7 +63,7 @@ class JavaLibraryFeatureCompilationIntegrationTest extends AbstractIntegrationSp } } """ - file("src/main/java/com/bar/Bar.java") << """ + file("src/myFeature/java/com/bar/Bar.java") << """ package com.bar; import com.foo.Foo; @@ -72,7 +76,7 @@ class JavaLibraryFeatureCompilationIntegrationTest extends AbstractIntegrationSp """ when: - succeeds ':compileJava' + succeeds ':compileMyFeatureJava' then: executedAndNotSkipped ':b:compileJava' @@ -97,9 +101,13 @@ class JavaLibraryFeatureCompilationIntegrationTest extends AbstractIntegrationSp group = 'org.gradle.test' + sourceSets { + myFeature + } + java { registerFeature("myFeature") { - usingSourceSet(sourceSets.main) + usingSourceSet(sourceSets.myFeature) } } @@ -152,7 +160,7 @@ class JavaLibraryFeatureCompilationIntegrationTest extends AbstractIntegrationSp """ } - file("b/src/main/java/com/foo/Foo.java") << """ + file("b/src/myFeature/java/com/foo/Foo.java") << """ package com.foo; public class Foo { public void foo() { @@ -175,8 +183,8 @@ class JavaLibraryFeatureCompilationIntegrationTest extends AbstractIntegrationSp succeeds ':compileJava' then: - executedAndNotSkipped ':b:compileJava', ':c:compileJava', ':d:compileJava', ':e:compileJava', ':f:compileJava' - packagingTasks(compileClasspathPackaging, 'b') + executedAndNotSkipped ':b:compileMyFeatureJava', ':c:compileJava', ':d:compileJava', ':e:compileJava', ':f:compileJava' + packagingTasks(compileClasspathPackaging, 'b', 'myFeature') packagingTasks(compileClasspathPackaging, 'c') packagingTasks(compileClasspathPackaging, 'd') packagingTasks(compileClasspathPackaging, 'e') @@ -186,7 +194,7 @@ class JavaLibraryFeatureCompilationIntegrationTest extends AbstractIntegrationSp succeeds 'clean', ':verifyClasspath' then: - executedAndNotSkipped ':b:jar', ':c:jar', ':d:jar', ':g:jar' // runtime + executedAndNotSkipped ':b:myFeatureJar', ':c:jar', ':d:jar', ':g:jar' // runtime packagingTasks(compileClasspathPackaging, 'e') // compile time only packagingTasks(compileClasspathPackaging, 'f') // compile time only @@ -206,9 +214,13 @@ class JavaLibraryFeatureCompilationIntegrationTest extends AbstractIntegrationSp file("b/build.gradle") << """ apply plugin: 'java-library' + sourceSets { + myFeature + } + java { registerFeature("myFeature") { - usingSourceSet(sourceSets.main) + usingSourceSet(sourceSets.myFeature) } } @@ -246,7 +258,7 @@ class JavaLibraryFeatureCompilationIntegrationTest extends AbstractIntegrationSp } } """ - file("src/main/java/com/bar/Bar.java") << """ + file("src/myFeature/java/com/bar/Bar.java") << """ package com.bar; import com.foo.Foo; @@ -262,9 +274,8 @@ class JavaLibraryFeatureCompilationIntegrationTest extends AbstractIntegrationSp succeeds ':compileJava' then: - executedAndNotSkipped ':b:compileJava', ':c:compileJava' + executedAndNotSkipped ':b:compileJava' packagingTasks(compileClasspathPackaging, 'b') - packagingTasks(compileClasspathPackaging, 'c') when: succeeds 'clean', ':resolveRuntime' @@ -492,6 +503,7 @@ class JavaLibraryFeatureCompilationIntegrationTest extends AbstractIntegrationSp """ when: + executer.expectDocumentedDeprecationWarning("The 'feat' feature was created using the main source set. This behavior has been deprecated. This will fail with an error in Gradle 9.0. The main source set is reserved for production code and should not be used for features. Use another source set instead. Consult the upgrading guide for further information: https://docs.gradle.org/current/userguide/upgrading_version_8.html#deprecate_register_feature_main_source_set") run 'test' then: @@ -540,7 +552,44 @@ class JavaLibraryFeatureCompilationIntegrationTest extends AbstractIntegrationSp executedAndNotSkipped ':compileMain211Java', ':compileMain212Java' } - def "creates configurations when using main source set and java-library is not applied" () { + def "creates main feature with main source set when java plugin not applied" () { + given: + buildFile << """ + plugins { + id('java-base') + } + + sourceSets { + main + } + + configurations { + testCompileClasspath + testRuntimeClasspath + } + + java { + registerFeature('main') { + usingSourceSet(sourceSets.main) + } + } + """ + + when: + executer.expectDocumentedDeprecationWarning("The 'main' feature was created using the main source set. This behavior has been deprecated. This will fail with an error in Gradle 9.0. The main source set is reserved for production code and should not be used for features. Use another source set instead. Consult the upgrading guide for further information: https://docs.gradle.org/current/userguide/upgrading_version_8.html#deprecate_register_feature_main_source_set") + succeeds 'dependencies' + + then: + outputContains("mainRuntimeOnly") + outputContains("mainCompileOnly") + outputContains("mainImplementation") + outputContains("mainApi") + outputContains("mainCompileOnlyApi") + outputContains("mainRuntimeElements") + outputContains("mainApiElements") + } + + def "creates configurations when using main source set, non-main feature, java-library is not applied" () { given: buildFile << """ plugins { @@ -564,6 +613,7 @@ class JavaLibraryFeatureCompilationIntegrationTest extends AbstractIntegrationSp """ when: + executer.expectDocumentedDeprecationWarning("The 'feature' feature was created using the main source set. This behavior has been deprecated. This will fail with an error in Gradle 9.0. The main source set is reserved for production code and should not be used for features. Use another source set instead. Consult the upgrading guide for further information: https://docs.gradle.org/current/userguide/upgrading_version_8.html#deprecate_register_feature_main_source_set") succeeds 'dependencies' then: @@ -590,6 +640,7 @@ class JavaLibraryFeatureCompilationIntegrationTest extends AbstractIntegrationSp """ when: + executer.expectDocumentedDeprecationWarning("The 'main' feature was created using the main source set. This behavior has been deprecated. This will fail with an error in Gradle 9.0. The main source set is reserved for production code and should not be used for features. Use another source set instead. Consult the upgrading guide for further information: https://docs.gradle.org/current/userguide/upgrading_version_8.html#deprecate_register_feature_main_source_set") run 'dependencies' then: