Skip to content

Compile the pre-26 NMS modules with JDK 21 through a toolchain - #177

Merged
Travja merged 1 commit into
devfrom
claude/nms-jdk-toolchains
Oct 23, 2026
Merged

Travja merged 1 commit into
devfrom
claude/nms-jdk-toolchains

Conversation

@Travja

@Travja Travja commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

This fixes the failed 1.2.0 release (run 40011583260).

What failed

BuildTools succeeded for every Spigot version. The deploy then failed compiling codex-nms-v1_20_1 on JDK 25:

spigot-1.20.1-R0.1-SNAPSHOT.jar(/net/minecraft/server/level/WorldServer.class): error: Cannot attach type annotations
  @javax.annotation.Nullable to net.minecraft.server.level.WorldServer.a:
  class file for com.mojang.datafixers.util.Pair not found

Since JDK 22, javac reads type annotations from the jars it compiles against, so it now needs classes those annotations reference. On the runner, datafixerupper wasn't on that module's classpath. The release runs on JDK 25 because Codex's main modules need WorldEdit/WorldGuard's Java 25 classes, but only the 26.x NMS modules need 25 themselves.

Change

  • codex-nms/pom.xml: the compiler picks its JDK through jdkToolchain = ${nms.jdk}, default 21. All NMS modules inherit this.
  • codex-nms-v26_2 and codex-nms-v26_3 set nms.jdk to 25, since their Spigot jars are Java 25 class files.
  • Maven itself still runs on JDK 25, so the main modules are unchanged.

The shared release workflow writes a toolchains.xml with the runner's JDK 21 and 25 (.github patch 0006, which also adds deployAtEnd). Without a toolchains.xml, as in a local build, the compiler just uses the JDK Maven runs on.

Before merging / re-running the release

  • .github patch 0006 is applied. Without the toolchains.xml it writes, the compiler falls back to JDK 25 and the release fails the same way.
  • The partial 1.2.0 upload is removed from repo.travja.dev releases: codex-parent, codex-bungee and codex-api 1.2.0. The failed run deployed those modules before it reached the broken one. The 1.2.0 tag was already removed by the workflow.

Testing

On a real Spigot 1.20.1 jar from BuildTools:

  • Reproduced the CI error: JDK 25, no toolchain, datafixerupper excluded from the classpath (as on the runner).
  • Same setup with a JDK 21 toolchain: the toolchain is picked (Toolchain in maven-compiler-plugin: JDK[…java-21…]) and the build succeeds. The delombok step still prints the message, but it's non-fatal and was already there.
  • codex-nms-v26_3 against the real 26.3 jar: compiles with the JDK 25 toolchain.
  • Without any toolchains.xml, both modules fall back to the running JDK instead of failing.

Generated by Claude Code

The first semver release of Codex failed in codex-nms-v1_20_1:

  spigot-1.20.1-R0.1-SNAPSHOT.jar(.../WorldServer.class): error: Cannot
  attach type annotations @javax.annotation.Nullable to WorldServer.a:
  class file for com.mojang.datafixers.util.Pair not found

Since JDK 22, javac reads type annotations from the jars it compiles
against, so it needs classes those annotations reference. On the CI
runner datafixerupper wasn't on the module's classpath. The build runs
on JDK 25 because the main modules need WorldEdit's Java 25 classes,
but only the 26.x NMS modules need 25 themselves.

codex-nms now selects the compiler JDK with jdkToolchain ${nms.jdk},
defaulting to 21, and the 26.2/26.3 modules set it to 25. The shared
release workflow writes a toolchains.xml for both JDKs. Without one, as
in a local build, the compiler falls back to the JDK Maven runs on.

Reproduced the CI error locally (JDK 25, no datafixerupper on the
classpath) and confirmed the 21 toolchain compiles that module. 26.3
compiles with the 25 toolchain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Secz6aiBJ7U8im8tnYhyLA
@Travja Travja added the build:patch label Oct 23, 2026 — with Claude
Travja pushed a commit to magemonkeystudio/.github that referenced this pull request Oct 23, 2026
The first semver release of Codex failed in its seventh NMS module, but
Maven had already deployed the modules built before it. That left
codex-parent, codex-bungee and codex-api 1.2.0 in the releases
repository without the rest of the release.

- Pass -DdeployAtEnd=true, so maven-deploy-plugin uploads only after
  every module has built. A failure partway through no longer leaves a
  partial release, and the workflow already removes the tag in that
  case.
- Write ~/.m2/toolchains.xml with the runner's JDK 21 and 25 before
  deploying, so modules can compile with a different JDK than Maven
  runs on. Codex's pre-26 NMS modules use the 21 toolchain
  (magemonkeystudio/codex#177), because javac on JDK 22+ rejects their
  Spigot jars. Projects without jdkToolchain configuration ignore it.

Tested locally: with deployAtEnd every module logs "Deferring deploy"
and nothing is uploaded before the last module finishes. The
toolchains snippet produces valid XML, including when a JDK is missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Secz6aiBJ7U8im8tnYhyLA
@Travja
Travja merged commit 6671ecf into dev Oct 23, 2026
2 of 3 checks passed
@Travja
Travja deleted the claude/nms-jdk-toolchains branch October 24, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants