I'm trying to create an ear file using the maven plugin but it's failing on the ear project pom. I've been staring at this for hours and can't figure it out. I'm using eclipse so all my projects including the parent are in the same directory.
My parent pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-parent</artifactId>
<packaging>pom</packaging>
<version>${traintrack-version}</version>
<name>traintrack-parent</name>
<url>http://maven.apache.org</url>
<properties>
<traintrack-version>0.0.1-SNAPSHOT</traintrack-version>
</properties>
<modules>
<module>../traintrack-core</module>
<module>../traintrack-web</module>
<module>../traintrack-services-authentication</module>
<module>../traintrack-ear</module>
</modules>
</project>
My ear pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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.traintrack</groupId>
<artifactId>traintrack-parent</artifactId>
<version>${traintrack-version}</version>
<relativePath>../traintrack-parent/pom.xml</relativePath>
</parent>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-ear</artifactId>
<name>traintrack-ear</name>
<packaging>ear</packaging>
<version>${traintrack-version}</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10</version>
<configuration>
<generateApplicationXml>true</generateApplicationXml>
<displayName>traintrack-ear</displayName>
<modules>
<jarModule>
<groupId>com.tracktrack</groupId>
<artifactId>traintrack-core</artifactId>
<bundleDir>lib</bundleDir>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
<webModule>
<groupId>com.tracktrack</groupId>
<artifactId>traintrack-web</artifactId>
<contextRoot>/TrainTrack</contextRoot>
</webModule>
<jarModule>
<groupId>com.tracktrack</groupId>
<artifactId>traintrack-services-authentication</artifactId>
<bundleDir>lib</bundleDir>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
</modules>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-web</artifactId>
<version>${traintrack-version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-core</artifactId>
<version>${traintrack-version}</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-services-authentication</artifactId>
<version>${traintrack-version}</version>
<type>jar</type>
</dependency>
</dependencies>
</project>
and my module pom.xmls begin like the following
<parent>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-parent</artifactId>
<relativePath>../traintrack-parent/pom.xml</relativePath>
<version>${traintrack-version}</version>
</parent>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-core</artifactId>
<version>${traintrack-version}</version>
<packaging>jar</packaging>
I get the following error
Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.10:generate-application-xml (default-generate-application-xml) on project traintrack-ear: Artifact[jar:com.tracktrack:traintrack-core] is not a dependency of the project.
I've been playing around with the dependencies and I found that I get the same error when I remove the dependencies section in the ear pom.xml. It's always the first module listed in the ear that throws the error, and all of them do.
It's probably a silly mistake somewhere but I just can't spot it. Any help is appreciated.
There is an error in the configuration of maven-ear-plugin
. groupId
of traintrack-core
should be com.traintrack
, not com.tracktrack
So, instead this:
<jarModule>
<groupId>com.tracktrack</groupId>
<artifactId>traintrack-core</artifactId>
<bundleDir>lib</bundleDir>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
Use this:
<jarModule>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-core</artifactId>
<bundleDir>lib</bundleDir>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
EDIT:
The same should be done for traintrack-web
and traintrack-services-authentication
.
A few tips not related with problem:
jar
is the default packaging, no need to declare itcompile
is the default scope, no need to declare itA few tips not directly related with problem:
groupId
in sub modules. You can remove groupId
from sub modules (such as traintrack-core
) and keeps running =)${project.groupId}
when you're using maven modules and groupId
are same to all modules/projects, as well as the dependency groupId
is same of the projectE.g:
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>traintrack-core</artifactId>
<version>${traintrack-version}</version>
</dependency>
<jarModule>
<groupId>${project.groupId}</groupId>
<artifactId>traintrack-core</artifactId>
<bundleDir>lib</bundleDir>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>