From 0ebfb12abab9869976137c4a3a79c2fd197de931 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Wed, 24 Sep 2025 10:33:06 -0700 Subject: [PATCH 1/2] Adopt the latest Spotless 8.0.0 --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 92bffc5031..64db3b18a8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,7 +6,7 @@ pluginManagement { } plugins { - id 'com.diffplug.spotless' version '7.2.1' apply false + id 'com.diffplug.spotless' version '8.0.0' apply false // https://plugins.gradle.org/plugin/com.gradle.plugin-publish id 'com.gradle.plugin-publish' version '2.0.0' apply false // https://github.com/gradle-nexus/publish-plugin/releases From a0d9dbe89e1483926fa69cc7546cdff4e412fe21 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Wed, 24 Sep 2025 10:38:31 -0700 Subject: [PATCH 2/2] Use the new `forbidRegex` to protect against internal API. --- gradle/spotless.gradle | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/gradle/spotless.gradle b/gradle/spotless.gradle index 0289e09d57..f19bf46911 100644 --- a/gradle/spotless.gradle +++ b/gradle/spotless.gradle @@ -1,17 +1,5 @@ apply plugin: 'com.diffplug.spotless' spotless { - def noInternalDepsClosure = { - String text = it - /* - * No good way to get around using this import: - * https://github.com/gradle/gradle/issues/3191 - */ - String regex = "import org\\.gradle\\.api\\.internal\\.(?!plugins\\.DslObject)(?!project\\.ProjectInternal)" - if ((text.contains('import org.gradle.internal.') || text.find(regex)) && - !text.contains('def noInternalDepsClosure')) { - throw new AssertionError("Accidental internal import") - } - } if (project != rootProject) { // the rootProject doesn't have any java java { @@ -22,9 +10,9 @@ spotless { eclipse().configFile rootProject.file('gradle/spotless.eclipseformat.xml') trimTrailingWhitespace() removeUnusedImports() - removeWildcardImports() formatAnnotations() - custom 'noInternalDeps', noInternalDepsClosure + forbidWildcardImports() + forbidRegex('ForbidGradleInternal', 'import org\\.gradle\\.api\\.internal\\.(.*)', "Don't use Gradle's internal API") } } groovyGradle {