I am porting some Java 8 code to Java 11 with module-system.
One jar contains the following module:
module de.powerstat.fb.generator
{
exports de.powerstat.fb.generator;
// ....
}
which is perfectly working. Now within another maven project I am referencing this jar/module within the pom:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<includeProjectDependencies>false</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
<executableDependency>
<groupId>de.powerstat.fb</groupId>
<artifactId>generator</artifactId>
</executableDependency>
<mainClass>de.powerstat.fb.generator/de.powerstat.fb.generator.CodeGenerator</mainClass>
<arguments>
<argument>${fb.hostname}</argument>
<argument>${fb.port}</argument>
<argument>${fb.username}</argument>
<argument>${fb.password}</argument>
<argument>${project.build.directory}</argument>
</arguments>
<cleanupDaemonThreads>false</cleanupDaemonThreads>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>de.powerstat.fb</groupId>
<artifactId>generator</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
When now doing a
mvn clean install
this results in a NullPointerException:
...
Caused by: java.lang.NullPointerException
at org.codehaus.mojo.exec.AbstractExecMojo.findExecutableArtifact (AbstractExecMojo.java:277)
at org.codehaus.mojo.exec.ExecJavaMojo.determineRelevantPluginDependencies (ExecJavaMojo.java:606)
at org.codehaus.mojo.exec.ExecJavaMojo.addRelevantPluginDependenciesToClasspath (ExecJavaMojo.java:539)
at org.codehaus.mojo.exec.ExecJavaMojo.getClassLoader (ExecJavaMojo.java:492)
at org.codehaus.mojo.exec.ExecJavaMojo.execute (ExecJavaMojo.java:273)
...
When commenting out now the following part:
<!--
<executableDependency>
<groupId>de.powerstat.fb</groupId>
<artifactId>generator</artifactId>
</executableDependency>
-->
Then the error changes to:
Caused by: java.lang.module.ResolutionException: Modules xml.apis and xercesImpl export package org.w3c.dom.html to module maven.model
at java.lang.module.Resolver.resolveFail (Resolver.java:885)
at java.lang.module.Resolver.failTwoSuppliers (Resolver.java:797)
at java.lang.module.Resolver.checkExportSuppliers (Resolver.java:718)
at java.lang.module.Resolver.finish (Resolver.java:362)
at java.lang.module.Configuration.<init> (Configuration.java:141)
at java.lang.module.Configuration.resolve (Configuration.java:424)
at java.lang.module.Configuration.resolve (Configuration.java:256)
at org.codehaus.mojo.exec.LoaderFinder.find (LoaderFinder.java:54)
at org.codehaus.mojo.exec.ExecJavaMojo.getClassLoader (ExecJavaMojo.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo.execute (ExecJavaMojo.java:273)
So my question is, what could I do to fix this situation? Maybe I am doing something wrong? Or is it a bug in the plugin? If it is a bug within the plugin - is there some kind of workaround (because the plugin looks unmaintained)?
Just to let you know - I am using maven 3.6.3 on MacOS.
@Extension1:
Today when compiling with the above commented out code I got a different error message:
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default) on project gentr64: Execution default of goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java failed: Module sisu.inject.bean contains package org.sonatype.guice.asm, module sisu.inject.plexus exports package org.sonatype.guice.asm to sisu.inject.bean -> [Help 1]
So it looks more like a problem of the plugin or maybe of maven itself.
I guess that the problem might be that I am trying to execute a java class within a module and because maven is not modularized this fails? Maybe someone could confirm or falsify this theroy?
@Extension 2:
After removing the jacoco plugin from my pom, I got another different error:
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default) on project gentr64: Execution default of goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java failed: Module maven.core contains package org.apache.maven.plugin, module maven.plugin.api exports package org.apache.maven.plugin to maven.core -> [Help 1]