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.
Asked
Active
Viewed 5,981 times
3
-
1Possible duplicate of [Maven WAR dependency](http://stackoverflow.com/questions/1769586/maven-war-dependency) – 4castle Mar 21 '16 at 02:53
-
What have you tried yet? – surajs1n Mar 21 '16 at 04:10
1 Answers
4
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.

khmarbaise
- 92,914
- 28
- 189
- 235