diff --git a/AGENTS.md b/AGENTS.md index aef708e4e..a3560a114 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,6 +5,8 @@ Before preparing or publishing a release, read [`release.md`](release.md) completely. It is the authoritative release procedure and credential guide. - Run Gradle on Java 17 or newer. The modules are compiled with a Java 8 toolchain, so the setup JAR runs on Java 8 and newer. Do not run Gradle itself on Java 8. +- The tests are compiled and run with Java 17 or newer, as JUnit 6 needs it, so no automated test runs on Java 8. +- Always try the built Robocode on Java 8 and on the newest Java before publishing, as described in Step 4 of `release.md`. `./gradlew release` publishes right after building, so do it before running that task. - `./gradlew release` performs the local release flow: pre-flight checks, build, Maven Central publishing, Chocolatey publishing on Windows, GitHub Release creation, SourceForge publishing (setup JAR, README.md, default download, and `version.html`), and the blog post HTML. A failing step does not stop the independent steps, and a summary at the end lists the results and the manual steps (posting on Blogger and SourceForge news). - With the local release, push `main` but not the version tag. `gh release create` makes the tag on GitHub; pushing the tag first starts the release workflow, which publishes too. - Docker publishing is deliberately separate from the release task. Publish the RoboRumble image (`zamboch/roborumble`) with `./gradlew dockerPush` only when it is explicitly required. diff --git a/buildSrc/src/main/kotlin/net.sf.robocode.java-conventions.gradle.kts b/buildSrc/src/main/kotlin/net.sf.robocode.java-conventions.gradle.kts index 7696bf62d..f7fbb04fc 100644 --- a/buildSrc/src/main/kotlin/net.sf.robocode.java-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/net.sf.robocode.java-conventions.gradle.kts @@ -23,10 +23,22 @@ java { } } +// The product runs on Java 8, but JUnit 6 needs Java 17, so only the tests are compiled and run with Java 17 or newer +val testJavaLanguageVersion = 17 + +configurations.matching { it.name == "testCompileClasspath" || it.name == "testRuntimeClasspath" }.configureEach { + attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, testJavaLanguageVersion) +} + tasks { withType { options.encoding = "UTF-8" } + named("compileTestJava") { + javaCompiler.set(javaToolchains.compilerFor { + languageVersion.set(JavaLanguageVersion.of(testJavaLanguageVersion)) + }) + } // Robot battle tests are timing-sensitive and can intermittently report transient // engine errors (e.g. "Unable to stop thread") on slow/loaded CI machines. // Retry failed tests a few times so such flakiness does not fail the build. @@ -37,13 +49,12 @@ tasks { maxFailures.set(20) failOnPassedAfterRetry.set(false) } - // Run tests on another Java version than the Java 8 toolchain, e.g. -PtestJavaVersion=25, + // Run tests on another Java version than Java 17, e.g. -PtestJavaVersion=25, // as robot security works differently on Java 24+ where the SecurityManager is removed. - providers.gradleProperty("testJavaVersion").orNull?.let { version -> - javaLauncher.set(javaToolchains.launcherFor { - languageVersion.set(JavaLanguageVersion.of(version)) - }) - } + val version = providers.gradleProperty("testJavaVersion").orNull ?: testJavaLanguageVersion.toString() + javaLauncher.set(javaToolchains.launcherFor { + languageVersion.set(JavaLanguageVersion.of(version)) + }) } } diff --git a/gradle/test-libs.versions.toml b/gradle/test-libs.versions.toml index aefb3fcc8..e5fc3272a 100644 --- a/gradle/test-libs.versions.toml +++ b/gradle/test-libs.versions.toml @@ -1,7 +1,7 @@ [versions] -junit = "5.14.4" -junit-platform = "1.14.4" +junit = "6.1.3" +junit-platform = "6.1.3" hamcrest = "3.0" [libraries] diff --git a/release.md b/release.md index 4293b5ab7..26ba06f8b 100644 --- a/release.md +++ b/release.md @@ -23,6 +23,9 @@ Docker push is not included — run `./gradlew dockerPush` separately if needed. LiteRumble must be told about the new version separately (see [Step 1](#step-1--bump-the-version)). +Always build and try Robocode before running `./gradlew release`, which publishes right after building +(see [Step 4](#step-4--build-all-artifacts)). + --- **Option B — fully automated** @@ -214,6 +217,16 @@ newer. A JDK 8 must be installed, so Gradle can detect it; check with `./gradlew `versions.md` is included in the setup JAR, so set the release date in `versions.md` before building the release. +**Always try the build before publishing anything.** The automated tests cannot run on Java 8, as JUnit 6 needs Java 17, +and they do not show whether the application itself works. Unpack the setup JAR in an empty folder, e.g. with +`jar xf robocode-{version}-setup.jar`, and start `robocode.bat` or `robocode.sh`, both on Java 8 and on the newest Java: + +1. Run a battle until the results are shown. +2. Compile a new robot in the Robot Editor, and run it in a battle. On Java 8, this needs the JDK. +3. Check the console window for errors. + +Do not publish if any of this fails. + ### Step 5 — Publish to Maven Central Stage and release in one step: diff --git a/robocode.content/src/main/resources/ReadMe.html b/robocode.content/src/main/resources/ReadMe.html index 6c73b94ec..cad4ee3b9 100644 --- a/robocode.content/src/main/resources/ReadMe.html +++ b/robocode.content/src/main/resources/ReadMe.html @@ -91,8 +91,9 @@

HISTORY OF ROBOCODE

SYSTEM REQUIREMENTS

To run Robocode, Java 8 or a newer version must be installed on your system. Both the Java Runtime Environment (JRE) and the Java Developer Kit (JDK) can be used. Note that the JRE does not include the standard Java compiler (javac) which - comes with the JDK. However, Robocode comes with a built-in compiler ECJ (Eclipse Compiler for Java). - Hence, it is sufficient to run Robocode with the JRE only.

+ comes with the JDK. However, Robocode comes with a built-in compiler ECJ (Eclipse Compiler for Java), which needs + Java 17 or newer. Hence, the JRE is enough to run Robocode, and with Java 17 or newer also to compile robots in the Robot + Editor. To compile robots with an older version of Java, use the JDK.

Also, note that it is important that these environment variables have been set up before running Robocode: