Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolchains jdk substitution #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cpfeiffer
Copy link

We have the desire to ensure that the Maven toolchains.xml uses the JDK installations configured in Jenkins. E.g. the JDK that is used to start a Maven job shall also be available in the toolchains.xml.

Unfortunately it is not possible to simply add Jenkins's JDK tools automatically to toolchains.xml, since it is not possible to infer the JDK version from a JDK tool (there's just the name and the jdkHome available).

So we took a simple approach of letting the user configure a template for the toolchains.xml with JDKs already preconfigured, except for the jdkHomes. When generating the toolchains.xml, we simply look up the toolchain in the template (matching a JDK tool name) and set the jdkHome for it.

WDYT?

@cpfeiffer
Copy link
Author

Looks like I forgot to git add the testcase in the second commit.
I'll submit an updated PR next week, with an additional option to remove inexistant JDKs from the toolchain (since the maven-toolchain-plugin fails the build when a jdk toolchain is configured and the directory does not exist).

The idea is to provide one or more Jenkins-wide file templates for
toolchains.xml.

The template contains preconfigured jdk toolchain entries with an id
that is equal to Jenkins's JDK tool configuration.

In the toolchains.xml template, these entries are adjusted to use the
javaHome from Jenkins's JDK tool.

If there are multiple JDK installations for the same java version in the
template, Maven can reference the desired one by id.

If Jenkins's JDK tools cannot be found in the toolchains.xml template,
they are not added to the toolchains.xml and a warning is printed per
JDK tool.

Finally, there is a new option "Remove unavailabe JDK toolchains".
This will check the toolchains.xml for JDK toolchains and remove all those
where the jdkHome does not exist (on the target node). This is to avoid
Maven failing due to inexistant toolchains, e.g. when there are many
JDKs defined on the Jenkins, but not all of them available on the build nodes.
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