Add Maven Toolchains Declaration (#276) by Okeanos · Pull Request #282 · actions/setup-java (original) (raw)

@brcrista I setup a minimal project with pipelines that are hopefully self-descriptive here: https://github.com/Okeanos/setup-java-example/actions

It appears that Gradle benefits less from this PR on GitHub Actions than anticipated from Gradle#14903 even for e.g. Gradle 7.3 which did not support Maven Toolchains detection.

Some jobs, such as the Java 8 and 11 are supposed to fail (technically, even for Gradle but it has auto-detection that works on GitHub Actions and for some reason matrix builds behave different from what I expected) because no valid JDK was found/supposed to be available/configured and the toolchains requirements in the pom.xml and build.gradle enforce an exact version requirement.

I also found and fixed a bug in my implementation and improved the tests as well. Asking for in-depth examples was a good idea ❤️ .

Additionally, I discovered that the outputs.java-version value from the setup-java task is actually incompatible with Toolchains declarations because it is the exact version (as evident in the Job called Java Default Actions sample step Show Toolchains (Debug) whereas the Java version for major releases is required (as used in the setup-java.inputs.java-version. Even the distribution value is … not really good. I would have expected temurin to be the value not Temurin-Hotspot; distribution is special because we can filter by vendor within Maven builds and "Temurin-Hotspot" isn't a vendor … "Temurin" could be interpreted as one; technically correct would probably be Eclipse Temurin for this example (and is reported by Gradle as well).

If you have any further questions or need better examples (for an arbitrary value of "better") please let me know.