diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index c390a1741..10a3b61bb 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -5,4 +5,10 @@ plugins { repositories { gradlePluginPortal() } +// Pin the precompiled-script-plugin compilation to Java 17 so the generated plugin classes load on +// the daemon regardless of which JDK it runs on. Without this, kotlin-dsl targets whatever JDK the +// daemon happens to use (e.g. 21/25), emitting newer bytecode that a Java 17 daemon cannot load +// (UnsupportedClassVersionError). +kotlin { jvmToolchain(17) } + spotless { kotlinGradle { ktfmt().googleStyle() } } diff --git a/build-logic/gradle.properties b/build-logic/gradle.properties new file mode 100644 index 000000000..5a91892ce --- /dev/null +++ b/build-logic/gradle.properties @@ -0,0 +1,5 @@ +# build-logic is an included build, so it does NOT inherit the root gradle.properties; its Kotlin +# compile daemon (which builds the precompiled script plugins) must be sized here. Without this the +# cold compile fails with an OOM / "internal compiler error" and falls back to a slow no-daemon +# compile. Raise -Xmx further if you still see those failures on a cold build. +kotlin.daemon.jvmargs=-Xmx2g diff --git a/build.gradle.kts b/build.gradle.kts index 09c233805..26b9fa396 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -62,9 +62,13 @@ allprojects { kotlinGradle { ktfmt("0.61").googleStyle() } java { target("src/*/java/**/*.java") - // since kfmt also brings in google-java-format we need to sync versions - // https://github.com/facebook/ktfmt/blob/v0.61/gradle/libs.versions.toml#L7 - googleJavaFormat("1.23.0") + // google-java-format 1.28.0: earlier versions (e.g. 1.23.0, which ktfmt 0.61 bundles) call + // com.sun.tools.javac internals that changed in recent JDKs, so Spotless throws + // NoSuchMethodError/NoClassDefFoundError when the daemon runs on a newer JDK (e.g. 25). + // 1.28.0 is the newest release that still runs on JDK 17 (1.29.0+ requires JDK 21+), + // matching the daemon/CI toolchain. This Java step has its own formatter classpath, + // independent of ktfmt's bundled copy (used only for Kotlin), so they need not match. + googleJavaFormat("1.28.0") removeUnusedImports() trimTrailingWhitespace() forbidWildcardImports()