From 870c43fa5ab2ca7e7128191e2bd4a603500f2be1 Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 8 Sep 2026 23:02:03 +0800 Subject: [PATCH 01/11] Migrate Gradle build scripts to Kotlin DSL with build-logic convention plugins --- build-logic/build.gradle.kts | 25 +++ build-logic/settings.gradle.kts | 13 ++ build-logic/src/main/kotlin/ProjectExt.kt | 7 + .../main/kotlin/spotless.changelog.gradle.kts | 54 +++++ .../kotlin/spotless.error-prone.gradle.kts | 37 +++ .../kotlin/spotless.java-publish.gradle.kts | 178 +++++++++++++++ .../kotlin/spotless.java-setup.gradle.kts | 38 ++++ .../kotlin/spotless.nexus-publish.gradle.kts | 31 +++ .../main/kotlin/spotless.rewrite.gradle.kts | 25 +++ .../kotlin/spotless.special-tests.gradle.kts | 36 +++ .../spotless.spotless-conventions.gradle.kts | 48 ++++ .../spotless.spotless-freshmark.gradle.kts | 58 +++++ build.gradle | 27 --- build.gradle.kts | 18 ++ gradle/changelog.gradle | 56 ----- gradle/error-prone.gradle | 34 --- gradle/java-publish.gradle | 210 ------------------ gradle/java-setup.gradle | 43 ---- gradle/libs.versions.toml | 1 + gradle/rewrite.gradle | 27 --- gradle/special-tests.gradle | 47 ---- gradle/spotless-freshmark.gradle | 59 ----- gradle/spotless.gradle | 28 --- lib-extra/build.gradle | 125 ----------- lib-extra/build.gradle.kts | 134 +++++++++++ lib/build.gradle | 153 ------------- lib/build.gradle.kts | 154 +++++++++++++ plugin-gradle/build.gradle | 94 -------- plugin-gradle/build.gradle.kts | 95 ++++++++ plugin-maven/build.gradle | 64 ------ plugin-maven/build.gradle.kts | 61 +++++ settings.gradle | 86 ------- settings.gradle.kts | 82 +++++++ testlib/build.gradle | 43 ---- testlib/build.gradle.kts | 53 +++++ 35 files changed, 1148 insertions(+), 1096 deletions(-) create mode 100644 build-logic/build.gradle.kts create mode 100644 build-logic/settings.gradle.kts create mode 100644 build-logic/src/main/kotlin/ProjectExt.kt create mode 100644 build-logic/src/main/kotlin/spotless.changelog.gradle.kts create mode 100644 build-logic/src/main/kotlin/spotless.error-prone.gradle.kts create mode 100644 build-logic/src/main/kotlin/spotless.java-publish.gradle.kts create mode 100644 build-logic/src/main/kotlin/spotless.java-setup.gradle.kts create mode 100644 build-logic/src/main/kotlin/spotless.nexus-publish.gradle.kts create mode 100644 build-logic/src/main/kotlin/spotless.rewrite.gradle.kts create mode 100644 build-logic/src/main/kotlin/spotless.special-tests.gradle.kts create mode 100644 build-logic/src/main/kotlin/spotless.spotless-conventions.gradle.kts create mode 100644 build-logic/src/main/kotlin/spotless.spotless-freshmark.gradle.kts delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 gradle/changelog.gradle delete mode 100644 gradle/error-prone.gradle delete mode 100644 gradle/java-publish.gradle delete mode 100644 gradle/java-setup.gradle delete mode 100644 gradle/rewrite.gradle delete mode 100644 gradle/special-tests.gradle delete mode 100644 gradle/spotless-freshmark.gradle delete mode 100644 gradle/spotless.gradle delete mode 100644 lib-extra/build.gradle create mode 100644 lib-extra/build.gradle.kts delete mode 100644 lib/build.gradle create mode 100644 lib/build.gradle.kts delete mode 100644 plugin-gradle/build.gradle create mode 100644 plugin-gradle/build.gradle.kts delete mode 100644 plugin-maven/build.gradle create mode 100644 plugin-maven/build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts delete mode 100644 testlib/build.gradle create mode 100644 testlib/build.gradle.kts diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts new file mode 100644 index 0000000000..8a72da2ef2 --- /dev/null +++ b/build-logic/build.gradle.kts @@ -0,0 +1,25 @@ +plugins { + `kotlin-dsl` +} + +val versionCatalog = versionCatalogs.named("libs") + +fun plugin(alias: String): String { + val p = versionCatalog.findPlugin(alias).get().get() + return "${p.pluginId}:${p.pluginId}.gradle.plugin:${p.version}" +} + +dependencies { + implementation(plugin("spotless")) + implementation(plugin("spotless-changelog")) + implementation("com.diffplug.spotless-changelog:spotless-changelog-lib:3.1.2") + implementation(plugin("spotbugs")) + implementation(plugin("errorprone")) + implementation(plugin("rewrite")) + implementation(plugin("test-logger")) + implementation(plugin("nexus-publish")) + implementation(plugin("develocity")) + + // TODO: https://github.com/gradle/gradle/issues/15383 + implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) +} diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts new file mode 100644 index 0000000000..a51240b49f --- /dev/null +++ b/build-logic/settings.gradle.kts @@ -0,0 +1,13 @@ +dependencyResolutionManagement { + repositories { + mavenCentral() + gradlePluginPortal() + } + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} + +rootProject.name = "build-logic" diff --git a/build-logic/src/main/kotlin/ProjectExt.kt b/build-logic/src/main/kotlin/ProjectExt.kt new file mode 100644 index 0000000000..c60493beae --- /dev/null +++ b/build-logic/src/main/kotlin/ProjectExt.kt @@ -0,0 +1,7 @@ +import org.gradle.accessors.dm.LibrariesForLibs +import org.gradle.api.Project +import org.gradle.kotlin.dsl.findByType +import org.gradle.kotlin.dsl.getByType + +val Project.libs: LibrariesForLibs + get() = extensions.findByType() ?: rootProject.extensions.getByType() diff --git a/build-logic/src/main/kotlin/spotless.changelog.gradle.kts b/build-logic/src/main/kotlin/spotless.changelog.gradle.kts new file mode 100644 index 0000000000..9b0259441f --- /dev/null +++ b/build-logic/src/main/kotlin/spotless.changelog.gradle.kts @@ -0,0 +1,54 @@ +plugins { + id("com.diffplug.spotless-changelog") +} + +val (kind, releaseTitle) = + when (project.name) { + "plugin-gradle" -> "gradle" to "Gradle Plugin" + "plugin-maven" -> "maven" to "Maven Plugin" + else -> { + check(project == rootProject) + "lib" to "Lib" + } + } + +spotlessChangelog { + changelogFile("CHANGES.md") + setAppendDashSnapshotUnless_dashPrelease(true) + branch("release") + tagPrefix("$kind/") + commitMessage("Published $kind/{{version}}") + tagMessage("{{changes}}") + runAfterPush( + "gh release create $kind/{{version}} --title '$releaseTitle v{{version}}' --notes-from-tag" + ) +} + +if (project == rootProject) { + gradle.taskGraph.whenReady { + val changelogPushTasks = allTasks.filter { it.name == "changelogPush" }.map { it.path } + if (changelogPushTasks.size > 1) { + throw IllegalArgumentException( + "Run changelogPush one at a time:\n" + changelogPushTasks.joinToString("\n") + ) + } + if (changelogPushTasks.size == 1) { + val isPlugin = + changelogPushTasks[0] == ":plugin-gradle:changelogPush" || + changelogPushTasks[0] == ":plugin-maven:changelogPush" + if ( + isPlugin && + !rootProject.spotlessChangelog.parsedChangelog.noUnreleasedChanges() && + rootProject.findProperty("ignoreUnreleasedLib")?.toString() != "true" + ) { + throw IllegalArgumentException( + "You're going to publish ${changelogPushTasks[0]}, but there are unreleased features in lib!\n" + + "You should run :changelogPush first! Else you'll be missing out on:\n" + + "${rootProject.spotlessChangelog.parsedChangelog.unreleasedChanges()}\n" + + "If it's okay to miss those and link against the old ${rootProject.spotlessChangelog.versionLast} then " + + "add -PignoreUnreleasedLib=true" + ) + } + } + } +} diff --git a/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts b/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts new file mode 100644 index 0000000000..668f069e73 --- /dev/null +++ b/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts @@ -0,0 +1,37 @@ +import net.ltgt.gradle.errorprone.errorprone + +plugins { + id("net.ltgt.errorprone") +} + +tasks.withType().configureEach { + options.errorprone { + if (System.getenv("error-prone")?.toBoolean() == true) { + enable() + } else { + disable() + } + disableAllWarnings = true + disable( + "AnnotateFormatMethod", + "FunctionalInterfaceMethodChanged", + "ImmutableEnumChecker", + "InlineMeSuggester", + "JavaxInjectOnAbstractMethod", + "OverridesJavaxInjectableMethod", + "ReturnValueIgnored", + ) + error( + "ReturnValueIgnored", + "SelfAssignment", + "StringJoin", + "UnnecessarilyFullyQualified", + "UnnecessaryLambda", + ) + excludedPaths = ".*/GradleIntegrationHarness.java" + } +} + +dependencies { + errorprone(libs.errorprone.core) +} diff --git a/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts b/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts new file mode 100644 index 0000000000..95c078073c --- /dev/null +++ b/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts @@ -0,0 +1,178 @@ +import com.diffplug.spotless.changelog.gradle.ChangelogExtension +import java.util.Base64 + +plugins { + `java-library` + `maven-publish` + signing +} + +fun decode64(varName: String): String { + val envValue = System.getenv(varName) ?: return "" + return String(Base64.getDecoder().decode(envValue), Charsets.UTF_8) +} + +java { + withJavadocJar() + withSourcesJar() +} + +tasks.named("sourcesJar") { + dependsOn(tasks.jar) +} + +tasks.withType().configureEach { + options { + (this as? StandardJavadocDocletOptions)?.apply { + encoding = Charsets.UTF_8.name() + addStringOption("Xdoclint:none", "-quiet") + addStringOption("Xwerror", "-quiet") + addStringOption("source", "17") + val artifactId = project.findProperty("artifactId")?.toString() ?: project.name + val org = project.findProperty("org")?.toString() ?: "diffplug" + val name = project.findProperty("name")?.toString() ?: "spotless" + val version = project.version.toString() + val group = project.group.toString() + val javadocInfo = + "

$group:$artifactId:$version by DiffPlug

" + header = javadocInfo + + val dotdotGradle = if (project.name.startsWith("eclipse-")) "../../gradle" else "../gradle" + linksOffline("https://docs.gradle.org/6.1.1/javadoc/", "$dotdotGradle/javadoc/gradle") + val versionLast = rootProject.the().versionLast + linksOffline( + "https://javadoc.io/static/com.diffplug.spotless/spotless-lib/$versionLast", + "$dotdotGradle/javadoc/spotless-lib", + ) + linksOffline( + "https://javadoc.io/static/com.diffplug.spotless/spotless-lib-extra/$versionLast", + "$dotdotGradle/javadoc/spotless-lib-extra", + ) + } + } +} + +tasks.check { + dependsOn(tasks.javadoc) +} + +afterEvaluate { + val isExt = project.name.startsWith("eclipse-") + val artifactId = project.findProperty("artifactId")?.toString() ?: project.name + val isPluginMaven = artifactId == "spotless-maven-plugin" + val isPluginGradle = pluginManager.hasPlugin("java-gradle-plugin") + + publishing { + publications { + val pluginMaven = + findByName("pluginMaven") as? MavenPublication + ?: create("pluginMaven") { + if (!isPluginGradle) { + from(components["java"]) + } + } + + pluginMaven.apply { + groupId = project.group.toString() + this.artifactId = artifactId + version = project.version.toString() + + pom { + name = artifactId + description = project.description + url = "https://github.com/${project.findProperty("org")}/${rootProject.name}" + scm { + url = "https://github.com/${project.findProperty("org")}/${rootProject.name}" + connection = + "scm:git:https://github.com/${project.findProperty("org")}/${rootProject.name}.git" + developerConnection = + "scm:git:ssh:git@github.com/${project.findProperty("org")}/${rootProject.name}.git" + } + licenses { + license { + if (isExt) { + name = "Eclipse Public License - v 1.0" + url = "https://www.eclipse.org/legal/epl-v10.html" + } else { + name = "The Apache Software License, Version 2.0" + url = "https://www.apache.org/licenses/LICENSE-2.0.txt" + } + distribution = "repo" + } + } + developers { + if (isExt) { + @Suppress("UNCHECKED_CAST") + val devs = project.findProperty("developers") as? Map> + devs?.forEach { (extId, extValues) -> + developer { + id = extId + name = extValues["name"] + email = extValues["email"] + } + } + } else { + if (isPluginMaven) { + developer { + id = "lutovich" + name = "Konstantin Lutovich" + email = "konstantin.lutovich@neotechnology.com" + } + } + developer { + id = "nedtwigg" + name = "Ned Twigg" + email = "ned.twigg@diffplug.com" + } + } + } + if (isPluginMaven) { + withXml { + val rootNode = asNode() + val prerequisites = rootNode.appendNode("prerequisites") + prerequisites.appendNode("maven", "3.1.0") + } + } + } + } + } + if (System.getenv("JITPACK") == "true" || project.version.toString().endsWith("-SNAPSHOT")) { + signing { + isRequired = false + } + } else { + signing { + val gpgKey = decode64("ORG_GRADLE_PROJECT_gpg_key64") + useInMemoryPgpKeys( + "0x4272C851", + gpgKey, + System.getenv("ORG_GRADLE_PROJECT_gpg_passphrase"), + ) + sign(publishing.publications) + } + + val changelogProject = if (tasks.names.contains("changelogBump")) project else rootProject + val changelogTasks = changelogProject.tasks + + tasks.jar { + dependsOn(changelogTasks.named("changelogCheck")) + } + + val thisProj = project + changelogTasks.named("changelogBump") { + dependsOn( + ":${thisProj.path.removePrefix(":")}:publishPluginMavenPublicationToSonatypeRepository" + ) + dependsOn(":closeAndReleaseSonatypeStagingRepository") + if (thisProj.tasks.names.contains("publishPlugins")) { + dependsOn(thisProj.tasks.named("publishPlugins")) + } + } + } + } +} + +tasks.withType().configureEach { + isPreserveFileTimestamps = false + isReproducibleFileOrder = true +} diff --git a/build-logic/src/main/kotlin/spotless.java-setup.gradle.kts b/build-logic/src/main/kotlin/spotless.java-setup.gradle.kts new file mode 100644 index 0000000000..cf24b25958 --- /dev/null +++ b/build-logic/src/main/kotlin/spotless.java-setup.gradle.kts @@ -0,0 +1,38 @@ +import com.github.spotbugs.snom.Confidence +import com.github.spotbugs.snom.SpotBugsTask + +plugins { + id("java") + id("com.github.spotbugs") + id("spotless.error-prone") + id("spotless.spotless-conventions") +} + +tasks.withType().configureEach { + options.encoding = Charsets.UTF_8.name() + options.release = libs.versions.jdk.release.map { it.toInt() } +} + +spotbugs { + ignoreFailures = false + reportLevel = Confidence.MEDIUM + omitVisitors = listOf("ConstructorThrow", "FindReturnRef") +} + +tasks.spotbugsTest { + enabled = false +} + +tasks.withType().configureEach { + outputs.file(project.layout.buildDirectory.file("reports/spotbugs/${name}.html")) + outputs.file(project.layout.buildDirectory.file("spotbugs/auxclasspath/${name}")) + reports.create("html") { + required = true + } +} + +dependencies { + compileOnly(libs.jcip.annotations) + compileOnly(spotbugs.toolVersion.map { "com.github.spotbugs:spotbugs-annotations:$it" }) + compileOnly(libs.jsr305) +} diff --git a/build-logic/src/main/kotlin/spotless.nexus-publish.gradle.kts b/build-logic/src/main/kotlin/spotless.nexus-publish.gradle.kts new file mode 100644 index 0000000000..9b49d00e25 --- /dev/null +++ b/build-logic/src/main/kotlin/spotless.nexus-publish.gradle.kts @@ -0,0 +1,31 @@ +import java.util.Base64 + +plugins { + id("io.github.gradle-nexus.publish-plugin") +} + +fun decode64(varName: String): String { + val envValue = System.getenv(varName) ?: return "" + return String(Base64.getDecoder().decode(envValue), Charsets.UTF_8) +} + +group = "com.diffplug.spotless" + +nexusPublishing { + repositories { + sonatype { + nexusUrl = uri("https://ossrh-staging-api.central.sonatype.com/service/local/") + snapshotRepositoryUrl = uri("https://central.sonatype.com/repository/maven-snapshots/") + username = System.getenv("ORG_GRADLE_PROJECT_nexus_user") + password = decode64("ORG_GRADLE_PROJECT_nexus_pass64") + } + } +} + +val initTask = tasks.named("initializeSonatypeStagingRepository") + +allprojects { + initTask.configure { + shouldRunAfter(tasks.withType()) + } +} diff --git a/build-logic/src/main/kotlin/spotless.rewrite.gradle.kts b/build-logic/src/main/kotlin/spotless.rewrite.gradle.kts new file mode 100644 index 0000000000..a09abad3ec --- /dev/null +++ b/build-logic/src/main/kotlin/spotless.rewrite.gradle.kts @@ -0,0 +1,25 @@ +plugins { + id("org.openrewrite.rewrite") +} + +rewrite { + activeRecipe("com.diffplug.spotless.openrewrite.SanityCheck") + exclusion( + listOf( + "**.dirty.java", + "**FormatterProperties.java", + "**_gradle_node_plugin_example_**", + "**idea/full.clean.java", + "**package-info.java", + "**testlib/src/main/resources**", + ) + ) + isExportDatatables = true + failOnDryRunResults = true +} + +dependencies { + "rewrite"(libs.rewrite.recipe.migrate.java) + "rewrite"(libs.rewrite.recipe.static.analysis) + "rewrite"(libs.rewrite.recipe.third.party) +} diff --git a/build-logic/src/main/kotlin/spotless.special-tests.gradle.kts b/build-logic/src/main/kotlin/spotless.special-tests.gradle.kts new file mode 100644 index 0000000000..9297d5ed70 --- /dev/null +++ b/build-logic/src/main/kotlin/spotless.special-tests.gradle.kts @@ -0,0 +1,36 @@ +import com.gradle.develocity.agent.gradle.test.DevelocityTestConfiguration + +plugins { + id("com.adarshr.test-logger") +} + +val special = listOf("black", "buf", "clang", "gofmt", "idea", "npm", "shfmt") + +val isCiServer = System.getenv().containsKey("CI") + +tasks.withType().configureEach { + if (isCiServer) { + configure { + testRetry { + maxRetries = 2 + maxFailures = 10 + } + } + } + // selfie https://selfie.dev/jvm/get-started#gradle + project.findProperty("selfie")?.let { environment("selfie", it) } + inputs.files(fileTree("src/test") { include("**/*.ss") }) + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) +} + +tasks.named("test") { useJUnitPlatform { excludeTags(*special.toTypedArray()) } } + +special.forEach { tag -> + tasks.register("test${tag.replaceFirstChar { it.uppercase() }}") { + useJUnitPlatform { includeTags(tag) } + val testEnv = rootProject.file("testenv.properties") + if (testEnv.exists()) { + systemProperty("testenv.properties.path", testEnv.canonicalPath) + } + } +} diff --git a/build-logic/src/main/kotlin/spotless.spotless-conventions.gradle.kts b/build-logic/src/main/kotlin/spotless.spotless-conventions.gradle.kts new file mode 100644 index 0000000000..86f5fbe9ce --- /dev/null +++ b/build-logic/src/main/kotlin/spotless.spotless-conventions.gradle.kts @@ -0,0 +1,48 @@ +plugins { + id("com.diffplug.spotless") +} + +spotless { + if (project != rootProject) { + java { + ratchetFrom("origin/main") + bumpThisNumberIfACustomStepChanges(1) + licenseHeaderFile(rootProject.file("gradle/spotless.license")) + importOrderFile(rootProject.file("gradle/spotless.importorder")) + eclipse().configFile(rootProject.file("gradle/spotless.eclipseformat.xml")) + trimTrailingWhitespace() + removeUnusedImports() + formatAnnotations() + forbidWildcardImports() + forbidRegex( + "ForbidGradleInternal", + """import org\.gradle\.api\.internal\.(.*)""", + "Don't use Gradle's internal API", + ) + } + } + kotlin { + target("build-logic/src/**/*.kt") + ktfmt(libs.ktfmt.get().version) + } + kotlinGradle { + target("*.gradle.kts", "build-logic/*.gradle.kts", "build-logic/src/**/*.gradle.kts") + ktfmt(libs.ktfmt.get().version) + } + groovyGradle { + target("*.gradle", "gradle/*.gradle") + greclipse() + .configFile( + rootProject.files( + "gradle/spotless.eclipseformat.xml", + "gradle/spotless.groovyformat.prefs", + ) + ) + } + format("dotfiles") { + target(".gitignore", ".gitattributes", ".editorconfig") + leadingTabsToSpaces(2) + trimTrailingWhitespace() + endWithNewline() + } +} diff --git a/build-logic/src/main/kotlin/spotless.spotless-freshmark.gradle.kts b/build-logic/src/main/kotlin/spotless.spotless-freshmark.gradle.kts new file mode 100644 index 0000000000..2e505c5292 --- /dev/null +++ b/build-logic/src/main/kotlin/spotless.spotless-freshmark.gradle.kts @@ -0,0 +1,58 @@ +import com.diffplug.gradle.spotless.FreshMarkExtension +import com.diffplug.spotless.changelog.gradle.ChangelogExtension + +plugins { + id("com.diffplug.spotless") +} + +val freshmarkSetup: (FreshMarkExtension) -> Unit = { freshmark -> + freshmark.target("*.md") + freshmark.propertiesFile(rootProject.file("gradle.properties")) + freshmark.properties { + put("yes", ":+1:") + put("no", ":white_large_square:") + } + freshmark.leadingTabsToSpaces(2) + freshmark.endWithNewline() +} + +spotless { + freshmark { + freshmarkSetup(this) + // disable ratchetFrom for freshmark, because we always want to update the readme links + ratchetFrom(null as String?) + } +} + +pluginManager.withPlugin("com.diffplug.spotless-changelog") { + val changelog = the() + val versionLast = changelog.versionLast + val versionNext = changelog.versionNext + + spotless { + freshmark { + properties { + put("versionLast", versionLast) + } + } + } + + val freshmark = FreshMarkExtension(the()) + freshmarkSetup(freshmark) + freshmark.properties { + put("versionLast", versionNext) + } + + val changelogBumpFreshmark = freshmark.createIndependentApplyTask("changelogBumpFreshmark") + changelogBumpFreshmark.dependsOn(tasks.named("changelogBump")) + + val changelogBumpFreshmarkGitAdd = + tasks.register("changelogBumpFreshmarkGitAdd") { + dependsOn(changelogBumpFreshmark) + commandLine("git", "add", "*.md") + } + + tasks.named("changelogPush") { + dependsOn(changelogBumpFreshmarkGitAdd) + } +} diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 4d788a0a57..0000000000 --- a/build.gradle +++ /dev/null @@ -1,27 +0,0 @@ -plugins { - alias(libs.plugins.equo.ide) - alias(libs.plugins.test.logger) apply false - alias(libs.plugins.spotless.changelog) apply false - alias(libs.plugins.plugin.publish) apply false - alias(libs.plugins.version.compatibility) apply false - alias(libs.plugins.nexus.publish) apply false - alias(libs.plugins.errorprone) apply false - alias(libs.plugins.rewrite) apply false - alias(libs.plugins.maven.plugin.development) apply false - alias(libs.plugins.p2deps) apply false -} - -equoIde { - branding().title('Spotless').icon(file('_images/spotless_logo.png')) - welcome().openUrl('https://github.com/diffplug/spotless/blob/main/CONTRIBUTING.md') - gradleBuildship().autoImport('.') -} - -apply from: rootProject.file('gradle/java-publish.gradle') -apply from: rootProject.file('gradle/changelog.gradle') -apply from: rootProject.file('gradle/rewrite.gradle') -allprojects { - apply from: rootProject.file('gradle/error-prone.gradle') - apply from: rootProject.file('gradle/spotless.gradle') -} -apply from: rootProject.file('gradle/spotless-freshmark.gradle') diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000000..58c59d06ec --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,18 @@ +plugins { + alias(libs.plugins.equo.ide) + alias(libs.plugins.plugin.publish) apply false + alias(libs.plugins.version.compatibility) apply false + alias(libs.plugins.maven.plugin.development) apply false + alias(libs.plugins.p2deps) apply false + id("spotless.nexus-publish") + id("spotless.changelog") + id("spotless.rewrite") + id("spotless.spotless-freshmark") + id("spotless.spotless-conventions") +} + +equoIde { + branding().title("Spotless").icon(file("_images/spotless_logo.png")) + welcome().openUrl("https://github.com/diffplug/spotless/blob/main/CONTRIBUTING.md") + gradleBuildship().autoImport(".") +} diff --git a/gradle/changelog.gradle b/gradle/changelog.gradle deleted file mode 100644 index 0fc643a634..0000000000 --- a/gradle/changelog.gradle +++ /dev/null @@ -1,56 +0,0 @@ -String kind -String releaseTitle -if (project.name == 'plugin-gradle') { - kind = 'gradle' - releaseTitle = 'Gradle Plugin' -} else if (project.name == 'plugin-maven') { - kind = 'maven' - releaseTitle = 'Maven Plugin' -} else { - assert project == rootProject - kind = 'lib' - releaseTitle = 'Lib' -} - -// the root project and plugins have their own changelogs -apply plugin: 'com.diffplug.spotless-changelog' -spotlessChangelog { - changelogFile 'CHANGES.md' - // need -Prelease=true in order to do a publish - appendDashSnapshotUnless_dashPrelease =true - - branch 'release' - tagPrefix "${kind}/" - commitMessage "Published ${kind}/{{version}}" // {{version}} will be replaced - tagMessage "{{changes}}" - runAfterPush "gh release create ${kind}/{{version}} --title '${releaseTitle} v{{version}}' --notes-from-tag" -} - -if (project == rootProject) { - gradle.taskGraph.whenReady { taskGraph -> - def changelogPushTasks = taskGraph.allTasks.stream() - .filter { t -> t.name == 'changelogPush' } - .map { t -> t.path } - .toList() - if (changelogPushTasks.size() > 1) { - // make sure only one changelog gets published per tag/commit - throw new IllegalArgumentException("Run changelogPush one at a time:\n" + changelogPushTasks.join('\n')) - } else if (changelogPushTasks.size() == 1) { - boolean isPlugin = (changelogPushTasks[0] == ':plugin-gradle:changelogPush') || (changelogPushTasks[1] == ':plugin-maven:changelogPush') - // if the one thing being published is a plugin - if (isPlugin) { - // make sure there aren't any unreleased changes in lib - if (!rootProject.spotlessChangelog.parsedChangelog.noUnreleasedChanges()) { - if (!("true".equals(rootProject.findProperty('ignoreUnreleasedLib')))) { - throw new IllegalArgumentException( - "You're going to publish ${changelogPushTasks[0]}, but there are unreleased features in lib!\n" + - "You should run :changelogPush first! Else you'll be missing out on:\n" + - "${rootProject.spotlessChangelog.parsedChangelog.unreleasedChanges()}\n" + - "If it's okay to miss those and link against the old ${rootProject.spotlessChangelog.versionLast} then " + - "add -PignoreUnreleasedLib=true") - } - } - } - } - } -} diff --git a/gradle/error-prone.gradle b/gradle/error-prone.gradle deleted file mode 100644 index 11cfd2015b..0000000000 --- a/gradle/error-prone.gradle +++ /dev/null @@ -1,34 +0,0 @@ -import static java.lang.System.getenv - -apply plugin: 'net.ltgt.errorprone' - -tasks.withType(JavaCompile).configureEach { - options.errorprone { - getenv('error-prone')?.toBoolean() ? enable() : disable() - disableAllWarnings = true // https://github.com/diffplug/spotless/issues/2745 https://github.com/google/error-prone/issues/5365 - disable( - 'AnnotateFormatMethod', // We don`t want to use ErrorProne's annotations. - 'FunctionalInterfaceMethodChanged', - 'ImmutableEnumChecker', // We don`t want to use ErrorProne's annotations. - 'InlineMeSuggester', // We don`t want to use ErrorProne's annotations. - 'JavaxInjectOnAbstractMethod', - 'OverridesJavaxInjectableMethod', - 'ReturnValueIgnored', // We don`t want to use ErrorProne's annotations. - ) - error( - 'ReturnValueIgnored', - 'SelfAssignment', - 'StringJoin', - 'UnnecessarilyFullyQualified', - 'UnnecessaryLambda', - ) - // bug: this only happens when the file is dirty. - // might be an up2date (caching) issue, as file is currently in corrupt state. - // ForbidGradleInternal(import - excludedPaths.set('.*/GradleIntegrationHarness.java') - } -} - -dependencies { - errorprone libs.errorprone.core -} diff --git a/gradle/java-publish.gradle b/gradle/java-publish.gradle deleted file mode 100644 index e6c36dc566..0000000000 --- a/gradle/java-publish.gradle +++ /dev/null @@ -1,210 +0,0 @@ -import java.nio.charset.StandardCharsets - -def decode64(String varName) { - String envValue = System.env[varName] - if (envValue == null) { - return "" - } else { - return new String(envValue.decodeBase64(), "UTF-8") - } -} - -if (project.parent == null) { - group = 'com.diffplug.spotless' - def pass = System.env['ORG_GRADLE_PROJECT_nexus_pass64'] - if (pass != null) { - pass = pass.decodeBase64() - } - // it's the root project - apply plugin: 'io.github.gradle-nexus.publish-plugin' - nexusPublishing { - repositories { - sonatype { - nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/")) - snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/")) - username = System.env['ORG_GRADLE_PROJECT_nexus_user'] - password = decode64('ORG_GRADLE_PROJECT_nexus_pass64') - } - } - } - def initTask = tasks.named('initializeSonatypeStagingRepository') - allprojects { - initTask.configure { - shouldRunAfter(tasks.withType(Sign)) - } - } - return -} - -/////////// -// MAVEN // -/////////// -java { - withJavadocJar() - withSourcesJar() -} - -tasks.named('sourcesJar') { - dependsOn 'jar' -} - -apply plugin: 'maven-publish' -apply plugin: 'signing' - -// Where it's possible to name parameters and methods clearly enough -// that javadoc is not necessary, why make the code bigger? -// -// Thus, no javadoc warnings. -javadoc { - options.addStringOption('Xdoclint:none', '-quiet') - options.addStringOption('Xwerror', '-quiet') -} -// make sure bad javadoc breaks the build -tasks.named('check') { - dependsOn tasks.named('javadoc') -} - -// use markdown in javadoc -def makeLink = { url, text -> - "${text}" -} -def javadocInfo = '

' + makeLink("https://github.com/${org}/${name}", "${group}:${project.ext.artifactId}:${version}") + - ' by ' + makeLink('https://www.diffplug.com', 'DiffPlug') + '

' - -String dotdotGradle = project.name.startsWith('eclipse-') ? '../../gradle' : '../gradle' -javadoc { - options.encoding = 'UTF-8' - // Where it's possible to name parameters and methods clearly enough - // that javadoc is not necessary, why make the code bigger? - // - // Thus, no javadoc warnings. - options.addStringOption('Xdoclint:none', '-quiet') - options.addStringOption('source', '17') - // setup the header - options.header javadocInfo - // setup links - options.linksOffline('https://docs.gradle.org/6.1.1/javadoc/', "${dotdotGradle}/javadoc/gradle") - - // links to javadoc from the other versions - options.linksOffline("https://javadoc.io/static/com.diffplug.spotless/spotless-lib/${rootProject.spotlessChangelog.versionLast}", "${dotdotGradle}/javadoc/spotless-lib") - options.linksOffline("https://javadoc.io/static/com.diffplug.spotless/spotless-lib-extra/${rootProject.spotlessChangelog.versionLast}", "${dotdotGradle}/javadoc/spotless-lib-extra") -} - -//////////////// -// PUBLISHING // -//////////////// -final MAVEN_PLUGIN_ARTIFACT_NAME = 'spotless-maven-plugin' -boolean isExt = project.name.startsWith('eclipse-') -boolean isPluginMaven = project.ext.artifactId == 'spotless-maven-plugin' - -publishing { - publications { - pluginMaven(MavenPublication) { - if (project.ext.artifactId != 'spotless-plugin-gradle') { - from components.java - } - - groupId = project.group - artifactId = project.ext.artifactId - version = project.version - - def projectExtArtifactId = project.ext.artifactId - def projectDescription = project.description - def projectOrg = project.org - def rootProjectName = rootProject.name - - pom.withXml { - // add MavenCentral requirements to the POM - asNode().children().last() + { - resolveStrategy = Closure.DELEGATE_FIRST - name projectExtArtifactId - description projectDescription - url "https://github.com/${projectOrg}/${rootProjectName}" - scm { - url "https://github.com/${projectOrg}/${rootProjectName}" - connection "scm:git:https://github.com/${projectOrg}/${rootProjectName}.git" - developerConnection "scm:git:ssh:git@github.com/${projectOrg}/${rootProjectName}.git" - } - licenses { - if (isExt) { - license { - name 'Eclipse Public License - v 1.0' - url 'https://www.eclipse.org/legal/epl-v10.html' - distribution 'repo' - } - } else { - license { - name 'The Apache Software License, Version 2.0' - url 'https://www.apache.org/licenses/LICENSE-2.0.txt' - distribution 'repo' - } - } - } - if (isPluginMaven) { - // Maven plugin required Maven 3.1.0+ to run - prerequisites { maven '3.1.0' } - } - developers { - if (isExt) { - project.ext.developers.each { extId, extValues -> - developer { - id extId - name extValues['name'] - email extValues['email'] - } - } - } else { - if (isPluginMaven) { - developer { - id 'lutovich' - name 'Konstantin Lutovich' - email 'konstantin.lutovich@neotechnology.com' - } - } - developer { - id 'nedtwigg' - name 'Ned Twigg' - email 'ned.twigg@diffplug.com' - } - } - } - } - } - } - } -} - -if (System.env['JITPACK'] == 'true' || version.endsWith('-SNAPSHOT')) { - signing { - setRequired(false) - } -} else { - signing { - String gpg_key = decode64('ORG_GRADLE_PROJECT_gpg_key64') - useInMemoryPgpKeys('0x4272C851', gpg_key, System.env['ORG_GRADLE_PROJECT_gpg_passphrase']) - sign(publishing.publications) - } - - // find the project with the changelog (this project for plugins, root project for libs) - def changelogTasks = (tasks.names.contains('changelogBump') ? project : rootProject).tasks - - // ensures that nothing will be built if changelogPush will end up failing - tasks.named('jar').configure { - dependsOn changelogTasks.named('changelogCheck') - } - // ensures that changelog bump and push only happens if the publish was successful - def thisProj = project - changelogTasks.named('changelogBump').configure { - dependsOn ":${thisProj.path}:publishPluginMavenPublicationToSonatypeRepository" - dependsOn ":closeAndReleaseSonatypeStagingRepository" - // if we have a Gradle plugin, we need to push it up to the plugin portal too - if (thisProj.tasks.names.contains('publishPlugins')) { - dependsOn thisProj.tasks.named('publishPlugins') - } - } -} - -tasks.withType(AbstractArchiveTask).configureEach { - preserveFileTimestamps = false - reproducibleFileOrder = true -} diff --git a/gradle/java-setup.gradle b/gradle/java-setup.gradle deleted file mode 100644 index 4f624d3fb5..0000000000 --- a/gradle/java-setup.gradle +++ /dev/null @@ -1,43 +0,0 @@ -////////// -// JAVA // -////////// - -// setup java -apply plugin: 'java' -tasks.withType(JavaCompile).configureEach { - options.encoding = 'UTF-8' - options.release = libs.versions.jdk.release.get().toInteger() -} - -////////////// -// SPOTBUGS // -////////////// -apply plugin: 'com.github.spotbugs' -spotbugs { - ignoreFailures = false // bug free or it doesn't ship! - // LOW|MEDIUM|DEFAULT|HIGH (low = sensitive to even minor mistakes). - reportLevel = com.github.spotbugs.snom.Confidence.valueOf('MEDIUM') - omitVisitors = [ - // https://spotbugs.readthedocs.io/en/latest/detectors.html#constructorthrow - 'ConstructorThrow', - // https://spotbugs.readthedocs.io/en/latest/detectors.html#findreturnref - 'FindReturnRef', - ] -} -tasks.named('spotbugsTest') { - enabled = false -} - -tasks.withType(com.github.spotbugs.snom.SpotBugsTask).configureEach { - outputs.file(project.layout.buildDirectory.file("reports/spotbugs/${it.name}.html")) - outputs.file(project.layout.buildDirectory.file("spotbugs/auxclasspath/${it.name}")) - reports { - html.enabled = true - } -} - -dependencies { - compileOnly libs.jcip.annotations - compileOnly "com.github.spotbugs:spotbugs-annotations:${spotbugs.toolVersion.get()}" - compileOnly libs.jsr305 -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 03a754fa9a..b2860cda20 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -78,3 +78,4 @@ nexus-publish = "io.github.gradle-nexus.publish-plugin:2.0.0" errorprone = "net.ltgt.errorprone:5.1.1" rewrite = "org.openrewrite.rewrite:7.39.0" maven-plugin-development = "org.gradlex.maven-plugin-development:1.0.3" +develocity = "com.gradle.develocity:4.5.0" diff --git a/gradle/rewrite.gradle b/gradle/rewrite.gradle deleted file mode 100644 index 7f548130e5..0000000000 --- a/gradle/rewrite.gradle +++ /dev/null @@ -1,27 +0,0 @@ -apply plugin: 'org.openrewrite.rewrite' -rewrite { - activeRecipe('com.diffplug.spotless.openrewrite.SanityCheck') - exclusions.addAll( - '**.dirty.java', - '**FormatterProperties.java', - '**_gradle_node_plugin_example_**', - '**gradle/changelog.gradle', - '**gradle/java-publish.gradle', - '**idea/full.clean.java', - '**java-setup.gradle', - '**lib-extra/build.gradle', - '**lib/build.gradle', - '**package-info.java', - '**plugin-maven/build.gradle', - '**settings.gradle', - '**special-tests.gradle', - '**testlib/src/main/resources**' - ) - exportDatatables = true - failOnDryRunResults = true -} -dependencies { - rewrite libs.rewrite.recipe.migrate.java - rewrite libs.rewrite.recipe.static.analysis - rewrite libs.rewrite.recipe.third.party -} diff --git a/gradle/special-tests.gradle b/gradle/special-tests.gradle deleted file mode 100644 index 658f86dd4e..0000000000 --- a/gradle/special-tests.gradle +++ /dev/null @@ -1,47 +0,0 @@ -apply plugin: 'com.adarshr.test-logger' - -// See com.diffplug.spotless.tag package for available JUnit 5 @Tag annotations -def special = [ - 'black', - 'buf', - 'clang', - 'gofmt', - 'idea', - 'npm', - 'shfmt' -] - -boolean isCiServer = System.getenv().containsKey("CI") -tasks.withType(Test).configureEach { - if (isCiServer) { - develocity { - testRetry { - maxRetries = 2 - maxFailures = 10 - } - } - } - // selfie https://selfie.dev/jvm/get-started#gradle - environment project.properties.subMap([ - "selfie" - ]) // optional, see "Overwrite everything" below - inputs.files(fileTree("src/test") { - // optional, improves up-to-date checking - include "**/*.ss" - }) - // https://docs.gradle.org/8.8/userguide/performance.html#execute_tests_in_parallel - maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 -} -tasks.named('test').configure { - useJUnitPlatform { - excludeTags special as String[] - } -} -special.forEach { tag -> - tasks.register("test${tag.capitalize()}", Test) { - useJUnitPlatform { includeTags tag } - if (rootProject.file('testenv.properties').exists()) { - systemProperty 'testenv.properties.path', rootProject.file('testenv.properties').canonicalPath - } - } -} diff --git a/gradle/spotless-freshmark.gradle b/gradle/spotless-freshmark.gradle deleted file mode 100644 index 9608cb2cbb..0000000000 --- a/gradle/spotless-freshmark.gradle +++ /dev/null @@ -1,59 +0,0 @@ - -apply plugin: 'com.diffplug.spotless' - -import com.diffplug.gradle.spotless.FreshMarkExtension - -Action freshmarkSetup = { - it.target '*.md' - it.propertiesFile(rootProject.file('gradle.properties')) - it.properties { - it.put('yes', ':+1:') - it.put('no', ':white_large_square:') - } - it.leadingTabsToSpaces(2) - it.endWithNewline() -} - -spotless { - freshmark { - freshmarkSetup.execute(it) - // disable ratchetFrom for freshmark, because we always want to update the readme links - ratchetFrom null - } -} - -def versionLast = spotlessChangelog.versionLast -def versionNext = spotlessChangelog.versionNext - -// if this freshmark has a changelog file, then it has version-sensitive content -if (tasks.names.contains('changelogCheck')) { - // normally we use versionLast for our freshmark - spotless { - freshmark { - properties { - it.put('versionLast', versionLast) - } - } - } - - // create a freshmark apply task manually - FreshMarkExtension freshmark = new FreshMarkExtension(spotless) - freshmarkSetup.execute(freshmark) - freshmark.properties { - // that uses versionNext as versionLast - it.put('versionLast', versionNext) - } - def changelogBumpFreshmark = freshmark.createIndependentApplyTask('changelogBumpFreshmark') - // freshmark should run after the changelog bump - changelogBumpFreshmark.dependsOn tasks.named('changelogBump') - - def changelogBumpFreshmarkGitAdd = tasks.register('changelogBumpFreshmarkGitAdd', Exec) { - // this git add should run after the freshmark - dependsOn(changelogBumpFreshmark) - // do the git add - commandLine 'git', 'add', '*.md' - } - tasks.named('changelogPush').configure { - dependsOn changelogBumpFreshmarkGitAdd - } -} diff --git a/gradle/spotless.gradle b/gradle/spotless.gradle deleted file mode 100644 index 5862a633ea..0000000000 --- a/gradle/spotless.gradle +++ /dev/null @@ -1,28 +0,0 @@ -apply plugin: 'com.diffplug.spotless' -spotless { - if (project != rootProject) { - // the rootProject doesn't have any java - java { - ratchetFrom 'origin/main' - bumpThisNumberIfACustomStepChanges(1) - licenseHeaderFile rootProject.file('gradle/spotless.license') - importOrderFile rootProject.file('gradle/spotless.importorder') - eclipse().configFile rootProject.file('gradle/spotless.eclipseformat.xml') - trimTrailingWhitespace() - removeUnusedImports() - formatAnnotations() - forbidWildcardImports() - forbidRegex('ForbidGradleInternal', 'import org\\.gradle\\.api\\.internal\\.(.*)', "Don't use Gradle's internal API") - } - } - groovyGradle { - target '*.gradle', 'gradle/*.gradle' - greclipse().configFile rootProject.files('gradle/spotless.eclipseformat.xml', 'gradle/spotless.groovyformat.prefs') - } - format 'dotfiles', { - target '.gitignore', '.gitattributes', '.editorconfig' - leadingTabsToSpaces(2) - trimTrailingWhitespace() - endWithNewline() - } -} diff --git a/lib-extra/build.gradle b/lib-extra/build.gradle deleted file mode 100644 index 9545924358..0000000000 --- a/lib-extra/build.gradle +++ /dev/null @@ -1,125 +0,0 @@ -plugins { - id 'java-library' - id 'dev.equo.p2deps' -} -ext.artifactId = project.artifactIdLibExtra -version = rootProject.spotlessChangelog.versionNext -apply from: rootProject.file('gradle/java-setup.gradle') -apply from: rootProject.file('gradle/java-publish.gradle') - -dependencies { - api projects.lib - // misc useful utilities - implementation libs.durian.core - implementation libs.durian.collect - // needed by GitAttributesLineEndings - implementation libs.jgit - implementation libs.concurrent.trees - // for eclipse - implementation libs.solstice - // the osgi dep is included in solstice, but it has some CVE's against it. - // 3.18.500 is the oldest, most-compatible version with no CVE's - // https://central.sonatype.com/artifact/org.eclipse.platform/org.eclipse.osgi/versions - implementation libs.osgi - - // testing - testImplementation projects.testlib - testImplementation libs.durian.io - testImplementation libs.jsr305 - testImplementation libs.junit.jupiter - testImplementation libs.assertj.core - testImplementation libs.durian.testlib - testRuntimeOnly "org.junit.platform:junit-platform-launcher" -} - -spotless { - java { - replaceRegex 'enforceSolsticeVersion', '"dev.equo.ide:solstice:(.*)"', "\"${libs.solstice.get().toString()}\"" - } -} - -apply from: rootProject.file('gradle/special-tests.gradle') -tasks.withType(Test).configureEach { - // needed for EclipseCdtFormatterStepTest - jvmArgs '--add-opens=java.base/java.lang=ALL-UNNAMED' -} - -def NEEDS_P2_DEPS = [ - // (alphabetic order please) - 'cdt', - 'groovy', - 'jdt' -] -for (needsP2 in NEEDS_P2_DEPS) { - sourceSets.register(needsP2) { - compileClasspath += sourceSets.main.output - runtimeClasspath += sourceSets.main.output - java {} - } - dependencies { - add("${needsP2}CompileOnly", libs.solstice) - } -} - -def jar = tasks.named('jar', Jar) { - for (needsP2 in NEEDS_P2_DEPS) { - from sourceSets.named(needsP2).map { it.output.classesDirs } - } -} - -tasks.withType(Test).configureEach { - dependsOn jar - classpath += jar.get().outputs.files - // P2 tests use a process-level file lock; parallel forks race for it. - // In-JVM synchronization in TestP2Provisioner is enough, so one fork is sufficient. - maxParallelForks = 1 -} - -apply plugin: 'dev.equo.p2deps' -p2deps { - into 'cdtCompileOnly', { - p2repo 'https://download.eclipse.org/eclipse/updates/4.26/' - p2repo 'https://download.eclipse.org/tools/cdt/releases/11.0/' - install 'org.eclipse.cdt.core' - } - into 'groovyCompileOnly', { - p2repo 'https://download.eclipse.org/eclipse/updates/4.26/' - p2repo 'https://groovy.jfrog.io/artifactory/plugins-release/org/codehaus/groovy/groovy-eclipse-integration/4.8.0/e4.26/' - install 'org.codehaus.groovy.eclipse.refactoring' - install 'org.codehaus.groovy.eclipse.core' - install 'org.eclipse.jdt.groovy.core' - install 'org.codehaus.groovy' - } - into 'jdtCompileOnly', { - p2repo 'https://download.eclipse.org/eclipse/updates/4.26/' - install 'org.eclipse.jdt.core' - } -} - -// Embedded Eclipse JDT lockfiles, see EclipseJdtLockfileMetadataTool. `verify` runs in CI so the -// lockfiles cannot silently drift from Eclipse's P2 metadata; `update` is run by hand whenever the -// default version moves. Both hit the Eclipse update sites, so neither is wired into `build`. -def eclipseJdtLockfileTool = { String entrypoint -> - return { - group = 'verification' - classpath = sourceSets.test.runtimeClasspath - mainClass = "com.diffplug.spotless.extra.java.EclipseJdtLockfileMetadataTool\$${entrypoint}" - workingDir = rootProject.projectDir - outputs.upToDateWhen { false } - } -} -tasks.register('verifyEclipseJdtLockfiles', JavaExec) { - configure eclipseJdtLockfileTool('Verify') - description = 'Checks the embedded Eclipse JDT lockfiles against Eclipse P2 metadata.' -} -tasks.register('updateEclipseJdtLockfiles', JavaExec) { - configure eclipseJdtLockfileTool('Update') - description = 'Regenerates the embedded Eclipse JDT lockfiles from Eclipse P2 metadata.' -} - -// we'll hold the core lib to a high standard -spotbugs { - // LOW|MEDIUM|DEFAULT|HIGH (low = sensitive to even minor mistakes). - reportLevel = com.github.spotbugs.snom.Confidence.valueOf('LOW') - excludeFilter = file("spotbugs-exclude.xml") -} diff --git a/lib-extra/build.gradle.kts b/lib-extra/build.gradle.kts new file mode 100644 index 0000000000..36728ddd7f --- /dev/null +++ b/lib-extra/build.gradle.kts @@ -0,0 +1,134 @@ +import com.diffplug.spotless.changelog.gradle.ChangelogExtension +import com.github.spotbugs.snom.Confidence + +plugins { + `java-library` + alias(libs.plugins.p2deps) + id("spotless.java-setup") + id("spotless.java-publish") + id("spotless.special-tests") +} + +extra["artifactId"] = property("artifactIdLibExtra") + +version = rootProject.the().versionNext + +dependencies { + api(projects.lib) + // misc useful utilities + implementation(libs.durian.core) + implementation(libs.durian.collect) + // needed by GitAttributesLineEndings + implementation(libs.jgit) + implementation(libs.concurrent.trees) + // for eclipse + implementation(libs.solstice) + // the osgi dep is included in solstice, but it has some CVE's against it. + // 3.18.500 is the oldest, most-compatible version with no CVE's + // https://central.sonatype.com/artifact/org.eclipse.platform/org.eclipse.osgi/versions + implementation(libs.osgi) + + // testing + testImplementation(projects.testlib) + testImplementation(libs.durian.io) + testImplementation(libs.jsr305) + testImplementation(libs.junit.jupiter) + testImplementation(libs.assertj.core) + testImplementation(libs.durian.testlib) + testRuntimeOnly("org.junit.platform:junit-platform-launcher") +} + +spotless { + java { + replaceRegex( + "enforceSolsticeVersion", + "\"dev.equo.ide:solstice:(.*)\"", + "\"${libs.solstice.get()}\"", + ) + } +} + +val needsP2Deps = + listOf( + // (alphabetic order please) + "cdt", + "groovy", + "jdt", + ) + +val mainSourceSet = sourceSets.named("main") + +for (needsP2 in needsP2Deps) { + sourceSets.register(needsP2) { + compileClasspath += mainSourceSet.get().output + runtimeClasspath += mainSourceSet.get().output + java {} + } + dependencies { add("${needsP2}CompileOnly", libs.solstice) } +} + +tasks.jar { + for (needsP2 in needsP2Deps) { + from(sourceSets.named(needsP2).map { it.output.classesDirs }) + } +} + +tasks.withType().configureEach { + // needed for EclipseCdtFormatterStepTest + jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") + dependsOn(tasks.jar) + classpath += tasks.jar.get().outputs.files + // P2 tests use a process-level file lock; parallel forks race for it. + // In-JVM synchronization in TestP2Provisioner is enough, so one fork is sufficient. + maxParallelForks = 1 +} + +p2deps { + into("cdtCompileOnly") { + p2repo("https://download.eclipse.org/eclipse/updates/4.26/") + p2repo("https://download.eclipse.org/tools/cdt/releases/11.0/") + install("org.eclipse.cdt.core") + } + into("groovyCompileOnly") { + p2repo("https://download.eclipse.org/eclipse/updates/4.26/") + p2repo( + "https://groovy.jfrog.io/artifactory/plugins-release/org/codehaus/groovy/groovy-eclipse-integration/4.8.0/e4.26/" + ) + install("org.codehaus.groovy.eclipse.refactoring") + install("org.codehaus.groovy.eclipse.core") + install("org.eclipse.jdt.groovy.core") + install("org.codehaus.groovy") + } + into("jdtCompileOnly") { + p2repo("https://download.eclipse.org/eclipse/updates/4.26/") + install("org.eclipse.jdt.core") + } +} + +// Embedded Eclipse JDT lockfiles, see EclipseJdtLockfileMetadataTool. `verify` runs in CI so the +// lockfiles cannot silently drift from Eclipse's P2 metadata; `update` is run by hand whenever the +// default version moves. Both hit the Eclipse update sites, so neither is wired into `build`. +fun eclipseJdtLockfileTool(entrypoint: String): Action = Action { + group = "verification" + classpath = sourceSets.named("test").get().runtimeClasspath + mainClass = "com.diffplug.spotless.extra.java.EclipseJdtLockfileMetadataTool\$$entrypoint" + workingDir = rootProject.projectDir + outputs.upToDateWhen { false } +} + +tasks.register("verifyEclipseJdtLockfiles") { + eclipseJdtLockfileTool("Verify").execute(this) + description = "Checks the embedded Eclipse JDT lockfiles against Eclipse P2 metadata." +} + +tasks.register("updateEclipseJdtLockfiles") { + eclipseJdtLockfileTool("Update").execute(this) + description = "Regenerates the embedded Eclipse JDT lockfiles from Eclipse P2 metadata." +} + +// we'll hold the core lib to a high standard +spotbugs { + // LOW|MEDIUM|DEFAULT|HIGH (low = sensitive to even minor mistakes). + reportLevel = Confidence.LOW + excludeFilter = file("spotbugs-exclude.xml") +} diff --git a/lib/build.gradle b/lib/build.gradle deleted file mode 100644 index bd372a3d3f..0000000000 --- a/lib/build.gradle +++ /dev/null @@ -1,153 +0,0 @@ -import org.gradle.util.GradleVersion - -plugins { - id 'java-library' - id 'io.github.davidburstrom.version-compatibility' -} -ext.artifactId = project.artifactIdLib -version = rootProject.spotlessChangelog.versionNext -apply from: rootProject.file('gradle/java-setup.gradle') -apply from: rootProject.file('gradle/java-publish.gradle') - -def NEEDS_GLUE = [ - // (alphabetic order please) - 'cleanthat', - 'diktat', - 'flexmark', - 'gherkin', - 'googleJavaFormat', - 'gson', - 'jackson', - 'javaParser', - 'ktfmt', - 'ktlint', - 'lombokStubs', - 'palantirJavaFormat', - 'princeOfSpace', - 'scalafmt', - 'sortPom', - 'tableTestFormatter', - 'zjsonPatch', -] - -for (glue in NEEDS_GLUE) { - sourceSets.register(glue) { - compileClasspath += sourceSets.main.output - runtimeClasspath += sourceSets.main.output - java {} - } -} - -versionCompatibility { - adapters { - // (alphabetic order please) - namespaces.register('Cleanthat') { - versions = [ - '2.1', - ] - targetSourceSetName = 'cleanthat' - } - namespaces.register('KtLint') { - // as discussed at https://github.com/diffplug/spotless/pull/1475 - // we will support no more than 2 breaking changes at a time = 3 incompatible versions - // we will try to drop down to only one version if a stable API can be maintained for a full year - versions = [ - '1.0.0', - ] - targetSourceSetName = 'ktlint' - } - namespaces.register('Diktat') { - versions = [ - '1.2.5', - '2.0.0', - ] - targetSourceSetName = 'diktat' - } - } -} - -tasks.named("check").configure { - dependsOn(tasks.named("testCompatibilityAdapters")) - dependsOn(tasks.named("testCompatibility")) -} - -dependencies { - compileOnly libs.slf4j.api - testCommonImplementation libs.slf4j.api - - // zero runtime reqs is a hard requirements for spotless-lib - // if you need a dep, put it in lib-extra - testCommonImplementation libs.junit.jupiter - testCommonImplementation libs.assertj.core - testCommonImplementation libs.durian.testlib - testCommonImplementation projects.testlib - testCommonRuntimeOnly "org.junit.platform:junit-platform-launcher" - - // GLUE CODE (alphabetic order please) - // cleanthat - cleanthatCompileOnly libs.cleanthat.java - compatCleanthat2Dot1CompileAndTestOnly libs.cleanthat.java - // diktat old supported version 1.x - compatDiktat1Dot2Dot5CompileOnly libs.diktat.rules - // diktat latest supported version 2.x - compatDiktat2Dot0Dot0CompileOnly libs.diktat.runner - // flexmark - flexmarkCompileOnly libs.flexmark.all - // gherkin - gherkinCompileOnly libs.gherkin.utils - gherkinCompileOnly libs.slf4j.api - // googleJavaFormat - googleJavaFormatCompileOnly libs.google.java.format - // gson - gsonCompileOnly libs.gson - // jackson - jacksonCompileOnly libs.jackson.databind - jacksonCompileOnly libs.jackson.dataformat.yaml - // javaParser - javaParserCompileOnly libs.javaparser.symbol.solver.core - // ktfmt - ktfmtCompileOnly libs.ktfmt - ktfmtCompileOnly("com.google.googlejavaformat:google-java-format") { - version { - strictly '1.7' // for JDK 8 compatibility - } - } - ktfmtCompileOnly libs.jsr305 - // ktlint latest supported version - compatKtLint1Dot0Dot0CompileAndTestOnly libs.ktlint.rule.engine - compatKtLint1Dot0Dot0CompileAndTestOnly libs.ktlint.ruleset.standard - compatKtLint1Dot0Dot0CompileAndTestOnly libs.slf4j.api - // palantirJavaFormat - palantirJavaFormatCompileOnly libs.palantir.java.format // this version needs to stay compilable against Java 8 for CI Job testNpm - // princeOfSpace - princeOfSpaceCompileOnly libs.prince.of.space.core - // scalafmt - scalafmtCompileOnly libs.scalafmt.core - // sortPom - sortPomCompileOnly libs.sortpom.sorter - sortPomCompileOnly libs.slf4j.api - // tableTestFormatter - tableTestFormatterCompileOnly libs.tabletest.formatter.core - // zjsonPatch - zjsonPatchCompileOnly libs.zjsonpatch -} - -// we'll hold the core lib to a high standard -spotbugs { - // LOW|MEDIUM|DEFAULT|HIGH (low = sensitive to even minor mistakes). - reportLevel = com.github.spotbugs.snom.Confidence.valueOf('LOW') - excludeFilter = file("spotbugs-exclude.xml") -} - -apply from: rootProject.file('gradle/special-tests.gradle') -tasks.withType(Test).configureEach { - jvmArgs "--add-opens=java.base/java.lang=ALL-UNNAMED" - - failOnNoDiscoveredTests = false -} - -jar { - for (glue in NEEDS_GLUE) { - from sourceSets.getByName(glue).output.classesDirs - } -} diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts new file mode 100644 index 0000000000..261231b084 --- /dev/null +++ b/lib/build.gradle.kts @@ -0,0 +1,154 @@ +import com.diffplug.spotless.changelog.gradle.ChangelogExtension +import com.github.spotbugs.snom.Confidence + +plugins { + `java-library` + alias(libs.plugins.version.compatibility) + id("spotless.java-setup") + id("spotless.java-publish") + id("spotless.special-tests") +} + +extra["artifactId"] = property("artifactIdLib") + +version = rootProject.the().versionNext + +val needsGlue = + listOf( + // (alphabetic order please) + "cleanthat", + "diktat", + "flexmark", + "gherkin", + "googleJavaFormat", + "gson", + "jackson", + "javaParser", + "ktfmt", + "ktlint", + "lombokStubs", + "palantirJavaFormat", + "princeOfSpace", + "scalafmt", + "sortPom", + "tableTestFormatter", + "zjsonPatch", + ) + +val mainSourceSet = sourceSets.named("main") + +for (glue in needsGlue) { + sourceSets.register(glue) { + compileClasspath += mainSourceSet.get().output + runtimeClasspath += mainSourceSet.get().output + java {} + } +} + +versionCompatibility { + adapters { + // (alphabetic order please) + namespaces.register("Cleanthat") { + versions = listOf("2.1") + targetSourceSetName = "cleanthat" + } + namespaces.register("KtLint") { + // as discussed at https://github.com/diffplug/spotless/pull/1475 + // we will support no more than 2 breaking changes at a time = 3 incompatible versions + // we will try to drop down to only one version if a stable API can be maintained for a full + // year + versions = listOf("1.0.0") + targetSourceSetName = "ktlint" + } + namespaces.register("Diktat") { + versions = listOf("1.2.5", "2.0.0") + targetSourceSetName = "diktat" + } + } +} + +tasks.check { + dependsOn(tasks.named("testCompatibilityAdapters")) + dependsOn(tasks.named("testCompatibility")) +} + +dependencies { + compileOnly(libs.slf4j.api) + "testCommonImplementation"(libs.slf4j.api) + + // zero runtime reqs is a hard requirements for spotless-lib + // if you need a dep, put it in lib-extra + "testCommonImplementation"(libs.junit.jupiter) + "testCommonImplementation"(libs.assertj.core) + "testCommonImplementation"(libs.durian.testlib) + "testCommonImplementation"(projects.testlib) + "testCommonRuntimeOnly"("org.junit.platform:junit-platform-launcher") + + // GLUE CODE (alphabetic order please) + // cleanthat + "cleanthatCompileOnly"(libs.cleanthat.java) + "compatCleanthat2Dot1CompileAndTestOnly"(libs.cleanthat.java) + // diktat old supported version 1.x + "compatDiktat1Dot2Dot5CompileOnly"(libs.diktat.rules) + // diktat latest supported version 2.x + "compatDiktat2Dot0Dot0CompileOnly"(libs.diktat.runner) + // flexmark + "flexmarkCompileOnly"(libs.flexmark.all) + // gherkin + "gherkinCompileOnly"(libs.gherkin.utils) + "gherkinCompileOnly"(libs.slf4j.api) + // googleJavaFormat + "googleJavaFormatCompileOnly"(libs.google.java.format) + // gson + "gsonCompileOnly"(libs.gson) + // jackson + "jacksonCompileOnly"(libs.jackson.databind) + "jacksonCompileOnly"(libs.jackson.dataformat.yaml) + // javaParser + "javaParserCompileOnly"(libs.javaparser.symbol.solver.core) + // ktfmt + "ktfmtCompileOnly"(libs.ktfmt) + "ktfmtCompileOnly"("com.google.googlejavaformat:google-java-format") { + version { + strictly("1.7") // for JDK 8 compatibility + } + } + "ktfmtCompileOnly"(libs.jsr305) + // ktlint latest supported version + "compatKtLint1Dot0Dot0CompileAndTestOnly"(libs.ktlint.rule.engine) + "compatKtLint1Dot0Dot0CompileAndTestOnly"(libs.ktlint.ruleset.standard) + "compatKtLint1Dot0Dot0CompileAndTestOnly"(libs.slf4j.api) + // palantirJavaFormat + "palantirJavaFormatCompileOnly"( + libs.palantir.java.format + ) // this version needs to stay compilable against Java 8 for CI Job testNpm + // princeOfSpace + "princeOfSpaceCompileOnly"(libs.prince.of.space.core) + // scalafmt + "scalafmtCompileOnly"(libs.scalafmt.core) + // sortPom + "sortPomCompileOnly"(libs.sortpom.sorter) + "sortPomCompileOnly"(libs.slf4j.api) + // tableTestFormatter + "tableTestFormatterCompileOnly"(libs.tabletest.formatter.core) + // zjsonPatch + "zjsonPatchCompileOnly"(libs.zjsonpatch) +} + +// we'll hold the core lib to a high standard +spotbugs { + // LOW|MEDIUM|DEFAULT|HIGH (low = sensitive to even minor mistakes). + reportLevel = Confidence.LOW + excludeFilter = file("spotbugs-exclude.xml") +} + +tasks.withType().configureEach { + jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") + failOnNoDiscoveredTests = false +} + +tasks.jar { + for (glue in needsGlue) { + from(sourceSets.getByName(glue).output.classesDirs) + } +} diff --git a/plugin-gradle/build.gradle b/plugin-gradle/build.gradle deleted file mode 100644 index 8f79641d41..0000000000 --- a/plugin-gradle/build.gradle +++ /dev/null @@ -1,94 +0,0 @@ -apply from: rootProject.file('gradle/changelog.gradle') -ext.artifactId = project.artifactIdGradle -version = spotlessChangelog.versionNext -apply plugin: 'java-library' -apply plugin: 'com.gradle.plugin-publish' -apply plugin: 'java-gradle-plugin' -apply from: rootProject.file('gradle/java-setup.gradle') -apply from: rootProject.file('gradle/spotless-freshmark.gradle') - - -dependencies { - if (version.endsWith('-SNAPSHOT') || (rootProject.spotlessChangelog.versionNext == rootProject.spotlessChangelog.versionLast)) { - api projects.lib - api projects.libExtra - } else { - api "com.diffplug.spotless:spotless-lib:${rootProject.spotlessChangelog.versionLast}" - api "com.diffplug.spotless:spotless-lib-extra:${rootProject.spotlessChangelog.versionLast}" - } - implementation libs.durian.core - implementation libs.durian.io - implementation libs.durian.collect - implementation libs.jgit - - testImplementation projects.testlib - testImplementation libs.junit.jupiter - testImplementation libs.assertj.core - testImplementation libs.durian.testlib - testImplementation libs.owasp.encoder - testImplementation libs.solstice - testRuntimeOnly "org.junit.platform:junit-platform-launcher" -} - -apply from: rootProject.file('gradle/special-tests.gradle') -tasks.withType(Test).configureEach { - testLogging.showStandardStreams = true -} -tasks.validatePlugins { - // TODO: https://github.com/gradle/gradle/issues/22600 - enableStricterValidation = true -} - -////////////////////////// -// GRADLE PLUGIN PORTAL // -////////////////////////// -gradlePlugin { - website = "https://github.com/diffplug/spotless" - vcsUrl = "https://github.com/diffplug/spotless" - plugins { - spotlessPlugin { - id = 'com.diffplug.spotless' - implementationClass = 'com.diffplug.gradle.spotless.SpotlessPlugin' - displayName = 'Spotless formatting plugin' - description = project.description - tags.set([ - 'format', - 'style', - 'license', - 'header', - 'google-java-format', - 'eclipse', - 'ktlint', - 'ktfmt', - 'diktat', - 'tsfmt', - 'prettier', - 'scalafmt', - 'scalafix', - 'black', - 'clang-format' - ]) - compatibility { - features { - configurationCache = true - } - } - } - spotlessPluginLegacy { - id = 'com.diffplug.gradle.spotless' - implementationClass = 'com.diffplug.gradle.spotless.SpotlessPluginRedirect' - displayName = 'Spotless formatting plugin (legacy)' - description = project.description - tags.set([ - 'format' - ]) - } - } -} - -tasks.named("publishPlugins") { - enabled = !version.endsWith('-SNAPSHOT') -} - -// have to apply java-publish after setting up the pluginBundle -apply from: rootProject.file('gradle/java-publish.gradle') diff --git a/plugin-gradle/build.gradle.kts b/plugin-gradle/build.gradle.kts new file mode 100644 index 0000000000..ab114191e6 --- /dev/null +++ b/plugin-gradle/build.gradle.kts @@ -0,0 +1,95 @@ +import com.diffplug.spotless.changelog.gradle.ChangelogExtension +import org.gradle.plugin.compatibility.compatibility + +plugins { + `java-library` + `java-gradle-plugin` + alias(libs.plugins.plugin.publish) + id("spotless.changelog") + id("spotless.java-setup") + id("spotless.spotless-freshmark") + id("spotless.special-tests") + id("spotless.java-publish") +} + +extra["artifactId"] = property("artifactIdGradle") + +version = the().versionNext + +val rootSpotlessChangelog = rootProject.the() + +dependencies { + if ( + version.toString().endsWith("-SNAPSHOT") || + (rootSpotlessChangelog.versionNext == rootSpotlessChangelog.versionLast) + ) { + api(projects.lib) + api(projects.libExtra) + } else { + api("com.diffplug.spotless:spotless-lib:${rootSpotlessChangelog.versionLast}") + api("com.diffplug.spotless:spotless-lib-extra:${rootSpotlessChangelog.versionLast}") + } + implementation(libs.durian.core) + implementation(libs.durian.io) + implementation(libs.durian.collect) + implementation(libs.jgit) + + testImplementation(projects.testlib) + testImplementation(libs.junit.jupiter) + testImplementation(libs.assertj.core) + testImplementation(libs.durian.testlib) + testImplementation(libs.owasp.encoder) + testImplementation(libs.solstice) + testRuntimeOnly("org.junit.platform:junit-platform-launcher") +} + +tasks.withType().configureEach { testLogging.showStandardStreams = true } + +tasks.validatePlugins { + // TODO: https://github.com/gradle/gradle/issues/22600 + enableStricterValidation = true +} + +////////////////////////// +// GRADLE PLUGIN PORTAL // +////////////////////////// +gradlePlugin { + website = "https://github.com/diffplug/spotless" + vcsUrl = "https://github.com/diffplug/spotless" + plugins { + create("spotlessPlugin") { + id = "com.diffplug.spotless" + implementationClass = "com.diffplug.gradle.spotless.SpotlessPlugin" + displayName = "Spotless formatting plugin" + description = project.description + tags = + listOf( + "format", + "style", + "license", + "header", + "google-java-format", + "eclipse", + "ktlint", + "ktfmt", + "diktat", + "tsfmt", + "prettier", + "scalafmt", + "scalafix", + "black", + "clang-format", + ) + compatibility { features { configurationCache = true } } + } + create("spotlessPluginLegacy") { + id = "com.diffplug.gradle.spotless" + implementationClass = "com.diffplug.gradle.spotless.SpotlessPluginRedirect" + displayName = "Spotless formatting plugin (legacy)" + description = project.description + tags = listOf("format") + } + } +} + +tasks.publishPlugins { enabled = !version.toString().endsWith("-SNAPSHOT") } diff --git a/plugin-maven/build.gradle b/plugin-maven/build.gradle deleted file mode 100644 index 79d9108e80..0000000000 --- a/plugin-maven/build.gradle +++ /dev/null @@ -1,64 +0,0 @@ -import org.gradlex.maven.plugin.development.task.GenerateHelpMojoSourcesTask -import org.gradlex.maven.plugin.development.task.GenerateMavenPluginDescriptorTask - -plugins { - // https://github.com/gradlex-org/maven-plugin-development - alias libs.plugins.maven.plugin.development -} - -apply from: rootProject.file('gradle/changelog.gradle') -ext.artifactId = project.artifactIdMaven -version = spotlessChangelog.versionNext - -apply from: rootProject.file("gradle/java-setup.gradle") -apply from: rootProject.file('gradle/spotless-freshmark.gradle') - -mavenPlugin { - name = 'Spotless Maven Plugin' - artifactId = project.artifactIdMaven - description = project.description -} - -dependencies { - implementation projects.lib - implementation projects.libExtra - - compileOnly libs.maven.plugin.api - compileOnly libs.maven.plugin.annotations - compileOnly libs.maven.core - compileOnly libs.aether.api - - compileOnly libs.jakarta.annotation.api - - implementation libs.durian.core - implementation libs.durian.io - implementation libs.durian.collect - implementation libs.plexus.resources - implementation libs.plexus.utils - implementation libs.jgit - implementation libs.plexus.build.api - - testImplementation project(":testlib") - testImplementation libs.junit.jupiter - testImplementation libs.assertj.core - testImplementation libs.mockito.core - testImplementation libs.durian.io - testImplementation libs.mustache.compiler - testImplementation libs.owasp.encoder - testImplementation libs.maven.plugin.api - testImplementation libs.aether.api - testImplementation libs.plexus.resources - testImplementation libs.maven.core - testRuntimeOnly "org.junit.platform:junit-platform-launcher" -} - -apply from: rootProject.file('gradle/special-tests.gradle') -tasks.withType(Test).configureEach { - systemProperty 'spotlessMavenPluginVersion', project.version - systemProperty 'spotlessProjectDir', "${project.rootProject.projectDir}".toString() - dependsOn 'publishToMavenLocal' - dependsOn ':lib:publishToMavenLocal' - dependsOn ':lib-extra:publishToMavenLocal' -} - -apply from: rootProject.file("gradle/java-publish.gradle") diff --git a/plugin-maven/build.gradle.kts b/plugin-maven/build.gradle.kts new file mode 100644 index 0000000000..76e4e1dd91 --- /dev/null +++ b/plugin-maven/build.gradle.kts @@ -0,0 +1,61 @@ +import com.diffplug.spotless.changelog.gradle.ChangelogExtension + +plugins { + alias(libs.plugins.maven.plugin.development) + id("spotless.changelog") + id("spotless.java-setup") + id("spotless.spotless-freshmark") + id("spotless.special-tests") + id("spotless.java-publish") +} + +extra["artifactId"] = property("artifactIdMaven") + +version = the().versionNext + +mavenPlugin { + name = "Spotless Maven Plugin" + artifactId = property("artifactIdMaven").toString() + description = project.description +} + +dependencies { + implementation(projects.lib) + implementation(projects.libExtra) + + compileOnly(libs.maven.plugin.api) + compileOnly(libs.maven.plugin.annotations) + compileOnly(libs.maven.core) + compileOnly(libs.aether.api) + + compileOnly(libs.jakarta.annotation.api) + + implementation(libs.durian.core) + implementation(libs.durian.io) + implementation(libs.durian.collect) + implementation(libs.plexus.resources) + implementation(libs.plexus.utils) + implementation(libs.jgit) + implementation(libs.plexus.build.api) + + testImplementation(projects.testlib) + testImplementation(libs.junit.jupiter) + testImplementation(libs.assertj.core) + testImplementation(libs.mockito.core) + testImplementation(libs.durian.io) + testImplementation(libs.mustache.compiler) + testImplementation(libs.owasp.encoder) + testImplementation(libs.maven.plugin.api) + testImplementation(libs.aether.api) + testImplementation(libs.plexus.resources) + testImplementation(libs.maven.core) + testRuntimeOnly("org.junit.platform:junit-platform-launcher") +} + +tasks.withType().configureEach { + systemProperty("spotlessMavenPluginVersion", project.version) + systemProperty("spotlessProjectDir", "${project.rootProject.projectDir}") + dependsOn(tasks.publishToMavenLocal) + dependsOn(":lib:publishToMavenLocal") + dependsOn(":lib-extra:publishToMavenLocal") +} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 7d83f7cafd..0000000000 --- a/settings.gradle +++ /dev/null @@ -1,86 +0,0 @@ -import static java.lang.System.getenv - -pluginManagement { - repositories { - mavenCentral() - gradlePluginPortal() - } -} - -plugins { - id 'com.diffplug.spotless' version '8.10.0' apply false - id 'com.github.spotbugs' version '6.5.11' apply false // https://github.com/spotbugs/spotbugs-gradle-plugin/releases - id 'com.gradle.develocity' version '4.5.0' -} - -dependencyResolutionManagement { - repositories { - mavenCentral() - } -} - -if (System.env['CI'] != null) { - // use the remote buildcache on all CI builds - buildCache { - def cred = { - if (System.env[it] != null) { - return System.env[it] - } else { - return System.getProperty(it) - } - } - remote(HttpBuildCache) { - url = 'https://buildcache.diffplug.com/cache/' - // but we only push if it's a trusted build (not PRs) - String user = cred('buildcacheuser') - String pass = cred('buildcachepass') - if (user != null && pass != null) { - push = true - credentials { - username = user - password = pass - } - } else { - credentials { username = 'anonymous' } - } - } - } -} - -develocity { - buildScan { - termsOfUseUrl = "https://gradle.com/terms-of-service" - termsOfUseAgree = "yes" - publishing { - onlyIf { getenv('CI') != null } - } - } -} - -enableFeaturePreview("STABLE_CONFIGURATION_CACHE") -enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") - -rootProject.name = 'spotless' - -include 'lib' // reusable library with no dependencies -include 'lib-extra' // reusable library with lots of dependencies -include 'plugin-gradle' // gradle-specific glue code -include 'testlib' // library for sharing test infrastructure between the projects below - -def getStartProperty(String name) { - def value = startParameter.getProjectProperties().get(name) - if(null != value) { - return value - } - // user properties are not available in the startParameter - def userPropertiesFile = new File(startParameter.getGradleUserHomeDir(), 'gradle.properties') - def userProperties = new Properties() - if (userPropertiesFile.exists()) { - userProperties.load(userPropertiesFile.newReader()) - } - return userProperties.get(name) -} - -if (!getenv('SPOTLESS_EXCLUDE_MAVEN')?.toBoolean() && !Boolean.valueOf(getStartProperty('SPOTLESS_EXCLUDE_MAVEN') as String)) { - include 'plugin-maven' // maven-specific glue code -} diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000000..65c04a7670 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,82 @@ +pluginManagement { + includeBuild("build-logic") + repositories { + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id("com.diffplug.spotless") version "8.10.0" apply false + id("com.github.spotbugs") version "6.5.11" apply false + id("com.gradle.develocity") version "4.5.0" +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + } +} + +if (System.getenv("CI") != null) { + // use the remote buildcache on all CI builds + buildCache { + fun cred(name: String): String? = System.getenv(name) ?: System.getProperty(name) + remote { + url = uri("https://buildcache.diffplug.com/cache/") + // but we only push if it's a trusted build (not PRs) + val user = cred("buildcacheuser") + val pass = cred("buildcachepass") + if (user != null && pass != null) { + isPush = true + credentials { + username = user + password = pass + } + } else { + credentials { + username = "anonymous" + } + } + } + } +} + +develocity { + buildScan { + termsOfUseUrl = "https://gradle.com/terms-of-service" + termsOfUseAgree = "yes" + publishing { + onlyIf { System.getenv("CI") != null } + } + } +} + +enableFeaturePreview("STABLE_CONFIGURATION_CACHE") + +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") + +rootProject.name = "spotless" + +include("lib") // reusable library with no dependencies + +include("lib-extra") // reusable library with lots of dependencies + +include("plugin-gradle") // gradle-specific glue code + +include("testlib") // library for sharing test infrastructure between the projects below + +fun getStartProperty(name: String): String? = + startParameter.projectProperties[name] + ?: File(startParameter.gradleUserHomeDir, "gradle.properties") + .takeIf { it.exists() } + ?.reader() + ?.use { java.util.Properties().apply { load(it) }.getProperty(name) } + +val excludeMaven = + System.getenv("SPOTLESS_EXCLUDE_MAVEN")?.toBoolean() == true || + getStartProperty("SPOTLESS_EXCLUDE_MAVEN")?.toBoolean() == true + +if (!excludeMaven) { + include("plugin-maven") // maven-specific glue code +} diff --git a/testlib/build.gradle b/testlib/build.gradle deleted file mode 100644 index 3cc5fdc3fa..0000000000 --- a/testlib/build.gradle +++ /dev/null @@ -1,43 +0,0 @@ -plugins { - id 'java-library' -} -ext.artifactId = project.artifactIdTestLib -version = rootProject.spotlessChangelog.versionNext -apply from: rootProject.file('gradle/java-setup.gradle') - -dependencies { - api projects.lib - api libs.durian.core - api libs.durian.testlib - api libs.junit.jupiter - api libs.assertj.core - api libs.mockito.core - api libs.selfie.lib - api libs.selfie.runner.junit5 - runtimeOnly "org.junit.platform:junit-platform-launcher" - - implementation libs.durian.io - implementation libs.durian.collect - implementation libs.jgit - implementation gradleTestKit() -} - -// we'll hold the testlib to a low standard (prize brevity) -spotbugs { - // LOW|MEDIUM|DEFAULT|HIGH (low = sensitive to even minor mistakes). - reportLevel = com.github.spotbugs.snom.Confidence.valueOf('HIGH') -} - -apply from: rootProject.file('gradle/special-tests.gradle') -tasks.withType(Test).configureEach { - // for Antlr4FormatterStepTest, KtfmtStepTest, and KtLintStepTest - jvmArgs( - '--add-opens=java.base/java.lang=ALL-UNNAMED', - '--add-opens=java.base/java.util=ALL-UNNAMED', - ) -} - -javadoc { - options.addStringOption('Xdoclint:none', '-quiet') - options.addStringOption('Xwerror', '-quiet') -} diff --git a/testlib/build.gradle.kts b/testlib/build.gradle.kts new file mode 100644 index 0000000000..1c96f20d85 --- /dev/null +++ b/testlib/build.gradle.kts @@ -0,0 +1,53 @@ +import com.diffplug.spotless.changelog.gradle.ChangelogExtension +import com.github.spotbugs.snom.Confidence + +plugins { + `java-library` + id("spotless.java-setup") + id("spotless.special-tests") +} + +extra["artifactId"] = property("artifactIdTestLib") + +version = rootProject.the().versionNext + +dependencies { + api(projects.lib) + api(libs.durian.core) + api(libs.durian.testlib) + api(libs.junit.jupiter) + api(libs.assertj.core) + api(libs.mockito.core) + api(libs.selfie.lib) + api(libs.selfie.runner.junit5) + runtimeOnly("org.junit.platform:junit-platform-launcher") + + implementation(libs.durian.io) + implementation(libs.durian.collect) + implementation(libs.jgit) + implementation(gradleTestKit()) +} + +// we'll hold the testlib to a low standard (prize brevity) +spotbugs { + // LOW|MEDIUM|DEFAULT|HIGH (low = sensitive to even minor mistakes). + reportLevel = Confidence.HIGH +} + +tasks.withType().configureEach { + // for Antlr4FormatterStepTest, KtfmtStepTest, and KtLintStepTest + jvmArgs( + "--add-opens=java.base/java.lang=ALL-UNNAMED", + "--add-opens=java.base/java.util=ALL-UNNAMED", + ) +} + +tasks.withType().configureEach { + options { + (this as? StandardJavadocDocletOptions)?.apply { + encoding = Charsets.UTF_8.name() + addStringOption("Xdoclint:none", "-quiet") + addStringOption("Xwerror", "-quiet") + } + } +} From b935223f167900f2353aa7dc467d5d0c2aa9b74b Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Tue, 8 Sep 2026 14:32:01 -0700 Subject: [PATCH 02/11] Use a MIME base64 decoder for the publishing secrets The Kotlin DSL migration replaced Groovy's String.decodeBase64() with java.util.Base64.getDecoder(). Groovy's decoder skips whitespace; the basic JDK decoder throws IllegalArgumentException on it. deploy.yml documents GPG_KEY64 as being produced by gpg --export-secret-keys --armor KEY_ID | openssl base64 and `openssl base64` wraps at 64 chars unless given -A, so that secret is multi-line and decode64 would have blown up at configuration time. This is only reachable on a real `-Prelease=true` publish (the other branch sets signing required=false), so no CI job exercises it. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01G7g6GGwdERtY12UeJDrUxj --- .../src/main/kotlin/spotless.java-publish.gradle.kts | 6 +++++- .../src/main/kotlin/spotless.nexus-publish.gradle.kts | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts b/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts index 95c078073c..f370c5b153 100644 --- a/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts @@ -7,9 +7,13 @@ plugins { signing } +// getMimeDecoder, not getDecoder: the secrets are line-wrapped. GPG_KEY64 is produced with +// `openssl base64`, which wraps at 64 chars unless given -A, and the basic decoder rejects those +// newlines. Groovy's String.decodeBase64 (used before the Kotlin DSL migration) skipped whitespace. +// This only runs on a real `-Prelease=true` publish, so CI never exercises it. fun decode64(varName: String): String { val envValue = System.getenv(varName) ?: return "" - return String(Base64.getDecoder().decode(envValue), Charsets.UTF_8) + return String(Base64.getMimeDecoder().decode(envValue), Charsets.UTF_8) } java { diff --git a/build-logic/src/main/kotlin/spotless.nexus-publish.gradle.kts b/build-logic/src/main/kotlin/spotless.nexus-publish.gradle.kts index 9b49d00e25..cea24403f0 100644 --- a/build-logic/src/main/kotlin/spotless.nexus-publish.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.nexus-publish.gradle.kts @@ -4,9 +4,12 @@ plugins { id("io.github.gradle-nexus.publish-plugin") } +// getMimeDecoder, not getDecoder: the basic decoder rejects the newlines that `base64`/`openssl +// base64` leave in a wrapped secret, whereas Groovy's String.decodeBase64 (used before the Kotlin +// DSL migration) skipped whitespace. See the matching note in spotless.java-publish.gradle.kts. fun decode64(varName: String): String { val envValue = System.getenv(varName) ?: return "" - return String(Base64.getDecoder().decode(envValue), Charsets.UTF_8) + return String(Base64.getMimeDecoder().decode(envValue), Charsets.UTF_8) } group = "com.diffplug.spotless" From 1cf1205ff943f6b59f199b665a40c06d21a4173b Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Tue, 8 Sep 2026 14:32:23 -0700 Subject: [PATCH 03/11] Fail loudly when publishing coordinates are missing The migration turned `project.ext.artifactId` (which throws when unset) into `findProperty("artifactId")?.toString() ?: project.name`. A project that forgot to set it would silently publish as `com.diffplug.spotless:lib` rather than failing the build. Same for `org`, which had a hardcoded "diffplug" fallback in one place and no fallback at all in the four pom url/scm interpolations, where a missing value would have rendered the literal string "null". Also drops the dead `?: "spotless"` fallback on `name`: findProperty resolves Project's own getName() bean property before the extra property from gradle.properties, so it returned "lib"/"plugin-gradle" and the javadoc header linked to https://github.com/diffplug/lib. The rest of the file already builds that URL as `$org/${rootProject.name}`, so use that here too. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01G7g6GGwdERtY12UeJDrUxj --- .../kotlin/spotless.java-publish.gradle.kts | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts b/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts index f370c5b153..6fba53825c 100644 --- a/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts @@ -16,6 +16,12 @@ fun decode64(varName: String): String { return String(Base64.getMimeDecoder().decode(envValue), Charsets.UTF_8) } +// These end up in the published Maven coordinates, so a missing one has to fail the build. A +// fallback would quietly publish e.g. `com.diffplug.spotless:lib` instead of `:spotless-lib`. +fun requiredProperty(name: String): String = + project.findProperty(name)?.toString() + ?: error("${project.path} is missing the '$name' property, which is required to publish it") + java { withJavadocJar() withSourcesJar() @@ -32,13 +38,12 @@ tasks.withType().configureEach { addStringOption("Xdoclint:none", "-quiet") addStringOption("Xwerror", "-quiet") addStringOption("source", "17") - val artifactId = project.findProperty("artifactId")?.toString() ?: project.name - val org = project.findProperty("org")?.toString() ?: "diffplug" - val name = project.findProperty("name")?.toString() ?: "spotless" + val artifactId = requiredProperty("artifactId") + val org = requiredProperty("org") val version = project.version.toString() val group = project.group.toString() val javadocInfo = - "

$group:$artifactId:$version by DiffPlug

" + "

$group:$artifactId:$version by DiffPlug

" header = javadocInfo val dotdotGradle = if (project.name.startsWith("eclipse-")) "../../gradle" else "../gradle" @@ -62,7 +67,8 @@ tasks.check { afterEvaluate { val isExt = project.name.startsWith("eclipse-") - val artifactId = project.findProperty("artifactId")?.toString() ?: project.name + val artifactId = requiredProperty("artifactId") + val org = requiredProperty("org") val isPluginMaven = artifactId == "spotless-maven-plugin" val isPluginGradle = pluginManager.hasPlugin("java-gradle-plugin") @@ -84,13 +90,11 @@ afterEvaluate { pom { name = artifactId description = project.description - url = "https://github.com/${project.findProperty("org")}/${rootProject.name}" + url = "https://github.com/$org/${rootProject.name}" scm { - url = "https://github.com/${project.findProperty("org")}/${rootProject.name}" - connection = - "scm:git:https://github.com/${project.findProperty("org")}/${rootProject.name}.git" - developerConnection = - "scm:git:ssh:git@github.com/${project.findProperty("org")}/${rootProject.name}.git" + url = "https://github.com/$org/${rootProject.name}" + connection = "scm:git:https://github.com/$org/${rootProject.name}.git" + developerConnection = "scm:git:ssh:git@github.com/$org/${rootProject.name}.git" } licenses { license { From d58ace0d88c2d5973a82dd213ab293f02f168ba4 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Tue, 8 Sep 2026 14:32:44 -0700 Subject: [PATCH 04/11] Don't silently create an empty pluginMaven publication The Groovy build applied java-publish at the very bottom of plugin-gradle/build.gradle, with the comment "have to apply java-publish after setting up the pluginBundle". The migration moved it into the plugins block, i.e. applied first, and dropped the comment. It still works, but only because the publishing config is wrapped in afterEvaluate and java-gradle-plugin is declared earlier in the plugins block, so its afterEvaluate runs first and creates 'pluginMaven'. If that ever inverts, the elvis branch created the publication with `if (!isPluginGradle) from(components["java"])` -- i.e. with no artifacts at all -- and we would publish a POM with no jar instead of failing. Make the invariant explicit with a check(), and restore the ordering comment at the call site. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01G7g6GGwdERtY12UeJDrUxj --- .../kotlin/spotless.java-publish.gradle.kts | 17 +++++++++++------ plugin-gradle/build.gradle.kts | 2 ++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts b/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts index 6fba53825c..09e2a992f2 100644 --- a/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts @@ -74,13 +74,18 @@ afterEvaluate { publishing { publications { + // java-gradle-plugin creates 'pluginMaven' from its own afterEvaluate, with the java + // component already attached. Ours has to run after that one, which it only does because + // java-gradle-plugin is applied earlier in the consumer's plugins block. If that ever + // inverts we would create an empty publication here and ship a POM with no jar, so check + // rather than silently degrade. + val existing = findByName("pluginMaven") as? MavenPublication + check(!isPluginGradle || existing != null) { + "${project.path} applies java-gradle-plugin, which must be applied before " + + "spotless.java-publish so that it can create the 'pluginMaven' publication" + } val pluginMaven = - findByName("pluginMaven") as? MavenPublication - ?: create("pluginMaven") { - if (!isPluginGradle) { - from(components["java"]) - } - } + existing ?: create("pluginMaven") { from(components["java"]) } pluginMaven.apply { groupId = project.group.toString() diff --git a/plugin-gradle/build.gradle.kts b/plugin-gradle/build.gradle.kts index ab114191e6..3b305a5f64 100644 --- a/plugin-gradle/build.gradle.kts +++ b/plugin-gradle/build.gradle.kts @@ -9,6 +9,8 @@ plugins { id("spotless.java-setup") id("spotless.spotless-freshmark") id("spotless.special-tests") + // must come after java-gradle-plugin, which is what creates the 'pluginMaven' publication that + // spotless.java-publish then configures id("spotless.java-publish") } From 8501b76eec15660d6cadbab9145e4771ad5c1c05 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Tue, 8 Sep 2026 14:33:04 -0700 Subject: [PATCH 05/11] Keep Groovy's boolean parsing for the two env-var toggles Groovy's String.toBoolean() accepts "true", "y" and "1" ignoring case; Kotlin's toBoolean() accepts only "true". The migration swapped them, so `error-prone=1` no longer enabled error-prone and `SPOTLESS_EXCLUDE_MAVEN=1` no longer excluded the maven plugin -- both silently, as no-ops. Note this also widens the -P form of SPOTLESS_EXCLUDE_MAVEN, which used strict Boolean.valueOf before. That direction can't break an existing invocation. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01G7g6GGwdERtY12UeJDrUxj --- .../src/main/kotlin/spotless.error-prone.gradle.kts | 7 ++++++- settings.gradle.kts | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts b/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts index 668f069e73..2d25639f84 100644 --- a/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts @@ -4,9 +4,14 @@ plugins { id("net.ltgt.errorprone") } +// Groovy's String.toBoolean() -- what this used before the Kotlin DSL migration -- accepts "true", +// "y" and "1", ignoring case. Kotlin's toBoolean() only accepts "true", so the short forms would +// silently become no-ops. +fun String.toBooleanGroovy(): Boolean = trim().lowercase() in setOf("true", "y", "1") + tasks.withType().configureEach { options.errorprone { - if (System.getenv("error-prone")?.toBoolean() == true) { + if (System.getenv("error-prone")?.toBooleanGroovy() == true) { enable() } else { disable() diff --git a/settings.gradle.kts b/settings.gradle.kts index 65c04a7670..956bc4d804 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -73,9 +73,14 @@ fun getStartProperty(name: String): String? = ?.reader() ?.use { java.util.Properties().apply { load(it) }.getProperty(name) } +// Groovy's String.toBoolean() -- what this used before the Kotlin DSL migration -- accepts "true", +// "y" and "1", ignoring case. Kotlin's toBoolean() only accepts "true", so the short forms would +// silently become no-ops. +fun String.toBooleanGroovy(): Boolean = trim().lowercase() in setOf("true", "y", "1") + val excludeMaven = - System.getenv("SPOTLESS_EXCLUDE_MAVEN")?.toBoolean() == true || - getStartProperty("SPOTLESS_EXCLUDE_MAVEN")?.toBoolean() == true + System.getenv("SPOTLESS_EXCLUDE_MAVEN")?.toBooleanGroovy() == true || + getStartProperty("SPOTLESS_EXCLUDE_MAVEN")?.toBooleanGroovy() == true if (!excludeMaven) { include("plugin-maven") // maven-specific glue code From 95053802ce5def036973b916eb7ed8e2999e15d5 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Tue, 8 Sep 2026 14:33:13 -0700 Subject: [PATCH 06/11] spotless.special-tests: declare the java plugin it depends on The script calls tasks.named("test") and registers Test tasks at apply time, but only declared com.adarshr.test-logger. It works today purely because every consumer happens to declare java-library (or maven-plugin-development) earlier in its plugins block; reordering would fail with an UnknownTaskException that points nowhere useful. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01G7g6GGwdERtY12UeJDrUxj --- build-logic/src/main/kotlin/spotless.special-tests.gradle.kts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build-logic/src/main/kotlin/spotless.special-tests.gradle.kts b/build-logic/src/main/kotlin/spotless.special-tests.gradle.kts index 9297d5ed70..a720b74c21 100644 --- a/build-logic/src/main/kotlin/spotless.special-tests.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.special-tests.gradle.kts @@ -1,6 +1,9 @@ import com.gradle.develocity.agent.gradle.test.DevelocityTestConfiguration plugins { + // this script configures the `test` task and registers Test tasks, so it needs java itself + // rather than relying on every consumer to declare it earlier in their plugins block + id("java") id("com.adarshr.test-logger") } From 5bed86a28565c05d493076ba43d135d470ce9c39 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Tue, 8 Sep 2026 14:34:09 -0700 Subject: [PATCH 07/11] Restore the rationale comments dropped in the migration The Kotlin DSL rewrite carried the behavior across faithfully but lost most of the "why" along the way. These are the ones that answer a question the code can't: - error-prone: the issue links behind disableAllWarnings (spotless#2745, google/error-prone#5365), which of the disables are there because we don't want ErrorProne's annotations, and the excludedPaths note about the dirty-file/up-to-date bug - java-setup: the spotbugs detector doc URLs for ConstructorThrow and FindReturnRef, the reportLevel scale, "bug free or it doesn't ship!" - java-publish: why javadoc warnings are off, why check depends on javadoc, the Maven 3.1.0 prerequisite, and both changelog ordering constraints - changelog: the one-changelog-per-tag rule and the -Prelease=true requirement - special-tests: the pointer to com.diffplug.spotless.tag, the up-to-date-checking and parallel-forks notes - freshmark: why the second FreshMarkExtension exists and uses versionNext as versionLast Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01G7g6GGwdERtY12UeJDrUxj --- .../src/main/kotlin/spotless.changelog.gradle.kts | 7 ++++++- .../src/main/kotlin/spotless.error-prone.gradle.kts | 13 +++++++++---- .../main/kotlin/spotless.java-publish.gradle.kts | 8 ++++++++ .../src/main/kotlin/spotless.java-setup.gradle.kts | 11 +++++++++-- .../main/kotlin/spotless.special-tests.gradle.kts | 4 ++++ .../kotlin/spotless.spotless-freshmark.gradle.kts | 6 ++++++ 6 files changed, 42 insertions(+), 7 deletions(-) diff --git a/build-logic/src/main/kotlin/spotless.changelog.gradle.kts b/build-logic/src/main/kotlin/spotless.changelog.gradle.kts index 9b0259441f..c9fb74cd1e 100644 --- a/build-logic/src/main/kotlin/spotless.changelog.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.changelog.gradle.kts @@ -12,12 +12,14 @@ val (kind, releaseTitle) = } } +// the root project and plugins have their own changelogs spotlessChangelog { changelogFile("CHANGES.md") + // need -Prelease=true in order to do a publish setAppendDashSnapshotUnless_dashPrelease(true) branch("release") tagPrefix("$kind/") - commitMessage("Published $kind/{{version}}") + commitMessage("Published $kind/{{version}}") // {{version}} will be replaced tagMessage("{{changes}}") runAfterPush( "gh release create $kind/{{version}} --title '$releaseTitle v{{version}}' --notes-from-tag" @@ -28,11 +30,14 @@ if (project == rootProject) { gradle.taskGraph.whenReady { val changelogPushTasks = allTasks.filter { it.name == "changelogPush" }.map { it.path } if (changelogPushTasks.size > 1) { + // make sure only one changelog gets published per tag/commit throw IllegalArgumentException( "Run changelogPush one at a time:\n" + changelogPushTasks.joinToString("\n") ) } if (changelogPushTasks.size == 1) { + // if the one thing being published is a plugin, make sure there aren't any unreleased + // changes in lib val isPlugin = changelogPushTasks[0] == ":plugin-gradle:changelogPush" || changelogPushTasks[0] == ":plugin-maven:changelogPush" diff --git a/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts b/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts index 2d25639f84..85ec338f6d 100644 --- a/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts @@ -16,15 +16,17 @@ tasks.withType().configureEach { } else { disable() } + // https://github.com/diffplug/spotless/issues/2745 + // https://github.com/google/error-prone/issues/5365 disableAllWarnings = true disable( - "AnnotateFormatMethod", + "AnnotateFormatMethod", // We don't want to use ErrorProne's annotations. "FunctionalInterfaceMethodChanged", - "ImmutableEnumChecker", - "InlineMeSuggester", + "ImmutableEnumChecker", // We don't want to use ErrorProne's annotations. + "InlineMeSuggester", // We don't want to use ErrorProne's annotations. "JavaxInjectOnAbstractMethod", "OverridesJavaxInjectableMethod", - "ReturnValueIgnored", + "ReturnValueIgnored", // We don't want to use ErrorProne's annotations. ) error( "ReturnValueIgnored", @@ -33,6 +35,9 @@ tasks.withType().configureEach { "UnnecessarilyFullyQualified", "UnnecessaryLambda", ) + // bug: this only happens when the file is dirty. + // might be an up2date (caching) issue, as file is currently in corrupt state. + // ForbidGradleInternal(import excludedPaths = ".*/GradleIntegrationHarness.java" } } diff --git a/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts b/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts index 09e2a992f2..df300ccd8b 100644 --- a/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts @@ -35,6 +35,8 @@ tasks.withType().configureEach { options { (this as? StandardJavadocDocletOptions)?.apply { encoding = Charsets.UTF_8.name() + // Where it's possible to name parameters and methods clearly enough that javadoc is not + // necessary, why make the code bigger? Thus, no javadoc warnings. addStringOption("Xdoclint:none", "-quiet") addStringOption("Xwerror", "-quiet") addStringOption("source", "17") @@ -61,6 +63,7 @@ tasks.withType().configureEach { } } +// make sure bad javadoc breaks the build tasks.check { dependsOn(tasks.javadoc) } @@ -140,6 +143,7 @@ afterEvaluate { } } if (isPluginMaven) { + // Maven plugin requires Maven 3.1.0+ to run withXml { val rootNode = asNode() val prerequisites = rootNode.appendNode("prerequisites") @@ -164,19 +168,23 @@ afterEvaluate { sign(publishing.publications) } + // find the project with the changelog (this project for plugins, root project for libs) val changelogProject = if (tasks.names.contains("changelogBump")) project else rootProject val changelogTasks = changelogProject.tasks + // ensures that nothing will be built if changelogPush will end up failing tasks.jar { dependsOn(changelogTasks.named("changelogCheck")) } + // ensures that changelog bump and push only happens if the publish was successful val thisProj = project changelogTasks.named("changelogBump") { dependsOn( ":${thisProj.path.removePrefix(":")}:publishPluginMavenPublicationToSonatypeRepository" ) dependsOn(":closeAndReleaseSonatypeStagingRepository") + // if we have a Gradle plugin, we need to push it up to the plugin portal too if (thisProj.tasks.names.contains("publishPlugins")) { dependsOn(thisProj.tasks.named("publishPlugins")) } diff --git a/build-logic/src/main/kotlin/spotless.java-setup.gradle.kts b/build-logic/src/main/kotlin/spotless.java-setup.gradle.kts index cf24b25958..e759c2720d 100644 --- a/build-logic/src/main/kotlin/spotless.java-setup.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.java-setup.gradle.kts @@ -14,9 +14,16 @@ tasks.withType().configureEach { } spotbugs { - ignoreFailures = false + ignoreFailures = false // bug free or it doesn't ship! + // LOW|MEDIUM|DEFAULT|HIGH (low = sensitive to even minor mistakes). reportLevel = Confidence.MEDIUM - omitVisitors = listOf("ConstructorThrow", "FindReturnRef") + omitVisitors = + listOf( + // https://spotbugs.readthedocs.io/en/latest/detectors.html#constructorthrow + "ConstructorThrow", + // https://spotbugs.readthedocs.io/en/latest/detectors.html#findreturnref + "FindReturnRef", + ) } tasks.spotbugsTest { diff --git a/build-logic/src/main/kotlin/spotless.special-tests.gradle.kts b/build-logic/src/main/kotlin/spotless.special-tests.gradle.kts index a720b74c21..36e0fd2a32 100644 --- a/build-logic/src/main/kotlin/spotless.special-tests.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.special-tests.gradle.kts @@ -7,6 +7,7 @@ plugins { id("com.adarshr.test-logger") } +// See com.diffplug.spotless.tag package for available JUnit 5 @Tag annotations val special = listOf("black", "buf", "clang", "gofmt", "idea", "npm", "shfmt") val isCiServer = System.getenv().containsKey("CI") @@ -21,8 +22,11 @@ tasks.withType().configureEach { } } // selfie https://selfie.dev/jvm/get-started#gradle + // optional, see "Overwrite everything" there project.findProperty("selfie")?.let { environment("selfie", it) } + // optional, improves up-to-date checking inputs.files(fileTree("src/test") { include("**/*.ss") }) + // https://docs.gradle.org/8.8/userguide/performance.html#execute_tests_in_parallel maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) } diff --git a/build-logic/src/main/kotlin/spotless.spotless-freshmark.gradle.kts b/build-logic/src/main/kotlin/spotless.spotless-freshmark.gradle.kts index 2e505c5292..fdb11c11ef 100644 --- a/build-logic/src/main/kotlin/spotless.spotless-freshmark.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.spotless-freshmark.gradle.kts @@ -24,11 +24,13 @@ spotless { } } +// if this freshmark has a changelog file, then it has version-sensitive content pluginManager.withPlugin("com.diffplug.spotless-changelog") { val changelog = the() val versionLast = changelog.versionLast val versionNext = changelog.versionNext + // normally we use versionLast for our freshmark spotless { freshmark { properties { @@ -37,17 +39,21 @@ pluginManager.withPlugin("com.diffplug.spotless-changelog") { } } + // create a freshmark apply task manually val freshmark = FreshMarkExtension(the()) freshmarkSetup(freshmark) freshmark.properties { + // that uses versionNext as versionLast put("versionLast", versionNext) } val changelogBumpFreshmark = freshmark.createIndependentApplyTask("changelogBumpFreshmark") + // freshmark should run after the changelog bump changelogBumpFreshmark.dependsOn(tasks.named("changelogBump")) val changelogBumpFreshmarkGitAdd = tasks.register("changelogBumpFreshmarkGitAdd") { + // this git add should run after the freshmark dependsOn(changelogBumpFreshmark) commandLine("git", "add", "*.md") } From 19f4065ff04d661cb3ee9d937a261ded2c4b4ac8 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Tue, 8 Sep 2026 14:50:09 -0700 Subject: [PATCH 08/11] Make the Error Prone environment toggle set enabled --- build-logic/src/main/kotlin/spotless.error-prone.gradle.kts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts b/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts index 85ec338f6d..75abd8b67d 100644 --- a/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts @@ -11,11 +11,7 @@ fun String.toBooleanGroovy(): Boolean = trim().lowercase() in setOf("true", "y", tasks.withType().configureEach { options.errorprone { - if (System.getenv("error-prone")?.toBooleanGroovy() == true) { - enable() - } else { - disable() - } + enabled = System.getenv("error-prone")?.toBooleanGroovy() == true // https://github.com/diffplug/spotless/issues/2745 // https://github.com/google/error-prone/issues/5365 disableAllWarnings = true From 8cd954b542aa70e195e431627243b0c8daa0c7f8 Mon Sep 17 00:00:00 2001 From: Goooler Date: Thu, 10 Sep 2026 17:49:52 +0800 Subject: [PATCH 09/11] Share common convention plugin utilities in Ext.kt --- build-logic/src/main/kotlin/Ext.kt | 35 +++++++++++++++++++ build-logic/src/main/kotlin/ProjectExt.kt | 7 ---- .../main/kotlin/spotless.changelog.gradle.kts | 6 ++-- .../kotlin/spotless.error-prone.gradle.kts | 5 --- .../kotlin/spotless.java-publish.gradle.kts | 20 +---------- .../kotlin/spotless.nexus-publish.gradle.kts | 10 ------ .../kotlin/spotless.special-tests.gradle.kts | 2 -- .../spotless.spotless-freshmark.gradle.kts | 3 +- lib-extra/build.gradle.kts | 3 +- lib/build.gradle.kts | 3 +- plugin-gradle/build.gradle.kts | 5 +-- plugin-maven/build.gradle.kts | 4 +-- testlib/build.gradle.kts | 3 +- 13 files changed, 45 insertions(+), 61 deletions(-) create mode 100644 build-logic/src/main/kotlin/Ext.kt delete mode 100644 build-logic/src/main/kotlin/ProjectExt.kt diff --git a/build-logic/src/main/kotlin/Ext.kt b/build-logic/src/main/kotlin/Ext.kt new file mode 100644 index 0000000000..6ab5ed4df6 --- /dev/null +++ b/build-logic/src/main/kotlin/Ext.kt @@ -0,0 +1,35 @@ +import com.diffplug.spotless.changelog.gradle.ChangelogExtension +import java.util.Base64 +import org.gradle.accessors.dm.LibrariesForLibs +import org.gradle.api.Project +import org.gradle.kotlin.dsl.findByType +import org.gradle.kotlin.dsl.getByType + +internal val Project.libs: LibrariesForLibs + get() = extensions.findByType() ?: rootProject.extensions.getByType() + +val Project.spotlessChangelog: ChangelogExtension + get() = extensions.findByType() ?: rootProject.extensions.getByType() + +val Project.rootSpotlessChangelog: ChangelogExtension + get() = rootProject.extensions.getByType() + +fun Project.requiredProperty(name: String): String = + findProperty(name)?.toString() + ?: error("$path is missing the '$name' property, which is required") + +// getMimeDecoder, not getDecoder: the basic decoder rejects the newlines that `base64`/`openssl +// base64` leave in a wrapped secret, whereas Groovy's String.decodeBase64 (used before the Kotlin +// DSL migration) skipped whitespace. +fun decode64(varName: String): String { + val envValue = System.getenv(varName) ?: return "" + return String(Base64.getMimeDecoder().decode(envValue), Charsets.UTF_8) +} + +// Groovy's String.toBoolean() -- what this used before the Kotlin DSL migration -- accepts "true", +// "y" and "1", ignoring case. Kotlin's toBoolean() only accepts "true", so the short forms would +// silently become no-ops. +fun String.toBooleanGroovy(): Boolean = trim().lowercase() in setOf("true", "y", "1") + +val isCiServer: Boolean + get() = System.getenv().containsKey("CI") diff --git a/build-logic/src/main/kotlin/ProjectExt.kt b/build-logic/src/main/kotlin/ProjectExt.kt deleted file mode 100644 index c60493beae..0000000000 --- a/build-logic/src/main/kotlin/ProjectExt.kt +++ /dev/null @@ -1,7 +0,0 @@ -import org.gradle.accessors.dm.LibrariesForLibs -import org.gradle.api.Project -import org.gradle.kotlin.dsl.findByType -import org.gradle.kotlin.dsl.getByType - -val Project.libs: LibrariesForLibs - get() = extensions.findByType() ?: rootProject.extensions.getByType() diff --git a/build-logic/src/main/kotlin/spotless.changelog.gradle.kts b/build-logic/src/main/kotlin/spotless.changelog.gradle.kts index c9fb74cd1e..5db9e0ba04 100644 --- a/build-logic/src/main/kotlin/spotless.changelog.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.changelog.gradle.kts @@ -43,14 +43,14 @@ if (project == rootProject) { changelogPushTasks[0] == ":plugin-maven:changelogPush" if ( isPlugin && - !rootProject.spotlessChangelog.parsedChangelog.noUnreleasedChanges() && + !rootSpotlessChangelog.parsedChangelog.noUnreleasedChanges() && rootProject.findProperty("ignoreUnreleasedLib")?.toString() != "true" ) { throw IllegalArgumentException( "You're going to publish ${changelogPushTasks[0]}, but there are unreleased features in lib!\n" + "You should run :changelogPush first! Else you'll be missing out on:\n" + - "${rootProject.spotlessChangelog.parsedChangelog.unreleasedChanges()}\n" + - "If it's okay to miss those and link against the old ${rootProject.spotlessChangelog.versionLast} then " + + "${rootSpotlessChangelog.parsedChangelog.unreleasedChanges()}\n" + + "If it's okay to miss those and link against the old ${rootSpotlessChangelog.versionLast} then " + "add -PignoreUnreleasedLib=true" ) } diff --git a/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts b/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts index 75abd8b67d..45a97a7439 100644 --- a/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.error-prone.gradle.kts @@ -4,11 +4,6 @@ plugins { id("net.ltgt.errorprone") } -// Groovy's String.toBoolean() -- what this used before the Kotlin DSL migration -- accepts "true", -// "y" and "1", ignoring case. Kotlin's toBoolean() only accepts "true", so the short forms would -// silently become no-ops. -fun String.toBooleanGroovy(): Boolean = trim().lowercase() in setOf("true", "y", "1") - tasks.withType().configureEach { options.errorprone { enabled = System.getenv("error-prone")?.toBooleanGroovy() == true diff --git a/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts b/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts index df300ccd8b..3c33d1d817 100644 --- a/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.java-publish.gradle.kts @@ -1,27 +1,9 @@ -import com.diffplug.spotless.changelog.gradle.ChangelogExtension -import java.util.Base64 - plugins { `java-library` `maven-publish` signing } -// getMimeDecoder, not getDecoder: the secrets are line-wrapped. GPG_KEY64 is produced with -// `openssl base64`, which wraps at 64 chars unless given -A, and the basic decoder rejects those -// newlines. Groovy's String.decodeBase64 (used before the Kotlin DSL migration) skipped whitespace. -// This only runs on a real `-Prelease=true` publish, so CI never exercises it. -fun decode64(varName: String): String { - val envValue = System.getenv(varName) ?: return "" - return String(Base64.getMimeDecoder().decode(envValue), Charsets.UTF_8) -} - -// These end up in the published Maven coordinates, so a missing one has to fail the build. A -// fallback would quietly publish e.g. `com.diffplug.spotless:lib` instead of `:spotless-lib`. -fun requiredProperty(name: String): String = - project.findProperty(name)?.toString() - ?: error("${project.path} is missing the '$name' property, which is required to publish it") - java { withJavadocJar() withSourcesJar() @@ -50,7 +32,7 @@ tasks.withType().configureEach { val dotdotGradle = if (project.name.startsWith("eclipse-")) "../../gradle" else "../gradle" linksOffline("https://docs.gradle.org/6.1.1/javadoc/", "$dotdotGradle/javadoc/gradle") - val versionLast = rootProject.the().versionLast + val versionLast = rootSpotlessChangelog.versionLast linksOffline( "https://javadoc.io/static/com.diffplug.spotless/spotless-lib/$versionLast", "$dotdotGradle/javadoc/spotless-lib", diff --git a/build-logic/src/main/kotlin/spotless.nexus-publish.gradle.kts b/build-logic/src/main/kotlin/spotless.nexus-publish.gradle.kts index cea24403f0..a1c54c8487 100644 --- a/build-logic/src/main/kotlin/spotless.nexus-publish.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.nexus-publish.gradle.kts @@ -1,17 +1,7 @@ -import java.util.Base64 - plugins { id("io.github.gradle-nexus.publish-plugin") } -// getMimeDecoder, not getDecoder: the basic decoder rejects the newlines that `base64`/`openssl -// base64` leave in a wrapped secret, whereas Groovy's String.decodeBase64 (used before the Kotlin -// DSL migration) skipped whitespace. See the matching note in spotless.java-publish.gradle.kts. -fun decode64(varName: String): String { - val envValue = System.getenv(varName) ?: return "" - return String(Base64.getMimeDecoder().decode(envValue), Charsets.UTF_8) -} - group = "com.diffplug.spotless" nexusPublishing { diff --git a/build-logic/src/main/kotlin/spotless.special-tests.gradle.kts b/build-logic/src/main/kotlin/spotless.special-tests.gradle.kts index 36e0fd2a32..8353e353d9 100644 --- a/build-logic/src/main/kotlin/spotless.special-tests.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.special-tests.gradle.kts @@ -10,8 +10,6 @@ plugins { // See com.diffplug.spotless.tag package for available JUnit 5 @Tag annotations val special = listOf("black", "buf", "clang", "gofmt", "idea", "npm", "shfmt") -val isCiServer = System.getenv().containsKey("CI") - tasks.withType().configureEach { if (isCiServer) { configure { diff --git a/build-logic/src/main/kotlin/spotless.spotless-freshmark.gradle.kts b/build-logic/src/main/kotlin/spotless.spotless-freshmark.gradle.kts index fdb11c11ef..cd0206aebb 100644 --- a/build-logic/src/main/kotlin/spotless.spotless-freshmark.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.spotless-freshmark.gradle.kts @@ -1,5 +1,4 @@ import com.diffplug.gradle.spotless.FreshMarkExtension -import com.diffplug.spotless.changelog.gradle.ChangelogExtension plugins { id("com.diffplug.spotless") @@ -26,7 +25,7 @@ spotless { // if this freshmark has a changelog file, then it has version-sensitive content pluginManager.withPlugin("com.diffplug.spotless-changelog") { - val changelog = the() + val changelog = spotlessChangelog val versionLast = changelog.versionLast val versionNext = changelog.versionNext diff --git a/lib-extra/build.gradle.kts b/lib-extra/build.gradle.kts index 36728ddd7f..4118bcbb7b 100644 --- a/lib-extra/build.gradle.kts +++ b/lib-extra/build.gradle.kts @@ -1,4 +1,3 @@ -import com.diffplug.spotless.changelog.gradle.ChangelogExtension import com.github.spotbugs.snom.Confidence plugins { @@ -11,7 +10,7 @@ plugins { extra["artifactId"] = property("artifactIdLibExtra") -version = rootProject.the().versionNext +version = spotlessChangelog.versionNext dependencies { api(projects.lib) diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 261231b084..942a72b1de 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -1,4 +1,3 @@ -import com.diffplug.spotless.changelog.gradle.ChangelogExtension import com.github.spotbugs.snom.Confidence plugins { @@ -11,7 +10,7 @@ plugins { extra["artifactId"] = property("artifactIdLib") -version = rootProject.the().versionNext +version = spotlessChangelog.versionNext val needsGlue = listOf( diff --git a/plugin-gradle/build.gradle.kts b/plugin-gradle/build.gradle.kts index 3b305a5f64..b59f4a6f70 100644 --- a/plugin-gradle/build.gradle.kts +++ b/plugin-gradle/build.gradle.kts @@ -1,4 +1,3 @@ -import com.diffplug.spotless.changelog.gradle.ChangelogExtension import org.gradle.plugin.compatibility.compatibility plugins { @@ -16,9 +15,7 @@ plugins { extra["artifactId"] = property("artifactIdGradle") -version = the().versionNext - -val rootSpotlessChangelog = rootProject.the() +version = spotlessChangelog.versionNext dependencies { if ( diff --git a/plugin-maven/build.gradle.kts b/plugin-maven/build.gradle.kts index 76e4e1dd91..1217ec3584 100644 --- a/plugin-maven/build.gradle.kts +++ b/plugin-maven/build.gradle.kts @@ -1,5 +1,3 @@ -import com.diffplug.spotless.changelog.gradle.ChangelogExtension - plugins { alias(libs.plugins.maven.plugin.development) id("spotless.changelog") @@ -11,7 +9,7 @@ plugins { extra["artifactId"] = property("artifactIdMaven") -version = the().versionNext +version = spotlessChangelog.versionNext mavenPlugin { name = "Spotless Maven Plugin" diff --git a/testlib/build.gradle.kts b/testlib/build.gradle.kts index 1c96f20d85..4956621aa0 100644 --- a/testlib/build.gradle.kts +++ b/testlib/build.gradle.kts @@ -1,4 +1,3 @@ -import com.diffplug.spotless.changelog.gradle.ChangelogExtension import com.github.spotbugs.snom.Confidence plugins { @@ -9,7 +8,7 @@ plugins { extra["artifactId"] = property("artifactIdTestLib") -version = rootProject.the().versionNext +version = spotlessChangelog.versionNext dependencies { api(projects.lib) From 4b55be050150c7805cc0a2360f95d4078a02178d Mon Sep 17 00:00:00 2001 From: Goooler Date: Thu, 10 Sep 2026 18:02:57 +0800 Subject: [PATCH 10/11] Use type-safe rewrite configuration accessor in spotless.rewrite.gradle.kts --- build-logic/src/main/kotlin/spotless.rewrite.gradle.kts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build-logic/src/main/kotlin/spotless.rewrite.gradle.kts b/build-logic/src/main/kotlin/spotless.rewrite.gradle.kts index a09abad3ec..18f1718506 100644 --- a/build-logic/src/main/kotlin/spotless.rewrite.gradle.kts +++ b/build-logic/src/main/kotlin/spotless.rewrite.gradle.kts @@ -19,7 +19,7 @@ rewrite { } dependencies { - "rewrite"(libs.rewrite.recipe.migrate.java) - "rewrite"(libs.rewrite.recipe.static.analysis) - "rewrite"(libs.rewrite.recipe.third.party) + rewrite(libs.rewrite.recipe.migrate.java) + rewrite(libs.rewrite.recipe.static.analysis) + rewrite(libs.rewrite.recipe.third.party) } From 6bfbad4afb4f0e058392c017eaa5a8f49166e1e9 Mon Sep 17 00:00:00 2001 From: Goooler Date: Thu, 10 Sep 2026 18:05:13 +0800 Subject: [PATCH 11/11] Enable org.gradle.kotlin.dsl.allWarningsAsErrors flag --- gradle.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle.properties b/gradle.properties index 058007ccc6..bff209744d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,7 @@ org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1024m -Dfile.encoding=UTF-8 org.gradle.parallel=true org.gradle.caching=true org.gradle.configuration-cache=true +org.gradle.kotlin.dsl.allWarningsAsErrors=true org.gradle.tooling.parallel=true name=spotless