error: option --module-path not allowed with target 1.8

error: option --module-path not allowed with target 1.8

When you set target 1.8, the flag --module-path seems to be added if a file `module-info.java` is present in your project. I came across it when running a javadoc target via a Maven project.

As Java 8 does not support modules, it doesn't make sense. Depending on the tools you are using, it might be able to detect modules and not add the flag anymore. If your tool doesn't support it, you can delete the module-info.java file:

find . -name 'module-info.java' -print -delete

Note though, that this can cause issues with building other packages (for example xxxx /module-info.java:[57,24] error: module not found: com.sun.xml.fastinfoset

So alternative option would be to set the build targets to Java 11 ( -Dtarget=11 ) or skip Javadoc build.

Note that SUSE has added a fix in xmvn-mojo that skips modular build. Red Hat implemented it in xmvn-mojo 4.2.0 :

https://issues.apache.org/jira/browse/MJAVADOC-575

https://github.com/fedora-java/xmvn/blob/master/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/JavadocMojo.java

https://build.opensuse.org/package/view_file/Java:packages/xmvn-mojo/0002-module-path-not-allowed-with-release-8.patch