Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Maven ready for JDK9?

Today I tried the latest jdk9 Build 113 and tried to compile my project with the latest Maven 3.3.9

These are the commands (found partially via twitter)

export MVN_OPTS="-Dmaven.compiler.fork -Dmaven.compiler.executable=/somewhere/Downloads/jdk-9/bin/javac"
export JAVA_HOME="/somewhere/Downloads/jdk-9"
mvn clean install

But I get this error ... in short:

[WARNING] Error injecting: org.codehaus.plexus.archiver.jar.JarArchiver
java.lang.ExceptionInInitializerError
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(java.base@9-ea/Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(java.base@9-ea/NativeConstructorAccessorImpl.java:62)

...

at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
    at org.codehaus.plexus.archiver.zip.AbstractZipArchiver.<clinit>(AbstractZipArchiver.java:116)
    ... 89 more
[WARNING] Error injecting: org.apache.maven.plugin.jar.JarMojo
java.lang.ExceptionInInitializerError
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(java.base@9-ea/Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(java.base@9-ea/NativeConstructorAccessorImpl.java:62)

...

at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
    at org.codehaus.plexus.archiver.zip.AbstractZipArchiver.<clinit>(AbstractZipArchiver.java:116)
    ... 89 more

What is the correct maven configuration or parameters to use for JDK9?

$ mvn --version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /home/somewhere/Downloads/maven
Java version: 9-ea, vendor: Oracle Corporation
Java home: /home/somewhere/Downloads/jdk-9
Default locale: en_US, platform encoding: UTF-8
OS name: "linux",...
like image 269
Karussell Avatar asked Apr 12 '16 20:04

Karussell


People also ask

What is the minimum version of Java for Maven?

1 for LTS) requires Java 6 thus Maven jobs must be launched with a JDK >= 6. Jenkins >= 1.612 (1.625. 1 for LTS) requires Java 7 thus Maven jobs must be launched with a JDK >= 7.

Does Maven require JDK?

Maven needs a JDK, and not a JRE.

What compiler does Maven use?

The default Java compiler version used by Maven is Java 1.5 .

Is Apache a Maven?

Maven is a part of the Apache Software Foundation.


4 Answers

Here is the answer from one Maven PMC member (me):

No, it is not. Robert Scholte is working on it. Jigsaw and other stuff introduced a lot of changes. There is no official timeframe where full compat (Maven + official plugins) will be given.

The issue you see is actually not Maven but Plexus Archiver. Refer to their GitHub page. If you think you can add value, contact maven-dev mailing list.

Progress documentation: https://cwiki.apache.org/confluence/display/MAVEN/Java+9+-+Jigsaw

like image 178
Michael-O Avatar answered Oct 13 '22 11:10

Michael-O


Yes, it is ready now. Still some things in progress, but generally usable. Check out a project of mine as example.

like image 16
King Nike Avatar answered Oct 13 '22 11:10

King Nike


Update: should work without this workaround now.

The problem is already fixed from the plexus archiver team, but not yet released - thanks to Michael-O for pointing me to the right place :) !

Now there is a workaround posted from ctomc in PR 12 to use an old plexus archiver version 2.4.4.:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.4.1</version>                    
    <dependencies>
        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-archiver</artifactId>
            <version>2.4.4</version>
        </dependency>
    </dependencies>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.6</version>
    <dependencies>
        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-archiver</artifactId>
            <version>2.4.4</version>
        </dependency>
    </dependencies>
</plugin>
like image 12
Karussell Avatar answered Oct 13 '22 12:10

Karussell


The Java doc plugin still have issues in the last version. (3.0.0.M1)

like image 1
petertc Avatar answered Oct 13 '22 13:10

petertc