[ 
https://issues.apache.org/jira/browse/MTOOLCHAINS-49?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Guillaume Nodet closed MTOOLCHAINS-49.
--------------------------------------
    Resolution: Fixed

> Automatic discovery of JDK toolchains
> -------------------------------------
>
>                 Key: MTOOLCHAINS-49
>                 URL: https://issues.apache.org/jira/browse/MTOOLCHAINS-49
>             Project: Maven Toolchains Plugin
>          Issue Type: Improvement
>            Reporter: Guillaume Nodet
>            Assignee: Guillaume Nodet
>            Priority: Major
>             Fix For: 3.2.0
>
>
> 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.
> {code}
>    <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>
> {code}
> The {{display-discovered-jdk-toolchains}} shows human readable discovered 
> JDKs:
> {code}
> > 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
> ...
> {code}
> while the {{generate-jdk-toolchains-xml}} will write the output in xml format:
> {code}
> > 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>
> ...
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to