Skip to content

Commit 6a82d12

Browse files
authored
Remove deprecated Configuration.setVisible(boolean) call (Gradle 9.8) (#271)
* Remove deprecated Configuration.setVisible(boolean) call The per-project producer configuration called `isVisible = false`, which Gradle deprecated in 9.8.0-milestone-2 (scheduled for removal in Gradle 11). Builds that fail on deprecation warnings (`org.gradle.warning.mode=fail`) break as soon as a project applying the nmcp plugin is configured. The `visible` property no longer has any meaningful effect on the build, and the internal `nmcpProducer` configuration is already kept out of resolution via `canBeConsumed=true`/`canBeResolved=false`, so the call can be removed without changing behaviour on any supported Gradle version. * Guard Configuration.setVisible(boolean) behind a Gradle < 9.8 check Per review feedback: keep the `isVisible = false` behaviour on Gradle versions where it still matters (so publications aren't published as part of `assemble`), and only skip it on Gradle 9.8+ where the property is deprecated and inert. This avoids the deprecation warning on 9.8+ while preserving the original behaviour on older Gradle versions.
1 parent 342716d commit 6a82d12

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎nmcp/src/main/kotlin/nmcp/internal/DefaultNmcpExtension.kt‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import org.gradle.api.Action
1010
import org.gradle.api.Project
1111
import org.gradle.api.publish.PublishingExtension
1212
import org.gradle.api.publish.maven.MavenPublication
13+
import org.gradle.util.GradleVersion
1314

1415
@GExtension(pluginId = "com.gradleup.nmcp", publicType = NmcpExtension::class, extensionName = nmcpExtensionName)
1516
internal abstract class DefaultNmcpExtension(private val project: Project): NmcpExtension {
@@ -25,7 +26,12 @@ internal abstract class DefaultNmcpExtension(private val project: Project): Nmcp
2526
it.isCanBeConsumed = true
2627
it.isCanBeResolved = false
2728
// See https://github.com/GradleUp/nmcp/issues/2
28-
it.isVisible = false
29+
// Without this, the publications end up being published as part of `assemble`.
30+
// `Configuration.setVisible(boolean)` is deprecated as of Gradle 9.8 (and inert since),
31+
// so only call it on older Gradle versions to stay warning-clean on 9.8+.
32+
if (GradleVersion.current() < GradleVersion.version("9.8")) {
33+
it.isVisible = false
34+
}
2935

3036
it.configureAttributes(project)
3137
}

0 commit comments

Comments
 (0)