From 17c73e229cbf39cd2ea96f4208ab39ffb5b69b06 Mon Sep 17 00:00:00 2001 From: Goooler Date: Fri, 11 Sep 2026 14:56:01 +0800 Subject: [PATCH] Stop calling deprecated Configuration.setVisible from Gradle 9.1.0 ``` The Configuration.setVisible(boolean) method has been deprecated. This is scheduled to be removed in Gradle 11. Consult the upgrading guide for further information: https://docs.gradle.org/9.8.0-rc-1/userguide/upgrading_version_9.html#deprecate-visible-property at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.setVisible(DefaultConfiguration.java:376) at org.gradle.api.internal.artifacts.configurations.DefaultLegacyConfiguration_Decorated.setVisible(Unknown Source) ``` --- plugin-gradle/CHANGES.md | 1 + .../gradle/spotless/GradleProvisioner.java | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index 7bc475f509..c34b85a00c 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -7,6 +7,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Fixed - `versionCatalog()` preserves entries when comments contain unmatched brackets, preserves commas inside quoted strings, and keeps significant line boundaries in multiline entries. ([#3042](https://github.com/diffplug/spotless/pull/3042)) - `versionCatalog()` now reports unfinished entries as lints at their starting line. These fail formatting by default, so upgrading may expose catalog errors that previously caused silent data loss. ([#3042](https://github.com/diffplug/spotless/pull/3042)) +- Stop calling deprecated `Configuration.setVisible` from Gradle 9.1.0 ([#3053](https://github.com/diffplug/spotless/pull/3053)) ## [8.10.2] - 2026-09-04 ### Fixed diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java index 52196faf83..1e46194697 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java @@ -35,6 +35,7 @@ import org.gradle.api.attributes.Category; import org.gradle.api.attributes.java.TargetJvmEnvironment; import org.gradle.api.initialization.dsl.ScriptHandler; +import org.gradle.util.GradleVersion; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,16 +54,16 @@ enum Policy { public DedupingProvisioner dedupingProvisioner(Project project) { return switch (this) { - case ROOT_PROJECT -> new DedupingProvisioner(forProject(project)); - case ROOT_BUILDSCRIPT -> new DedupingProvisioner(forRootProjectBuildscript(project)); - default -> throw Unhandled.enumException(this); + case ROOT_PROJECT -> new DedupingProvisioner(forProject(project)); + case ROOT_BUILDSCRIPT -> new DedupingProvisioner(forRootProjectBuildscript(project)); + default -> throw Unhandled.enumException(this); }; } public DedupingP2Provisioner dedupingP2Provisioner(Project project) { return switch (this) { - case ROOT_PROJECT, ROOT_BUILDSCRIPT -> new DedupingP2Provisioner(P2Provisioner.createDefault(), defaultP2CacheDirectory(project)); - default -> throw Unhandled.enumException(this); + case ROOT_PROJECT, ROOT_BUILDSCRIPT -> new DedupingP2Provisioner(P2Provisioner.createDefault(), defaultP2CacheDirectory(project)); + default -> throw Unhandled.enumException(this); }; } } @@ -133,7 +134,10 @@ private static Provisioner forConfigurationContainer(Project project, Configurat config.setDescription("Spotless internal dependency resolution for " + request); config.setTransitive(withTransitives); config.setCanBeConsumed(false); - config.setVisible(false); + if (GradleVersion.current().compareTo(GradleVersion.version("9.1.0")) < 0) { + // Deprecated from 9.1.0 + config.setVisible(false); + } config.attributes(attr -> { attr.attribute(Category.CATEGORY_ATTRIBUTE, project.getObjects().named(Category.class, Category.LIBRARY)); attr.attribute(Bundling.BUNDLING_ATTRIBUTE, project.getObjects().named(Bundling.class, Bundling.EXTERNAL));