I have a Maven multi-module project (Jakarta EE 8) based on the wildfly-jakartaee8-with-tools archetype being deployed on Wildly 26 and using the maven-ear-plugin (3.2.0)
This is the project structure
-WebApp.ear
-Web-entities.jar
-Web-ejb.jar
-Web-web.war
-Web-mobile.war
-Web-api.war
Here is the Web-ear pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.webapp</groupId>
<artifactId>WebApp</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>Web-ear</artifactId>
<packaging>ear</packaging>
<name>Web - ear</name>
<description>This is the EAR POM file</description>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Web-entities</artifactId>
<type>ejb</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Web-ejb</artifactId>
<type>ejb</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Web-web</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Web-mobile</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Web-api</artifactId>
<type>war</type>
</dependency>
</dependencies>
<build>
<finalName>${project.parent.artifactId}</finalName>
<plugins>
<!--EAR plugin: format of output file -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>${version.ear.plugin}</version>
<configuration>
<!-- Tell Maven we are using Jakarta EE -->
<version>8</version>
<displayName>Web-ear</displayName>
<generateApplicationXml>true</generateApplicationXml>
<initializeInOrder>true</initializeInOrder>
<!-- Use Jakarta EE ear libraries as needed. Jakarta EE ear libraries
are in easy way to package any libraries needed in the ear, and automatically
have any modules (EJB-JARs and WARs) use them -->
<defaultLibBundleDir>lib</defaultLibBundleDir>
<unpackTypes>war</unpackTypes>
<modules>
<ejbModule>
<groupId>${project.groupId}</groupId>
<artifactId>Web-entities</artifactId>
<bundleFileName>Web-entities.jar</bundleFileName>
</ejbModule>
<ejbModule>
<groupId>${project.groupId}</groupId>
<artifactId>Web-ejb</artifactId>
<bundleFileName>Web-ejb.jar</bundleFileName>
</ejbModule>
<webModule>
<groupId>${project.groupId}</groupId>
<artifactId>Web-web</artifactId>
<contextRoot>/webapp</contextRoot>
<bundleFileName>Web-web.war</bundleFileName>
</webModule>
<webModule>
<groupId>${project.groupId}</groupId>
<artifactId>Web-mobile</artifactId>
<contextRoot>/mobile</contextRoot>
<bundleFileName>Web-mobile.war</bundleFileName>
</webModule>
<webModule>
<groupId>${project.groupId}</groupId>
<artifactId>Web-api</artifactId>
<contextRoot>/api</contextRoot>
<bundleFileName>Web-api.war</bundleFileName>
</webModule>
</modules>
</configuration>
</plugin>
<!-- The WildFly plug-in deploys your ear to a local WildFly / JBoss EAP container.
Due to Maven's lack of intelligence with EARs we need to configure
the WildFly Maven plug-in to skip deployment for all modules. We then enable
it specifically in the ear module. -->
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
But when I build the generated application.xml does not include any of the child modules.
If I set generateApplicationXml
to false, then manually create the application.xml with the modules specified it still does not add the child modules in the output EAR. but if I set <scope>compile</scope>
on the module dependancies in the ear pom it does include them - but this seems wrong to me as all the examples I see uses <scope>provided</scope>
?
I can see that Maven is building each child module correctly and they are present in the /target output folder of the sub-module but its just not adding them to the EAR output, I just get an empty EAR with meta-info
I found that the cause of this was in the project parent pom.xml
the child dependancies were labeled with <scope>provided</scope>
thus preventing the child modules from being packaged, removing this fixed the issue