Creating JAR file in WAR module leads to error in EAR creation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating JAR file in WAR module leads to error in EAR creation

g.hohl
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 | Threaded
Open this post in threaded view
|

AW: Creating JAR file in WAR module leads to error in EAR creation

g.hohl
Hello everyone,


maybe some additional information will be helpful.
The project structure is like (and also build in this order due to the dependencies of the modules):

- XXX-pom
  - XXX-ejb
  - XXX-web
  - XXX-ear

Here the excerpt from the pom.xml of the XXX-web module:

<project>
        <parent>
                <groupId>XXX</groupId>
                <artifactId>XXX-pom</artifactId>
                <version>1.0.18</version>
        </parent>
        <artifactId>XXX-web</artifactId>
        <packaging>war</packaging>
       
        <build>
                <plugins>
                        <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
    <webResources>
    <resource>
    <directory>${generated-webbapp-folder}</directory>
    </resource>
    </webResources>
    </configuration>
    </plugin>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <executions>
    <!-- Ensure that the JAR version ends up in the local repository -->
    <execution>
    <id>jar-install</id>
    <phase>install</phase>
    <goals>
    <goal>install-file</goal>
    </goals>
    <configuration>
    <file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
    <packaging>jar</packaging>
    <javadoc>${project.build.directory}/${project.artifactId}-${project.version}-javadoc.jar</javadoc>
    <sources>${project.build.directory}/${project.artifactId}-${project.version}-sources.jar</sources>
    </configuration>
    </execution>
    </executions>
    </plugin>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-deploy-plugin</artifactId>
    <executions>
    <!-- Ensure that the JAR version ends up in the remote repository -->
    <execution>
    <id>jar-deploy</id>
    <phase>deploy</phase>
    <goals>
    <goal>deploy-file</goal>
    </goals>
    <configuration>
    <file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
    <groupId>${project.groupId}</groupId>
    <artifactId>${project.artifactId}</artifactId>
    <version>${project.version}</version>
    <packaging>jar</packaging>
    <generatePom>false</generatePom>
    <javadoc>${project.build.directory}/${project.artifactId}-${project.version}-javadoc.jar</javadoc>
    <sources>${project.build.directory}/${project.artifactId}-${project.version}-sources.jar</sources>
    <repositoryId>${project.distributionManagement.repository.id}</repositoryId>
    <url>${project.distributionManagement.repository.url}</url>
    </configuration>
    </execution>
    </executions>
    </plugin>
                </plugins>
        </build>
</project>

And here the excerpt from the pom.xml of the XXX-ear module:

<project>
        <parent>
                <groupId>XXX</groupId>
                <artifactId>XXX-pom</artifactId>
                <version>1.0.18</version>
        </parent>
        <artifactId>XXX-web</artifactId>
        <packaging>war</packaging>
       
        <dependencies>
                <dependency>
                        <groupId>XXX</groupId>
                        <artifactId>XXX-web</artifactId>
                        <version>${project.version}</version>
                        <type>war</type>
                </dependency>
        </dependencies>
       
        <build>
                <plugins>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-ear-plugin</artifactId>
                                <configuration>
                                        <modules>
                                                <webModule>
                                                        <groupId>XXX</groupId>
                                                        <artifactId>XXX-web</artifactId>
                                                        <uri>XXX-web-${project.version}.war</uri>
                                                        <bundleFileName>XXX-web-${project.version}.war</bundleFileName>
                                                        <contextRoot>/XXX</contextRoot>
                                                        <bundleDir>/</bundleDir>
                                                </webModule>
                                        </modules>
                                </configuration>
                        </plugin>
                </plugins>
        </build>
</project>

The <webModule> specifies that the type of the artifact must be WAR.
So the maven-ear-plugin tries to match that against the artifacts of the project (means the <dependencies>).
And that also works.

But it seems that the maven-install-plugin and / or maven-deploy-plugin overwrite the file-path of the WAR at runtime of the Maven build in memory.
I don't know why and I also don't know how to prevent it.


Best regards,
Gerrit


-----Ursprüngliche Nachricht-----
Von: Hohl, Gerrit <[hidden email]>
Gesendet: Donnerstag, 12. November 2020 13:33
An: Maven Users List ([hidden email]) <[hidden email]>
Betreff: Creating JAR file in WAR module leads to error in EAR creation

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: AW: Creating JAR file in WAR module leads to error in EAR creation

Jörg Schaible
Am Donnerstag, 12. November 2020, 14:13:42 CET schrieb Hohl, Gerrit:

> Hello everyone,
>
>
> maybe some additional information will be helpful.
> The project structure is like (and also build in this order due to the
> dependencies of the modules):
>
> - XXX-pom
>   - XXX-ejb
>   - XXX-web
>   - XXX-ear

