Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java 9 modules test error

Tags:

java

maven

java-9

I have written Java 9 module application with maven and now I am trying to add test cases.

I have this error when I am trying to mvn clean install on whole project:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:testCompile (default-testCompile) on project EmployeeModule: Fatal error compiling: invalid flag: -Xmodule:EmployeeModule -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :EmployeeModule

Its weird because I can run this project in intellij without warning or error, I can also run tests in this module without errors.

I am using Java 9 from oracle site and Maven 3.5.0. Sorry, I can't tag it with java9.

like image 638
amkz Avatar asked Mar 08 '23 22:03

amkz


1 Answers

You should use the maven-compiler-plugin 3.7.0 The 3.6.x are based on older definitions of the module-class, so they've become useless when working with Java 9.

like image 87
Robert Scholte Avatar answered Mar 31 '23 03:03

Robert Scholte