java-library-template icon indicating copy to clipboard operation
java-library-template copied to clipboard

Use JVM Toolchain

Open StefMa opened this issue 1 year ago • 3 comments

❓ Type of change

  • [ ] 📖 Documentation (updates to the documentation, readme or JSdoc annotations)
  • [ ] 🐞 Bug fix (a non-breaking change that fixes an issue)
  • [ ] 👌 Enhancement (improving an existing functionality like performance)
  • [ ] ✨ New feature (a non-breaking change that adds functionality)
  • [x] 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description, Motivation and Context

This PR moves the JVM Version selection from the machine to the build time. With that change, Gradle makes sure that the code will be compiled with the configured JVM ersion (21) from the configured vendor (Corretto/Amazon). There is "no need" to install a specific JVM version on CI or your dev machine. You only need "a" JVM installation that can start Gradle. Gradle will detect that the configuration say it should compile the code with Java 21/Corretto, it will install the respective toolchain and use that to compile the code and run tests with that.

More information can also be found here: https://docs.gradle.org/8.6/userguide/toolchains.html

🧪 How Has This Been Tested?

Remove your locally installed JVM version (21/Corretto). Then use another JVM version and kick of Gradle (./gradlew check). Wihin the configuration phase you will see an output like this: Screenshot 2024-03-07 at 9 02 37 AM Indicating that the requested toolchain (was donwloaded) and now installing on the machine for later usage.

📝 Checklist

  • [ ] I have linked an issue or discussion.
  • [ ] I have updated the documentation accordingly.

StefMa avatar Mar 07 '24 08:03 StefMa

Thanks, @StefMa, for submitting this PR! I'll need to look closer at the gradle docs. But at first glance, this seems like a valid and useful addition.

hartmut-co-uk avatar Mar 07 '24 18:03 hartmut-co-uk

Hey @hartmut-co-uk, any chance to have a look at this?

StefMa avatar May 25 '24 15:05 StefMa

So the data volumes written and read from cache is higher, also the JDK is downloaded with each and every workflow run.

I don't get this 🤔 Is it now downloaded or is it written into the cache? Or is it written to cache but additionally downloaded? 😱

Normally, it should write it to the cache but not downloading again (but fetched from cache). I'm not that familiar with the gradle/actions/setup-gradle action. However, I guess it should handle the jdk toolchain cache correctly 🤔

StefMa avatar Jun 09 '24 17:06 StefMa