[snip]

You should not mix-up both artifacts for Maven. From Mavens PoV they are the
same (because they have the same G:A:V). Look at the configuration options for
the WAR plugin. You can generate automatically a jar file for the classes with
an own classifier which is automatically attached. Use that one to refer in
your EAR build.

Cheers,
Jörg



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: AW: Creating JAR file in WAR module leads to error in EAR creation

Karl Heinz Marbaise-3
In reply to this post by g.hohl
Hi,

On 12.11.20 14:13, Hohl, Gerrit wrote:
> Hello everyone,
>
>
> maybe some additional information will be helpful.
> The project structure is like (and also build in this order due to the dependencies of the modules):
>
> - XXX-pom
>    - XXX-ejb


My assumption is that ejb project uses packaging: ejb?
Where is the ejb module used? And how?

Which version of maven-ejb-plugin have you defined in your build?




>    - XXX-web
>    - XXX-ear
>
> Here the excerpt from the pom.xml of the XXX-web module:
>
> <project>
> <parent>
> <groupId>XXX</groupId>
> <artifactId>XXX-pom</artifactId>
> <version>1.0.18</version>
> </parent>
> <artifactId>XXX-web</artifactId>
> <packaging>war</packaging>
>
> <build>
> <plugins>
> <plugin>
>       <groupId>org.apache.maven.plugins</groupId>
>       <artifactId>maven-war-plugin</artifactId>
>       <configuration>
>       <webResources>
>       <resource>
>       <directory>${generated-webbapp-folder}</directory>
>       </resource>
>       </webResources>
>       </configuration>
>       </plugin>
>       <plugin>
>       <groupId>org.apache.maven.plugins</groupId>
>       <artifactId>maven-install-plugin</artifactId>
>       <executions>
>       <!-- Ensure that the JAR version ends up in the local repository -->
>       <execution>
>       <id>jar-install</id>
>       <phase>install</phase>
>       <goals>
>       <goal>install-file</goal>
>       </goals>
>       <configuration>
>       <file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
>       <packaging>jar</packaging>
>       <javadoc>${project.build.directory}/${project.artifactId}-${project.version}-javadoc.jar</javadoc>
>       <sources>${project.build.directory}/${project.artifactId}-${project.version}-sources.jar</sources>
>       </configuration>
>       </execution>
>       </executions>
>       </plugin>

This does not make sense. If you like to create and deploy a separate
jar file of the classes which are being compiled in the war module you
should use:

<archiveClasses>true</archiveClasses>
<attachClasses>true</attachClasses>

configuration of the maven-war-plugin which will do and create an
appropriate jar file for those classes.


I strongly recommend to upgrade maven-war-plugin, maven-ear-plugin
versions to the most recent ones...



>       <plugin>
>       <groupId>org.apache.maven.plugins</groupId>
>       <artifactId>maven-deploy-plugin</artifactId>
>       <executions>
>       <!-- Ensure that the JAR version ends up in the remote repository -->
>       <execution>
>       <id>jar-deploy</id>
>       <phase>deploy</phase>
>       <goals>
>       <goal>deploy-file</goal>
>       </goals>
>       <configuration>
>       <file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
>       <groupId>${project.groupId}</groupId>
>       <artifactId>${project.artifactId}</artifactId>
>       <version>${project.version}</version>
>       <packaging>jar</packaging>
>       <generatePom>false</generatePom>
>       <javadoc>${project.build.directory}/${project.artifactId}-${project.version}-javadoc.jar</javadoc>
>       <sources>${project.build.directory}/${project.artifactId}-${project.version}-sources.jar</sources>
>       <repositoryId>${project.distributionManagement.repository.id}</repositoryId>
>       <url>${project.distributionManagement.repository.url}</url>
>       </configuration>
>       </execution>
>       </executions>
>       </plugin>
> </plugins>
> </build>
> </project>
>


Same as above... remove this part...

Manually calling install-file/deploy-file is in 99.999% of the cases
simply wrong...

> And here the excerpt from the pom.xml of the XXX-ear module:
>
> <project>
> <parent>
> <groupId>XXX</groupId>
> <artifactId>XXX-pom</artifactId>
> <version>1.0.18</version>
> </parent>
> <artifactId>XXX-web</artifactId>
> <packaging>war</packaging>
>
> <dependencies>
> <dependency>
> <groupId>XXX</groupId>
> <artifactId>XXX-web</artifactId>
> <version>${project.version}</version>
> <type>war</type>
> </dependency>
> </dependencies>
>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-ear-plugin</artifactId>
> <configuration>
> <modules>
> <webModule>
> <groupId>XXX</groupId>
> <artifactId>XXX-web</artifactId>
> <uri>XXX-web-${project.version}.war</uri>
> <bundleFileName>XXX-web-${project.version}.war</bundleFileName>
> <contextRoot>/XXX</contextRoot>
> <bundleDir>/</bundleDir>
> </webModule>
> </modules>
> </configuration>
> </plugin>
> </plugins>
> </build>
> </project>
>
> The <webModule> specifies that the type of the artifact must be WAR.
> So the maven-ear-plugin tries to match that against the artifacts of the project (means the <dependencies>).
> And that also works.
>
> But it seems that the maven-install-plugin and / or maven-deploy-plugin overwrite the file-path of the WAR at runtime of the Maven build in memory.
> I don't know why and I also don't know how to prevent it.
>
>
> Best regards,
> Gerrit
>
>

