From the maven-toolchain-plugin documentation:
A Toolchain is an object that Maven plugins can use to retrieve preconfigured tools (including location and other information). With the jdk toolchain, for example, instead of being stuck with the JDK used to run Maven, all plugins can use the same or other JDK instances without hardcoding absolute paths into the pom.xml and without configuring every plugin that require a path to JDK tools.
Toolchains are used in different maven modules to ensure that the correct Java compiler version is used when compiling source files. This is because Datasketches Memory uses some JDK version-specific APIs, which require different JDKs to compile correctly.
Your local environment requires toolchain entries for Java 8 and 11 to build this project.
These can be found in a reference toolchains.xml
template in the tools
directory. Any maven commands used during development can be supplemented with: --toolchains tools/toolchains.xml
, without permanently modifying the local ~/.m2/toolchains.xml
file.
Alternatively, to avoid having to add this extra argument to every Maven command, the toolchain template can be copied to your local maven toolchains.xml
, e.g. ~/.m2/toolchains.xml
. If there is already a locally configured toolchains.xml
file, the requisite entries should be merged into the existing file if they do not already exist.
In order to compile the project using Maven toolchains, the following environment variables should be set as follows:
Environment variable | Value |
---|---|
JAVA8_HOME | Home directory for Java 8 (openJDK) |
JAVA11_HOME | Home directory for Java 11 (openJDK) |
For example, if you are using SDKMAN!, your environment might be configured as follows:
/Users/me/.sdkman/candidates/java/8.0.282.hs-adpt
/Users/me/.sdkman/candidates/java/11.0.10.hs-adpt
Users can discover what JDKs have been loaded into their environment by using the following command:
/usr/libexec/java_home -V
If you are an Eclipse user, you may need further configuration for your IDE to use the appropriate JDK for each module - see the Eclipse IDE Setup.
Similarly, if you are an IntelliJ user, you may need further configuration for your IDE to use the appropriate JDK for each module - see the IntelliJ IDE Setup.