Hi,

I have been using the Maven Toolchains plugin ( 
https://maven.apache.org/plugins/maven-toolchains-plugin/index.html )
for a while now.

Before the 3.2.0 release I created my personal toolchains.xml with definitions 
looking like this:

```xml
 <toolchain>
   <type>jdk</type>
   <provides>
     <version>17</version>
     <vendor>Adoptium</vendor>
   </provides>
   <configuration>
     
<jdkHome>/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home</jdkHome>
   </configuration>
 </toolchain>
```

This works quite well when using the Maven Toolchains plugin and a 
configuration looking like this in my pom.xml:

```xml
<configuration>
 <toolchains>
   <jdk>
     <version>${java.version}</version>
   </jdk>
 </toolchains>
</configuration>
```

The java.version property is just a reference to `21` (and used in e.g. the 
compiler settings to target the feature level).
Works well for my intended purposes of having multiple JDKs installed in 
parallel, is easy to handle, and overall a decent
experience when trying to keep project requirements in sync across machines.

With Maven Toolchains 3.2.0 auto discovery was added. A very nice and welcome 
feature, however, I am at a loss as to
replicate my previous simple configuration without pulling in additional 
plugins etc. The auto-generated toolchain that
is the result of the auto-discovery makes the major feature version of the JDK 
not accessible! Instead it looks like this:

```xml
<provides>
 <vendor.version>Temurin-21.0.3+9</vendor.version>
 <lts>true</lts>
 <runtime.name>OpenJDK Runtime Environment</runtime.name>
 <version>21.0.3</version>
 <vendor>Eclipse Adoptium</vendor>
 <runtime.version>21.0.3+9-LTS</runtime.version>
</provides>
```

The documentation is also not very helpful and only explains some basics. 
Actual/real word use cases and how I as a
user am supposed to achieve them are not described as best as I can tell.

Hence, I created a repository ( 
https://github.com/Okeanos/maven-toolchains-exploration ) that shows what I 
tried in
order to understand how auto-discovery and self-managed toolchains work 
(together).

I'd be greatful for a response explaining how I am supposed to properly use the 
auto-generated toolchains in order
to target feature releases (e.g. 11, 13, 21, …) of JDKs as simple as possible. 
If you need further information from me
in order to help, please let me know!

Thanks,
Nikolas

P.S.: Apologies if this shows up twice in the mailing list (at some point). I 
sent a first version of this without having
signed-up to the list first (not knowing that I better do that to not get stuck 
in the moderation queue).
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to