-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Automatic discovery of JDK Toolchains #1129
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
Conversation
Why not using cross compilation with newest javac still supporting Java 8 bytecode? |
19acf20 to
b50e2d7
Compare
What do you mean exactly ? I may have missed something... |
Usually using |
Yes, if they are people are happy building with this option, they definitely don't need to use toolchains. My understanding is that when running tests, people quite like the tests to be run in the target environment. |
|
very interesting/nice feature! |
yes, that's taken care of ! |
|
The PR apache/maven-toolchains-plugin#14 provides a new mojo that displays the list of discovered toolchains. |
|
I'm planning to add better support for the current JDK toolchain. The selection of the toolchain by the mojo, in the case of the JDK toolchain, should take into account the current toolchain with several modes:
Also, the selection may be made slightly easier for the JDK toolchains, as the set of properties is kinda determined by the discovery mechanism, so a dedicated mojo may be needed for the JDK toolchain. The discovery could be stored to disk, at least the mapping between the jdk home and the properties, so that we don't have to launch all the JVMs to get the information. I also wonder if the jdk profile activation should use the toolchain. |
...hain-builder/src/main/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilder.java
Outdated
Show resolved
Hide resolved
...hain-builder/src/main/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilder.java
Outdated
Show resolved
Hide resolved
maven-toolchain-builder/src/main/java/org/apache/maven/toolchain/discovery/JavaHomeFinder.java
Show resolved
Hide resolved
...oolchain-builder/src/main/java/org/apache/maven/toolchain/discovery/JavaHomeFinderBasic.java
Show resolved
Hide resolved
|
I actually wonder if it would make more sense to move that code into the |
|
Given the way toolchains are defined and used in the code, there's no real reason to split the discovery process from the selection process, so I'm closing this PR in favour of apache/maven-toolchains-plugin#14 which adds 3 mojos to discover and display / generate an xml / select the toolchain. |
Currently, the need to support JDK 8 as a target kinda implies that maven itself needs to run with JDK 8. Toolchains are not easy to use and require a few manual steps.
This commit aims at reducing the burden of using toolchains so that maven get use JDK 11 as a requirement for running, but making it easy for users to target a different JDK.
The code currently adds automatic discovery of JDK on various platforms (though no WSL which looks quite complicated to support). The idea is also to see if the configuration of the toolchain plugin in the pom can also be simplified somehow.
This borrows code from IntelliJ Idea (which is ASL2).