Best would be to have an example project on Github or alike where we can
take a look on it ...and help here...


Kind regards
Karl Heinz Marbaise



> -----Ursprüngliche Nachricht-----
> Von: Hohl, Gerrit <[hidden email]>
> Gesendet: Donnerstag, 12. November 2020 13:33
> An: Maven Users List ([hidden email]) <[hidden email]>
> Betreff: Creating JAR file in WAR module leads to error in EAR creation
>
> 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
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

AW: AW: Creating JAR file in WAR module leads to error in EAR creation

g.hohl
Hello Karl Heinz,
Hello Jörg,


Thanks for your replies to my problem.


@Jörg: I would have assumed - as the EJB plugin also uses the type explicitly defined by the type of used module - that Maven would be able to resolve the coordinates to the correct artifact (means GAV and type).
https://github.com/apache/maven-ear-plugin/blob/b289e6c271d50172c871e528105dda81d6f702b8/src/main/java/org/apache/maven/plugins/ear/AbstractEarModule.java#L144
But it seems not the case. Or that they share the same information which is overwritten by the JAR installation / deployment.
The odd thing here is that everything works fine if I build the modules one-by-one.
So it seems not to be a general problem, but just a problem in case you do that in one build.
I would have expected that it always fails or always succeeds.


@Karl Heinz: Yes, the packaging is EJB.
That module is used in the web module and in the ear module as well as the client (which is not part of that Maven project, but an own Maven project).
Currently I'm using version 3.1.0 of the maven-ejb-plugin.
But I'm not sure how that is related to the problem as in all iteration - successful or not - I didn't change anything in aspect of the EJB.
Maybe you can elaborate on that a little bit?


In meantime I solved it with the maven-war-plugin's options:

<project>
        <parent>
                <groupId>XXX</groupId>
                <artifactId>XXX-pom</artifactId>
                <version>1.0.18</version>
        </parent>
        <artifactId>XXX-web</artifactId>
        <packaging>war</packaging>
       
        <build>
                <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
    <webResources>
    <resource>
    <directory>${generated-webbapp-folder}</directory>
    </resource>
    </webResources>
    <!-- Create separate JAR artifact containing only the classes -->
    <attachClasses>true</attachClasses>
    <classesClassifier>classes</classesClassifier>
    </configuration>
    </plugin>
                </plugins>
        </build>
</project>

This will create an additional XXX-web-1.0.18-classes.jar file.
The minus point is that this isn't as flexible as using the maven-jar-plugin.
But so far it works for me, also I have to do some copying via the maven-antrun-plugin as I need more files in the JAR than just the classes.

I guess that solution is also what Jörg mentioned.


Best regards,
Gerrit


P.S.: I recognized that I had a typo in my previous mail.
Of course the artifactId of the XXX-ear module is <artifactId>XXX-ear</artifact> using <packaging>ear</packaging>.
Ups... But it is only in the excerpt. The real module's pom.xml is correct.

-----Ursprüngliche Nachricht-----
Von: Karl Heinz Marbaise <[hidden email]>
Gesendet: Donnerstag, 12. November 2020 20:35
An: Maven Users List <[hidden email]>; Hohl, Gerrit <[hidden email]>
Betreff: Re: AW: Creating JAR file in WAR module leads to error in EAR creation

Hi,

On 12.11.20 14:13, Hohl, Gerrit wrote:
> Hello everyone,
>
>
> maybe some additional information will be helpful.
> The project structure is like (and also build in this order due to the dependencies of the modules):
>
> - XXX-pom
>    - XXX-ejb


My assumption is that ejb project uses packaging: ejb?
Where is the ejb module used? And how?

Which version of maven-ejb-plugin have you defined in your build?




