jpmsnewbie
jpmsnewbie

Reputation: 145

Fatal error compiling: Failed to run the ecj compiler: Unrecognized option : --module-version

Trying to run the following combination:

Fails with the following error message:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project tourconex: Fatal error compiling: Fa
iled to run the ecj compiler: Unrecognized option : --module-version -> [Help 1]

Have tried to add blank compilerArgs node, but without avail.

Removing module-info.java fixes the problem, but that's not what I want.

Also, looked at the source http://central.maven.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.8.1/

specifically at the source of CompilerMojo.java:

module-version is always added, so it seems there's no way to suppress it:

compilerArgs.add( "--module-version" );
compilerArgs.add( getProject().getVersion() );

Looking at the documentation of ecj, there's no "module-version" argument

https://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-using_batch_compiler.htm

So it seems that it just won't work at the moment!?

Maven Plugin section:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
        <compilerId>eclipse</compilerId>
        <source>11</source>
        <target>11</target>
        <release>11</release>
        <showWarnings>true</showWarnings>
        <showDeprecation>true</showDeprecation>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-compiler-eclipse</artifactId>
            <version>2.8.5</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jdt</groupId>
            <artifactId>ecj</artifactId>
            <version>3.17.0</version>
        </dependency>
    </dependencies>
</plugin>

Upvotes: 0

Views: 881

Answers (2)

Stephan Herrmann
Stephan Herrmann

Reputation: 8178

Until now ecj does not support the option --module-version.

It may have fallen through the cracks for several possible reasons:

  • nobody cared, because the module version is not evaluated by JVM nor other tools
  • perhaps it wasn't specified as a new compiler option before Java 9 GA (http://openjdk.java.net/jeps/261 does not have a version history, but I know that the text was changed significantly right on the release day).

Please file a feature request at https://bugs.eclipse.org/bugs/enter_bug.cgi?product=JDT

Edit: Your feature request has been implemented. While we missed today's release of Eclipse 2019-06, you may fetch ecj.jar from the next integration build below https://download.eclipse.org/eclipse/downloads/index.html - next full release is scheduled for September.

Edit2: After more research the simplest workaround might be to go back to version 3.8.0 of maven-compiler-plugin which does not try to pass --module-version to the compiler. This happens only since 3.8.1 released this May.

Upvotes: 0

jpmsnewbie
jpmsnewbie

Reputation: 145

Opened issue / feature request on eclipse.org: https://bugs.eclipse.org/bugs/show_bug.cgi?id=548195

Upvotes: 0

Related Questions