Skip to content

Build the plugin for Java 17, and test it with both formatter lines - #54

Open
abashev wants to merge 1 commit into
mainfrom
abashev/build-on-java-17
Open

abashev wants to merge 1 commit into
mainfrom
abashev/build-on-java-17

Conversation

@abashev

@abashev abashev commented Nov 29, 2026 •

Copy link
Copy Markdown

Before this PR

The plugin is compiled for Java 21, because open-java-format 21.x is, and CI, the release, CodeQL and the dependency submission build on JDK 21. A Maven build on JDK 17 to 20 cannot load the plugin, even with a formatter that runs there. CI tests one formatter version, the one Dependabot moves, and follow-releases.yml moves the README to the release GitHub marks Latest.

After this PR

  • java.version 17: the plugin's classes are Java 17. The release, CodeQL, the dependency submission and mise.toml use Temurin 17.
  • pom.xml holds one formatter version per line, open-java-format-17.version (17.1.0, the first release of the 17 line, A 17.X.X release line: the formatter and the Gradle plugin on Java 17, backported from 21.X.X open-java-format#293) and open-java-format-21.version (21.1.2). The profiles open-java-format-17 and open-java-format-21 pick one, and a build without a profile uses the 17 line, which runs on every JDK the plugin does. Profiles, because the integration tests take the version from the POM's properties: a -Dopen-java-format.version changes the compile classpath but does not reach them.
  • CI is a matrix of a JDK and a formatter line: the 17 line on JDK 17, the 21 line on JDK 21 and 25. The ruleset's required check build is now a job that waits for every leg, so the auto-merge of a new 21.x waits for JDK 21 and 25 too, and not for JDK 17 alone.
  • follow-releases.yml takes the highest published release of each line, not the one GitHub marks Latest, which a 17.x release never is. A new 21.x moves open-java-format-21.version and the README's examples in one pull request, so the README names it only once the plugin passed its tests with it. A new 17.x moves open-java-format-17.version on its own branch, follow-releases/open-java-format-17. The plugin's own releases move the README as before.
  • Dependabot leaves open-java-format alone: it knows one version only, and would move the 17 line to 21.x.
  • maven-plugin-plugin's requiredJavaVersion is ${java.version}. With auto, it took the Java version from the formatter's classes as well: with 21.0.2 it wrote 21 into plugin.xml, although every class of the plugin was compiled for 17, and Maven 4 would then refuse the plugin on JDK 17.
  • The README says Maven needs JDK 17 or newer, which JDK each formatter line needs, and how to build with each.

Checked locally:

  • -P open-java-format-21 on Temurin 21 and on OpenJDK 25: mvn verify passes, with 38 unit tests and 30 integration tests, and all 29 integration projects get 21.1.2. The jar's classes are class file version 61, and plugin.xml says 17.
  • On Temurin 17, -P open-java-format-17 fails only on resolving 17.1.0. The plugin built on 21 loads and runs on Temurin 17, and there it fails on 21.1.2 with UnsupportedClassVersionError, as it should.
  • The follow-releases.yml step script in catthehacker/ubuntu:act-24.04, with the real release lists, a local bare repository as origin and a stand-in gh for the pull requests: no new release on either line or for the plugin; a new 21.x, with a later 17.x published after it; the same run again; a new 17.x; only a lower 17.x; and a new plugin release.

Possible downsides?

  • open-java-format 17.1.0 is not on Maven Central yet, so the JDK 17 leg fails here, and with it build. Merge after 17.1.0 is released, and re-run the checks first. Merged earlier, it would fail every pull request, Dependabot's included.
  • The README's examples still show 2.27.0.2, which needs JDK 21, so the plugin should be released right after the merge.
  • The first scheduled follow-releases.yml run after the merge is the first real one with the new matrix; until 17.1.0 is out, the 17 job only says the line has no release yet.

@abashev
abashev force-pushed the abashev/build-on-java-17 branch 2 times, most recently from aec03d4 to 4a4cbef Compare November 29, 2026 09:37
The plugin was compiled for Java 21 because open-java-format 21.x is.
It is now compiled for 17, so it runs with the formatter's 17 line on
JDK 17 and with either line on JDK 21 and later.

- java.version 17; the release, CodeQL, the dependency submission and
  mise.toml on Temurin 17.
- pom.xml holds one version per formatter line, open-java-format-17.version
  and open-java-format-21.version, and a profile for each picks it. A
  build without a profile uses the 17 line.
- CI tests the 17 line on JDK 17 and the 21 line on JDK 21 and 25. The
  required check, build, waits for every leg.
- follow-releases.yml moves each line to the highest published release
  of that line, and the README's examples along with the 21 line.
  Dependabot leaves open-java-format alone.
- maven-plugin-plugin's requiredJavaVersion is java.version: "auto" took
  21 from the formatter's classes.
- The README names the JDK each formatter line needs.
@abashev
abashev force-pushed the abashev/build-on-java-17 branch from 4a4cbef to 3308adc Compare November 29, 2026 10:03
@abashev abashev changed the title Build and test the plugin on Java 17 Build the plugin for Java 17, and test it with both formatter lines Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant