Hello everyone,

I have a project consisting of several modules, one being a WAR module and one 
being an EAR module.
The EAR module has a dependency on the WAR module.

It turned out that I need the classes of that WAR module also as a JAR file for 
our UI project.
So I added a install-file goal for the maven-install-plugin and a deploy-file 
goal for the maven-deploy-plugin.
The WAR module build now creates the JAR file successfully and also deploys it.

But now my EAR module fails:
Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:3.0.2:ear 
(default-ear) on project XXX-ear: Cannot copy a directory: 
C:\XXX\XXX-pom\XXX-web\target\classes; Did you package/install 
XXX:XXX-web:war:1.0.18:compile? -> [Help 1]

I looked up the code of the maven-ear-plugin. It seems it the following line is 
the problem:
https://github.com/apache/maven-ear-plugin/blob/b289e6c271d50172c871e528105dda81d6f702b8/src/main/java/org/apache/maven/plugins/ear/EarMojo.java#L424
For some reason the file attribute of the Artifact object seems to contain the 
path to the classes directory if the JAR file is build.
If I uncomment the JAR file creation in the WAR module it seems it contains the 
WAR file path.

Things get even more interesting: When I created the JAR file, but build the 
WAR and the EAR independently (not by building the parent project), it works 
perfectly.
Seems something overwrites that information (the path of the WAR) and that 
information is kept also during the build step of the EAR file.

So I'm not sure what I'm doing wrong or how I can fix it.
Anyone faced a similar problem in the past?

Best regards,
Gerrit

Reply via email to