在运行mvn clean和mvn package时,进行部署与去除部署的工作 <profiles> <profile> <id>deploy-dev</id> <activation> <jdk>[1.5,1.7]</jdk> <property> <name>deploy.container</name> <value>TOMCAT</value> </property> </activation> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.3</version> <executions> <execution> <id>deploy</id> <phase>package</phase> <configuration> <tasks> <property environment="env" /> <property name="deploy.dir" value="${env.TOMCAT_HOME}/webapps" /> <property name="deploy.filename" value="${build.finalName}.${project.packaging}" /> <echo message="${deploy.filename}" /> <!-- ================================= target: deploy ================================= --> <copy todir="${deploy.dir}"> <fileset dir="target"> <include name="${deploy.filename}" /> </fileset> </copy> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> <execution> <id>undeploy</id> <phase>clean</phase> <configuration> <tasks> <property environment="env" /> <property name="deploy.dir" value="${env.TOMCAT_HOME}/webapps" /> <property name="deploy.filename" value="${build.finalName}.${project.packaging}" /> <echo message="${deploy.filename}" /> <delete> <fileset dir="${deploy.dir}"> <include name="${deploy.filename}" /> </fileset> </delete> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles>