You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "b. ohnsorg (Jira)" <ji...@apache.org> on 2022/06/21 15:59:00 UTC

[jira] [Updated] (MJAR-289) Support toolchain

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

b. ohnsorg updated MJAR-289:
----------------------------
    Description: 
# Configure a toolchain to use a more recent JDK, e.g. 17
 # run mvn clean install with a different (older) JDK, e.g. 11
 # maven-jar-plugin bails out with exit code other than 0 from jar command

 

It seems very likely (see MJAR-62) that this plugin doesn't support toolchains at all. Since packaging as JAR is a basic operation this has to work out of the box, when using toolchains.

 

Instead current version of maven-jar-plugin runs a jar command that does not create a JAR. Since compilation takes place based on toolchain class files are of format version 61. This is incompatible with the jar command from a JDK 11.

 
{code:java}
[…]
[INFO] --- maven-compiler-plugin:3.9.0:testCompile (default-testCompile) @ jpianotrain-core ---
[INFO] Toolchain in maven-compiler-plugin: JDK[/opt/jdk-17.0.2/]
[…]
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ jpianotrain-core ---
[INFO] Toolchain in maven-surefire-plugin: JDK[/opt/jdk-17.0.2/]

[…]
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ jpianotrain-core ---
[INFO] Building jar: /home/onkobu/svn/jpianotrain/trunk/jpianotrain-core/target/jpianotrain-core-0.0.4-SNAPSHOT.jar
java.lang.module.InvalidModuleDescriptorException: Unsupported major.minor version 61.0
    at java.base/jdk.internal.module.ModuleInfo.invalidModuleDescriptor(ModuleInfo.java:1091)
    at java.base/jdk.internal.module.ModuleInfo.doRead(ModuleInfo.java:195)
    at java.base/jdk.internal.module.ModuleInfo.read(ModuleInfo.java:147)
    at java.base/java.lang.module.ModuleDescriptor.read(ModuleDescriptor.java:2553)
    at jdk.jartool/sun.tools.jar.Main.addExtendedModuleAttributes(Main.java:2084)
    at jdk.jartool/sun.tools.jar.Main.update(Main.java:1018)
    at jdk.jartool/sun.tools.jar.Main.run(Main.java:366)
    at jdk.jartool/sun.tools.jar.JarToolProvider.run(JarToolProvider.java:37)
    at java.base/java.util.spi.ToolProvider.run(ToolProvider.java:137)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.codehaus.plexus.archiver.jar.JarToolModularJarArchiver.postCreateArchive(JarToolModularJarArchiver.java:114)
    at org.codehaus.plexus.archiver.AbstractArchiver.createArchive(AbstractArchiver.java:1066)
    at org.apache.maven.archiver.MavenArchiver.createArchive(MavenArchiver.java:676)
    at org.apache.maven.plugins.jar.AbstractJarMojo.createArchive(AbstractJarMojo.java:276)
    at org.apache.maven.plugins.jar.AbstractJarMojo.execute(AbstractJarMojo.java:307)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137){code}

  was:
# Configure a toolchain to use a more recent JDK, e.g. 17
 # run mvn clean install with a different (older) JDK, e.g. 11
 # maven-jar-plugin bails out with exit code other than 0 from jar command

 

It seems very likely (see MJAR-62) that this plugin doesn't support toolchains at all. Since packaging as JAR is a basic operation this has to work out of the box, when using toolchains.


> Support toolchain
> -----------------
>
>                 Key: MJAR-289
>                 URL: https://issues.apache.org/jira/browse/MJAR-289
>             Project: Maven JAR Plugin
>          Issue Type: Improvement
>            Reporter: b. ohnsorg
>            Priority: Major
>
> # Configure a toolchain to use a more recent JDK, e.g. 17
>  # run mvn clean install with a different (older) JDK, e.g. 11
>  # maven-jar-plugin bails out with exit code other than 0 from jar command
>  
> It seems very likely (see MJAR-62) that this plugin doesn't support toolchains at all. Since packaging as JAR is a basic operation this has to work out of the box, when using toolchains.
>  
> Instead current version of maven-jar-plugin runs a jar command that does not create a JAR. Since compilation takes place based on toolchain class files are of format version 61. This is incompatible with the jar command from a JDK 11.
>  
> {code:java}
> […]
> [INFO] --- maven-compiler-plugin:3.9.0:testCompile (default-testCompile) @ jpianotrain-core ---
> [INFO] Toolchain in maven-compiler-plugin: JDK[/opt/jdk-17.0.2/]
> […]
> [INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ jpianotrain-core ---
> [INFO] Toolchain in maven-surefire-plugin: JDK[/opt/jdk-17.0.2/]
> […]
> [INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ jpianotrain-core ---
> [INFO] Building jar: /home/onkobu/svn/jpianotrain/trunk/jpianotrain-core/target/jpianotrain-core-0.0.4-SNAPSHOT.jar
> java.lang.module.InvalidModuleDescriptorException: Unsupported major.minor version 61.0
>     at java.base/jdk.internal.module.ModuleInfo.invalidModuleDescriptor(ModuleInfo.java:1091)
>     at java.base/jdk.internal.module.ModuleInfo.doRead(ModuleInfo.java:195)
>     at java.base/jdk.internal.module.ModuleInfo.read(ModuleInfo.java:147)
>     at java.base/java.lang.module.ModuleDescriptor.read(ModuleDescriptor.java:2553)
>     at jdk.jartool/sun.tools.jar.Main.addExtendedModuleAttributes(Main.java:2084)
>     at jdk.jartool/sun.tools.jar.Main.update(Main.java:1018)
>     at jdk.jartool/sun.tools.jar.Main.run(Main.java:366)
>     at jdk.jartool/sun.tools.jar.JarToolProvider.run(JarToolProvider.java:37)
>     at java.base/java.util.spi.ToolProvider.run(ToolProvider.java:137)
>     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>     at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>     at org.codehaus.plexus.archiver.jar.JarToolModularJarArchiver.postCreateArchive(JarToolModularJarArchiver.java:114)
>     at org.codehaus.plexus.archiver.AbstractArchiver.createArchive(AbstractArchiver.java:1066)
>     at org.apache.maven.archiver.MavenArchiver.createArchive(MavenArchiver.java:676)
>     at org.apache.maven.plugins.jar.AbstractJarMojo.createArchive(AbstractJarMojo.java:276)
>     at org.apache.maven.plugins.jar.AbstractJarMojo.execute(AbstractJarMojo.java:307)
>     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137){code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)