Reputation: 4239
I'm new to maven and I am using the maven war plugin to generate a WAR file for my project.
mvn war:war
But I would like this to be done automatically when I run
mvn package
How do I modify pom.xml to do this?
EDIT:
To clarify, I still want a JAR file as well as the WAR file. I am currently building a JAR with dependencies using
<packaging>jar</packaging>
and
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.fb.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
Upvotes: 0
Views: 149
Reputation: 3740
Put "war" packaging at the beginning of your pom.xml. Then add the following to your build section.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>make-a-jar</id>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Upvotes: 1