Reputation: 1517
I have customModule
which is dependant on user-portal
app. user-portal
is dependent on util
module
Here are the relevant POM's
customModule
POM
<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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>parent-build</artifactId>
<groupId>com.myComp.user</groupId>
<version>1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>customModule</groupId>
<artifactId>dbunit</artifactId>
<dependencies>
<dependency>
<groupId>com.myComp.user</groupId>
<artifactId>user-portal</artifactId>
<version>1.15</version>
<scope>compile</scope>
<type>war</type>
</dependency>
</dependencies>
</project>
user-portal
POM having utils
as dependency
<dependencies>
<dependency>
<groupId>com.myComp.user.utils</groupId>
<artifactId>utils</artifactId>
<version>1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
But utils
classes are not visible under customModule
. I am not sure why transitive dependencies/classes are not visible here ?
Upvotes: 3
Views: 422
Reputation: 7968
When depending to war packaging, classes inside the war is not visible. You should add <attachClasses>true</attachClasses>
to your war plugin in user-portal
project. This will produce both war and a jar with the classes.
In the dependent project you should depend to <classifier>classes</classifier>
instead of war.
inside user-portal pom.xml
<build>
...
<plugins>
...
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
...
</plugins>
...
</build>
customModule pom.xml
<dependency>
<groupId>com.myComp.user</groupId>
<artifactId>user-portal</artifactId>
<version>1.15</version>
<classifier>classes</classifier>
</dependency>
As a side note, default scope is compile you don't have to specify it.
Source = https://pragmaticintegrator.wordpress.com/2010/10/22/using-a-war-module-as-dependency-in-maven/
Upvotes: 1