Migrate Gradle build scripts to Kotlin DSL with build-logic convention plugins - #3044
Migrate Gradle build scripts to Kotlin DSL with build-logic convention plugins#3044Goooler wants to merge 8 commits into
Conversation
30c19dd to
870c43f
Compare
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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G7g6GGwdERtY12UeJDrUxj
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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G7g6GGwdERtY12UeJDrUxj
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) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G7g6GGwdERtY12UeJDrUxj
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) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G7g6GGwdERtY12UeJDrUxj
The script calls tasks.named<Test>("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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G7g6GGwdERtY12UeJDrUxj
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) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G7g6GGwdERtY12UeJDrUxj
|
I made some edits, this LGTM now @Goooler. I'll let you click merge if you agree with the changes. Main thing was Base64 decoding with spaces & newlines. |
|
Would it be possible to migrate the secrets on CI? I'll address a follow-up to migrate publish plugin to |
|
The problem with non-base-64 secrets is that if the secrets contain punctuation they can screw up scripts and commandline args. I lost many hours to this, which is how they ended up base-64 encoded in the first place. We don't have to rotate them, so I heavily prefer not to. |
|
The secrets work well with env variables like https://github.com/GradleUp/shadow/blob/cf92cff334f5e4addf8f53bff1d469d68b470f00/.github/workflows/release.yml#L26-L32. But either of your choices is fine with me. |
Relands #2876.