Add gradle9 module: Spring Boot 4 build migrated from Gradle 8 to Gradle 9

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gth99spB1CzQmBFofXmU4Z
This commit is contained in:
2026-09-28 09:00:03 +00:00
co-authored by Claude Sonnet 5
parent b4b43b94bf
commit 804c33f0d5
25 changed files with 689 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
.gradle/
build/
+14
View File
@@ -0,0 +1,14 @@
# gradle9: moving a Spring Boot 4 build to Gradle 9
Companion code for the ankurm.com post "Gradle 9 for Spring Boot 4 Projects: Configuration Cache, Version Catalogs and Kotlin DSL".
| Folder | What it is |
|---|---|
| `before/` | A legacy Groovy DSL build (Boot 4.1.1) that works on Gradle 8.14 and breaks on Gradle 9 |
| `after/` | The same project migrated: Kotlin DSL, version catalog, configuration-cache-safe custom task, wrapper on Gradle 9.8.0 |
| `scripts/run-all.sh` | Regenerates everything under `output/` (env vars `G8`, `G9`, `J21`, `J25` point to the tools) |
| `output/` | Captured transcripts, the only source for numbers and messages quoted in the post |
Tested with Gradle 8.14.3 (JDK 21) and Gradle 9.8.0 (JDK 25.0.4.1), Spring Boot 4.1.1, on 28 September 2026.
Quick start: `cd after && ./gradlew build --configuration-cache`.
+35
View File
@@ -0,0 +1,35 @@
plugins {
java
alias(libs.plugins.spring.boot)
alias(libs.plugins.dependency.management)
}
group = "com.ankurm"
version = "0.0.1"
tasks.withType<JavaCompile>().configureEach { options.release = 17 }
base { archivesName = "g9demo" }
repositories { mavenCentral() }
dependencies {
implementation(libs.starter.webmvc)
testImplementation(libs.starter.webmvc.test)
}
// Configuration-cache-safe: a typed task whose inputs are Property/Provider values,
// so nothing reaches back into the script or Project when the task executes.
abstract class BuildInfo : DefaultTask() {
@get:Input abstract val text: Property<String>
@get:OutputFile abstract val target: RegularFileProperty
@TaskAction fun write() { target.get().asFile.writeText(text.get()) }
}
tasks.register<BuildInfo>("buildInfo") {
val prefix = "${project.name} ${project.version} " // read at configuration time
text = providers.environmentVariable("BUILD_STAMP").orElse("local").map { "$prefix$it\n" }
target = layout.buildDirectory.file("build-info.txt")
}
tasks.named<Test>("test") { useJUnitPlatform() }
+11
View File
@@ -0,0 +1,11 @@
[versions]
spring-boot = "4.1.1"
dependency-management = "1.1.7"
[libraries]
starter-webmvc = { module = "org.springframework.boot:spring-boot-starter-webmvc" }
starter-webmvc-test = { module = "org.springframework.boot:spring-boot-starter-webmvc-test" }
[plugins]
spring-boot = { id = "org.springframework.boot", version.ref = "spring-boot" }
dependency-management = { id = "io.spring.dependency-management", version.ref = "dependency-management" }
Binary file not shown.
@@ -0,0 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.0-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored Executable
+248
View File
@@ -0,0 +1,248 @@
#!/bin/sh
#
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# gradlew start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh gradlew
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
+112
View File
@@ -0,0 +1,112 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem gradlew startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables, and ensure extensions are enabled
setlocal EnableExtensions
@rem Catch executions from older scripts and ensure they exit cleanly.
@rem This can be removed once we can be reasonably confident that few people
@rem will be migrating directly to this new wrapper.
goto afterSafetyNet
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto exitWithErrorLevel
:afterSafetyNet
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
1>&2 echo.
1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
1>&2 echo.
1>&2 echo Please set the JAVA_HOME variable in your environment to match the
1>&2 echo location of your Java installation.
"%COMSPEC%" /c exit 1
goto exitWithErrorLevel
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
1>&2 echo.
1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
1>&2 echo.
1>&2 echo Please set the JAVA_HOME variable in your environment to match the
1>&2 echo location of your Java installation.
"%COMSPEC%" /c exit 1
goto exitWithErrorLevel
:execute
@rem Setup the command line
@rem Execute gradlew
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
@rem which allows us to clear the local environment before executing the java command
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel & goto exitWithErrorLevel
@rem This label must not be changed. We rely on old scripts being able to jump to this point.
:exitWithErrorLevel
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
"%COMSPEC%" /c exit %ERRORLEVEL%
+1
View File
@@ -0,0 +1 @@
rootProject.name = "g9demo"
@@ -0,0 +1,15 @@
package com.ankurm.g9;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class G9Application {
public static void main(String[] args) { SpringApplication.run(G9Application.class, args); }
@GetMapping("/hello")
String hello() { return "hello"; }
}
@@ -0,0 +1,21 @@
package com.ankurm.g9;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.test.web.servlet.MockMvc;
@SpringBootTest
@AutoConfigureMockMvc
class G9ApplicationTest {
@Autowired MockMvc mvc;
@Test
void hello() throws Exception {
mvc.perform(get("/hello")).andExpect(content().string("hello"));
}
}
+31
View File
@@ -0,0 +1,31 @@
plugins {
id 'java'
id 'org.springframework.boot' version '4.1.1'
id 'io.spring.dependency-management' version '1.1.7'
}
group = 'com.ankurm'
version = '0.0.1'
sourceCompatibility = '17'
archivesBaseName = 'g9demo-legacy'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-webmvc'
testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
}
// Task that reads the project model and an environment variable while it EXECUTES
tasks.register('buildInfo') {
doLast {
def stamp = System.getenv('BUILD_STAMP') ?: 'local'
file("$buildDir/build-info.txt").text = "${project.name} ${project.version} ${stamp}\n"
}
}
tasks.named('test') {
useJUnitPlatform()
}
+1
View File
@@ -0,0 +1 @@
rootProject.name = 'g9demo'
@@ -0,0 +1,15 @@
package com.ankurm.g9;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class G9Application {
public static void main(String[] args) { SpringApplication.run(G9Application.class, args); }
@GetMapping("/hello")
String hello() { return "hello"; }
}
@@ -0,0 +1,21 @@
package com.ankurm.g9;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.test.web.servlet.MockMvc;
@SpringBootTest
@AutoConfigureMockMvc
class G9ApplicationTest {
@Autowired MockMvc mvc;
@Test
void hello() throws Exception {
mvc.perform(get("/hello")).andExpect(content().string("hello"));
}
}
+11
View File
@@ -0,0 +1,11 @@
$ gradle --version (Gradle 8)
Gradle 8.14.3
Kotlin: 2.0.21
Groovy: 3.0.24
Launcher JVM: 21.0.10 (Ubuntu 21.0.10+7-Ubuntu-124.04)
$ gradle --version (Gradle 9)
Gradle 9.8.0
Kotlin: 2.4.10
Groovy: 4.0.33
Launcher JVM: 25.0.4.1 (Eclipse Adoptium 25.0.4.1+1-LTS)
+14
View File
@@ -0,0 +1,14 @@
$ gradle build --warning-mode all # Gradle 8.14.3, JDK 21, legacy Groovy build
Build file 'WORK/a/build.gradle': line 9
The org.gradle.api.plugins.JavaPluginConvention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.14.3/userguide/upgrading_version_8.html#java_convention_deprecation
at build_dlrldupk0ke03lzjij3dzgrv1.run(WORK/a/build.gradle:9)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
Build file 'WORK/a/build.gradle': line 10
The org.gradle.api.plugins.BasePluginConvention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.14.3/userguide/upgrading_version_8.html#base_convention_deprecation
at build_dlrldupk0ke03lzjij3dzgrv1.run(WORK/a/build.gradle:10)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
Build file 'WORK/a/build.gradle': line 10
The BasePluginExtension.archivesBaseName property has been deprecated. This is scheduled to be removed in Gradle 9.0. Please use the archivesName property instead. For more information, please refer to https://docs.gradle.org/8.14.3/dsl/org.gradle.api.plugins.BasePluginExtension.html#org.gradle.api.plugins.BasePluginExtension:archivesName in the Gradle documentation.
at build_dlrldupk0ke03lzjij3dzgrv1.run(WORK/a/build.gradle:10)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
BUILD SUCCESSFUL
@@ -0,0 +1,5 @@
$ gradle build # Gradle 9.8.0, JDK 25, same legacy build, unchanged
Build file 'WORK/b/build.gradle' line: 9
* What went wrong:
> Could not set unknown property 'sourceCompatibility' for root project 'g9demo' of type org.gradle.api.Project.
BUILD FAILED
@@ -0,0 +1,5 @@
$ gradle build # after replacing sourceCompatibility = '17' with java { sourceCompatibility = ... }
Build file 'WORK/c/build.gradle' line: 10
* What went wrong:
> Could not set unknown property 'archivesBaseName' for root project 'g9demo' of type org.gradle.api.Project.
BUILD FAILED
@@ -0,0 +1,6 @@
$ gradle build buildInfo --warning-mode all # both removals fixed
Build file 'WORK/d/build.gradle': line 25
Invocation of Task.project at execution time has been deprecated. This will fail with an error in Gradle 10. This API is incompatible with the configuration cache, which will become the only mode supported by Gradle in a future release. Consult the upgrading guide for further information: https://docs.gradle.org/9.8.0/userguide/upgrading_version_7.html#task_project
at build_9kjx5jbekfxgd2u4kdta23gdc$_run_closure5$_closure7.doCall$original(WORK/d/build.gradle:25)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
BUILD SUCCESSFUL
@@ -0,0 +1,11 @@
$ gradle buildInfo --configuration-cache # same fixed legacy build
> Task :buildInfo FAILED
1 problem was found storing the configuration cache.
- Build file 'build.gradle': line 25: invocation of 'Task.project' at execution time is unsupported with the configuration cache.
[Incubating] Problems report is available at: file://WORK/d/build/reports/problems/problems-report.html
Build file 'WORK/d/build.gradle' line: 25
* What went wrong:
Execution failed for task ':buildInfo' (registered in build file 'build.gradle').
> Invocation of 'Task.project' by task ':buildInfo' at execution time is unsupported with the configuration cache.
BUILD FAILED
Configuration cache entry discarded with 1 problem.
@@ -0,0 +1,21 @@
$ ./gradlew buildInfo test --configuration-cache # migrated build, first run
> Task :buildInfo
> Task :testClasses
> Task :test
BUILD SUCCESSFUL
Configuration cache entry stored.
$ ./gradlew buildInfo test --configuration-cache # second run
Reusing configuration cache.
> Task :buildInfo UP-TO-DATE
> Task :testClasses UP-TO-DATE
> Task :test UP-TO-DATE
BUILD SUCCESSFUL
Configuration cache entry reused.
$ BUILD_STAMP=ci42 ./gradlew buildInfo --configuration-cache # env var changed
BUILD SUCCESSFUL
Configuration cache entry stored.
$ cat build/build-info.txt
g9demo 0.0.1 ci42
+10
View File
@@ -0,0 +1,10 @@
$ ./gradlew build # migrated build on the Gradle wrapper (9.8.0), tests included
> Task :bootJar
> Task :testClasses
> Task :test
BUILD SUCCESSFUL
7 actionable tasks: 7 executed
$ ls build/libs
g9demo-0.0.1-plain.jar
g9demo-0.0.1.jar
+10
View File
@@ -0,0 +1,10 @@
$ gradle build # Gradle 8.14.3 on JDK 25 (launcher JVM), migrated build
FAILURE: Build failed with an exception.
* What went wrong:
25.0.4.1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED
+60
View File
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
# Regenerates output/*.txt. Needs: G8 (Gradle 8.14.x), G9 (Gradle 9.x), J21 and J25 (JAVA_HOME dirs).
set -u
G8=${G8:-/opt/gradle/bin/gradle}; G9=${G9:-/tmp/tools/gradle-9.8.0/bin/gradle}
J21=${J21:-/usr/lib/jvm/java-21-openjdk-amd64}; J25=${J25:-/tmp/tools/jdk-25.0.4.1+1}
HERE=$(cd "$(dirname "$0")/.." && pwd); OUT=$HERE/output; W=${WORK:-/tmp/g9-work}
mkdir -p "$OUT"; rm -rf "$W"; mkdir -p "$W"
clean() { grep -v 'JAVA_TOOL_OPTIONS' | sed "s#$W#WORK#g; s#$HERE#REPO#g; s/ in [0-9msh ]*\$//; /^Daemon will be stopped/d; /^Starting a Gradle Daemon/d; /^See the complete report/d"; }
run() { # run <javahome> <dir> <gradle> args...
local jh=$1 d=$2 g=$3; shift 3; (cd "$d" && JAVA_HOME=$jh "$g" --console=plain "$@" 2>&1 | clean); }
fresh() { rm -rf "$W/$1"; cp -r "$HERE/before" "$W/$1"; rm -rf "$W/$1/build" "$W/$1/.gradle"; }
{ echo '$ gradle --version (Gradle 8)'; JAVA_HOME=$J21 $G8 --version 2>&1 | grep -E '^Gradle|^Launcher|^Kotlin|^Groovy'
echo; echo '$ gradle --version (Gradle 9)'; JAVA_HOME=$J25 $G9 --version 2>&1 | grep -E '^Gradle|^Launcher|^Kotlin|^Groovy'; } > "$OUT/00-environment.txt"
fresh a
{ echo '$ gradle build --warning-mode all # Gradle 8.14.3, JDK 21, legacy Groovy build'
run "$J21" "$W/a" "$G8" build --warning-mode all | grep -E 'deprecat|Deprecat|BUILD|build.gradle|Gradle 9|Gradle 10|Task.project' ; } > "$OUT/01-legacy-on-gradle8.txt"
fresh b
{ echo '$ gradle build # Gradle 9.8.0, JDK 25, same legacy build, unchanged'
run "$J25" "$W/b" "$G9" build | grep -E 'What went wrong|Could not|BUILD|build.gradle' ; } > "$OUT/02-legacy-on-gradle9-sourceCompatibility.txt"
fresh c
python3 - "$W/c/build.gradle" <<'PY'
import sys; p=sys.argv[1]; s=open(p).read()
s=s.replace("sourceCompatibility = '17'","java { sourceCompatibility = JavaVersion.VERSION_17 }"); open(p,'w').write(s)
PY
{ echo "\$ gradle build # after replacing sourceCompatibility = '17' with java { sourceCompatibility = ... }"
run "$J25" "$W/c" "$G9" build | grep -E 'What went wrong|Could not|BUILD|build.gradle' ; } > "$OUT/03-legacy-on-gradle9-archivesBaseName.txt"
fresh d
python3 - "$W/d/build.gradle" <<'PY'
import sys; p=sys.argv[1]; s=open(p).read()
s=s.replace("sourceCompatibility = '17'","java { sourceCompatibility = JavaVersion.VERSION_17 }")
s=s.replace("archivesBaseName = 'g9demo-legacy'","base { archivesName = 'g9demo-legacy' }"); open(p,'w').write(s)
PY
{ echo '$ gradle build buildInfo --warning-mode all # both removals fixed'
run "$J25" "$W/d" "$G9" build buildInfo --warning-mode all | grep -E 'deprecat|Deprecat|BUILD|Gradle 10|Task.project|build.gradle' ; } > "$OUT/04-legacy-fixed-on-gradle9.txt"
rm -rf "$W/d/build" "$W/d/.gradle"
{ echo '$ gradle buildInfo --configuration-cache # same fixed legacy build'
run "$J25" "$W/d" "$G9" buildInfo --configuration-cache | grep -E 'What went wrong|Task.project|BUILD|onfiguration cache|problem|build.gradle|FAILED' ; } > "$OUT/05-legacy-configuration-cache.txt"
rm -rf "$W/after"; cp -r "$HERE/after" "$W/after"; rm -rf "$W/after/build" "$W/after/.gradle"
{ echo '$ ./gradlew buildInfo test --configuration-cache # migrated build, first run'
run "$J25" "$W/after" "$W/after/gradlew" buildInfo test --configuration-cache | grep -E 'BUILD|onfiguration cache|Task :(buildInfo|test)'
echo; echo '$ ./gradlew buildInfo test --configuration-cache # second run'
run "$J25" "$W/after" "$W/after/gradlew" buildInfo test --configuration-cache | grep -E 'BUILD|onfiguration cache|Task :(buildInfo|test)'
echo; echo '$ BUILD_STAMP=ci42 ./gradlew buildInfo --configuration-cache # env var changed'
(cd "$W/after" && BUILD_STAMP=ci42 JAVA_HOME=$J25 ./gradlew --console=plain buildInfo --configuration-cache 2>&1 | clean | grep -E 'BUILD|onfiguration cache|input|BUILD_STAMP')
echo; echo '$ cat build/build-info.txt'; cat "$W/after/build/build-info.txt"; } > "$OUT/06-migrated-configuration-cache.txt"
{ echo '$ ./gradlew build # migrated build on the Gradle wrapper (9.8.0), tests included'
run "$J25" "$W/after" "$W/after/gradlew" clean build | grep -E 'BUILD|Task :(test|bootJar)|actionable'
echo; echo '$ ls build/libs'; ls "$W/after/build/libs"; } > "$OUT/07-migrated-build.txt"
{ echo '$ gradle build # Gradle 8.14.3 on JDK 25 (launcher JVM), migrated build'
(cd "$W/after" && JAVA_HOME=$J25 $G8 --console=plain build 2>&1 | clean | grep -vE '^$' | head -12); } > "$OUT/08-gradle8-on-jdk25.txt"
echo done