Reputation: 29
I have a project with 2 packages in it. I have a war file present in 1st package. I want to make use of this war file in package 2. How can I add maven dependency in package 2 pom.xml file.
Upvotes: 3
Views: 6367
Reputation: 97349
In general war
package usually don't make sense to use them as dependencies. But you can create separate jar
packages of the classes (incl. resources) which are in the war
project. This can be achieved by using the following in your 1st package:
<project>
<packaging>war</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
So this create a supplemental jar
file with the following coordinates groupId:artifactId:classifier:version
in this case groupId:artifactId:classes:version
which you now can use as a dependency in your 2nd project.
Upvotes: 5