Reputation: 12393
After I do "mvn clean install". I get the compiled jar in my target folder. Now I want to configure Maven to automatically copy this jar and overwrite the old jar in a specific directory? (ie: %tomcat_dir%/WEB-INF/lib) when I enter a goal such as "mvn deploy"?
Upvotes: 1
Views: 2457
Reputation: 7662
This is citation from Maven Quick Reference:
Add Maven-Plugin to pom.xml:
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://192.168.129.36:8080/manager/html</url>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
</plugin>
...
</plugins>
...
<repositories>
<repository>
<id>codehaus</id>
<name>Codehaus maven repository</name>
<url>http://dist.codehaus.org/</url>
<layout>legacy</layout>
</repository>
...
</repositories>
Then run Tomcat with
mvn tomcat:run
Deploy the war automatically with
mvn tomcat:deploy
If already deployed, the webapp needs to be undeployed first:
mvn tomcat:undeploy
Note that automatic deployment/undeployment only works without further configuration in $MAVEN2_HOME/conf/settings.xml if the managers username is admin with empty password
Upvotes: 1