-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Guillaume Nodet opened MTOOLCHAINS-49 and commented
Add mojos to:
- display a human readable list of discovered JDK toolchains
- generate the toolchains.xml file for discovered JDK toolchains
- select a JDK toolchain with specific behaviour if the current JDK fulfils the requirements
The generation of the toolchains.xml file is not necessary to use discovered toolchains. The select-jdk-toolchain will select a toolchain amongst explicitely configured toolchains and discovered toolchains. The information for discovered toolchains are cached in ~/.m2/discovered-toolchains-cache.xml file by default.
The select-jdk-toolchain config below allows using the current JDK, or any other discovered JDK >= 17. The benefit is that the current JDK can be kept for speed, but ensuring the usage of any JDK 17 or higher if the current jdk is below the requirements.
<profile>
<id>toolchains</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>3.1.1-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>select-jdk-toolchain</goal>
</goals>
<configuration>
<version>[17,)</version>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
The display-discovered-jdk-toolchains shows human readable discovered JDKs:
> mvn org.apache.maven.plugins:maven-toolchains-plugin:3.1.1-SNAPSHOT:display-discovered-jdk-toolchains
...
[INFO] Discovered 13 JDK toolchains:
[INFO] - /Users/gnodet/.sdkman/candidates/java/21.ea.22-open
[INFO] provides:
[INFO] vendor: Oracle Corporation
[INFO] runtime.version: 21-ea+22-1890
[INFO] runtime.name: OpenJDK Runtime Environment
[INFO] version: 21-ea
...
while the generate-jdk-toolchains-xml will write the output in xml format:
> mvn org.apache.maven.plugins:maven-toolchains-plugin:3.1.1-SNAPSHOT:generate-jdk-toolchains-xml
...
<?xml version="1.0" encoding="UTF-8"?>
<toolchains xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 http://maven.apache.org/xsd/toolchains-1.1.0.xsd" xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<toolchain>
<type>jdk</type>
<provides>
<vendor>Oracle Corporation</vendor>
<runtime.version>21-ea+22-1890</runtime.version>
...
Remote Links:
1 votes, 3 watchers