>    - XXX-web
>    - XXX-ear
>
> Here the excerpt from the pom.xml of the XXX-web module:
>
> <project>
> <parent>
> <groupId>XXX</groupId>
> <artifactId>XXX-pom</artifactId>
> <version>1.0.18</version>
> </parent>
> <artifactId>XXX-web</artifactId>
> <packaging>war</packaging>
>
> <build>
> <plugins>
> <plugin>
>       <groupId>org.apache.maven.plugins</groupId>
>       <artifactId>maven-war-plugin</artifactId>
>       <configuration>
>       <webResources>
>       <resource>
>       <directory>${generated-webbapp-folder}</directory>
>       </resource>
>       </webResources>
>       </configuration>
>       </plugin>
>       <plugin>
>       <groupId>org.apache.maven.plugins</groupId>
>       <artifactId>maven-install-plugin</artifactId>
>       <executions>
>       <!-- Ensure that the JAR version ends up in the local repository -->
>       <execution>
>       <id>jar-install</id>
>       <phase>install</phase>
>       <goals>
>       <goal>install-file</goal>
>       </goals>
>       <configuration>
>       <file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
>       <packaging>jar</packaging>
>       <javadoc>${project.build.directory}/${project.artifactId}-${project.version}-javadoc.jar</javadoc>
>       <sources>${project.build.directory}/${project.artifactId}-${project.version}-sources.jar</sources>
>       </configuration>
>       </execution>
>       </executions>
>       </plugin>

This does not make sense. If you like to create and deploy a separate jar file of the classes which are being compiled in the war module you should use:

<archiveClasses>true</archiveClasses>
<attachClasses>true</attachClasses>

configuration of the maven-war-plugin which will do and create an appropriate jar file for those classes.


I strongly recommend to upgrade maven-war-plugin, maven-ear-plugin versions to the most recent ones...



>       <plugin>
>       <groupId>org.apache.maven.plugins</groupId>
>       <artifactId>maven-deploy-plugin</artifactId>
>       <executions>
>       <!-- Ensure that the JAR version ends up in the remote repository -->
>       <execution>
>       <id>jar-deploy</id>
>       <phase>deploy</phase>
>       <goals>
>       <goal>deploy-file</goal>
>       </goals>
>       <configuration>
>       <file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
>       <groupId>${project.groupId}</groupId>
>       <artifactId>${project.artifactId}</artifactId>
>       <version>${project.version}</version>
>       <packaging>jar</packaging>
>       <generatePom>false</generatePom>
>       <javadoc>${project.build.directory}/${project.artifactId}-${project.version}-javadoc.jar</javadoc>
>       <sources>${project.build.directory}/${project.artifactId}-${project.version}-sources.jar</sources>
>       <repositoryId>${project.distributionManagement.repository.id}</repositoryId>
>       <url>${project.distributionManagement.repository.url}</url>
>       </configuration>
>       </execution>
>       </executions>
>       </plugin>
> </plugins>
> </build>
> </project>
>


Same as above... remove this part...

Manually calling install-file/deploy-file is in 99.999% of the cases simply wrong...

> And here the excerpt from the pom.xml of the XXX-ear module:
>
> <project>
> <parent>
> <groupId>XXX</groupId>
> <artifactId>XXX-pom</artifactId>
> <version>1.0.18</version>
> </parent>
> <artifactId>XXX-web</artifactId>
> <packaging>war</packaging>
>
> <dependencies>
> <dependency>
> <groupId>XXX</groupId>
> <artifactId>XXX-web</artifactId>
> <version>${project.version}</version>
> <type>war</type>
> </dependency>
> </dependencies>
>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-ear-plugin</artifactId>
> <configuration>
> <modules>
> <webModule>
> <groupId>XXX</groupId>
> <artifactId>XXX-web</artifactId>
> <uri>XXX-web-${project.version}.war</uri>
> <bundleFileName>XXX-web-${project.version}.war</bundleFileName>
> <contextRoot>/XXX</contextRoot>
> <bundleDir>/</bundleDir>
> </webModule>
> </modules>
> </configuration>
> </plugin>
> </plugins>
> </build>
> </project>
>
> The <webModule> specifies that the type of the artifact must be WAR.
> So the maven-ear-plugin tries to match that against the artifacts of the project (means the <dependencies>).
> And that also works.
>
> But it seems that the maven-install-plugin and / or maven-deploy-plugin overwrite the file-path of the WAR at runtime of the Maven build in memory.
> I don't know why and I also don't know how to prevent it.
>
>
> Best regards,
> Gerrit
>
>

Best would be to have an example project on Github or alike where we can take a look on it ...and help here...


Kind regards
Karl Heinz Marbaise



> -----Ursprüngliche Nachricht-----
> Von: Hohl, Gerrit <[hidden email]>
> Gesendet: Donnerstag, 12. November 2020 13:33
> An: Maven Users List ([hidden email]) <[hidden email]>
> Betreff: Creating JAR file in WAR module leads to error in EAR
> creation
>
> 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/b289e6c271d50172c871e5
> 28105dda81d6f702b8/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
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]