What about Maven toolchain plugin usage

21 views
Skip to first unread message

Markus Hoffrogge

unread,
Jul 17, 2024, 8:51:57 AM (5 days ago) Jul 17
to Jenkins Developers
Hi all,

just have joined this group by today - so maybe my question might have been discussed already but within a few minutes I could not find much on this - so would like to check on this topic within this group.

As far as I see the Jenkins CI infrastructure plugins build jobs are running for different Java JDK versions - currently for Java 17 and Java 21 as far as I could see.

On the other hand side the current POM is defining java level 11, BUT it is not making use of the Maven toolchain plugin.

IMHO this is not best practice, since the classes will be compiled to comply with the Java level defined by the POM, BUT the ompile reference to java runtime/bootstrap API is to the Java level of the JDK version running the Maven build job.

This implies the risk that code could make use of higher level Java APIs and would compile well, but if this code is running on a lower level java runtime matching the classes level signature it will fail, since that API does not exist in the lower level runtime.

For that reason Maven is providing the toolchain plugin.
The toolchain plugin enables to compile with the toolchain specified JDK version - which can differ from the Maven job runtime JDK.
Same for JUnit testing via surefire plugin.

Is there a reason why Jenkins POM definitions are not making use of it?

Kind regards
Markus

Ullrich Hafner

unread,
Jul 17, 2024, 9:59:33 AM (5 days ago) Jul 17
to Jenkins Developers
This implies the risk that code could make use of higher level Java APIs and would compile well, but if this code is running on a lower level java runtime matching the classes level signature it will fail, since that API does not exist in the lower level runtime.


Isn’t this picked up by JEP 247 in javac since Java 11? Or do you have an example that would break with our setup?

For that reason Maven is providing the toolchain plugin.
The toolchain plugin enables to compile with the toolchain specified JDK version - which can differ from the Maven job runtime JDK.
Same for JUnit testing via surefire plugin.

Is there a reason why Jenkins POM definitions are not making use of it?

Kind regards
Markus


--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/1569c8d2-8d74-4a5a-b4d8-4dbd49c39b9cn%40googlegroups.com.

Vincent Latombe

unread,
Jul 17, 2024, 11:07:27 AM (5 days ago) Jul 17
to jenkin...@googlegroups.com
Hi,

you should look up the `--release` flag available since Java 9 (which is what the Jenkins project uses).

Cheers,

Vincent


Markus Hoffrogge

unread,
Jul 17, 2024, 1:56:02 PM (5 days ago) Jul 17
to Jenkins Developers
You're right - that doesn't require it anymore. Did overlook this one.

Thanks for your responsive clarification!

Markus
Reply all
Reply to author
Forward
0 new messages