I know you'd probably want a Maven
-only answer to this - I did too. However, I found that the easiest but most flexible thing to do was to build the war with Maven, and deploy it with ANT
. The tomcat-maven-plugin wasn't powerful enough for me because I needed to deploy the .war to a local Tomcat
install AND to a remote machine using scp
.
Here's what my ANT
build.xml
file looks like:
<?xml version="1.0"?>
<target name="deploy_local">
<echo>Deploying .war to local Tomcat</echo>
<copy file="target/My.war" todir="/tomcat/webapps">
</copy>
</target>
<target name="deploy_production">
<echo>Deploying .war to production Tomcat</echo>
<move file="target/My.war" tofile="target/ROOT.war"/>
<scp file="target/ROOT.war"
trust="true"
todir="me:password@154.14.232.122:/tomcat/webapps"
port="22">
</scp>
</target>
You can see I even rename the .war file from My.war to ROOT.war for the production deploy.
The complete procedure is then: mvn clean package
followed by running the local or production ANT
target for deployment.