1、打包时复制文件到某位置
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<encoding>UTF-8</encoding>
<!--要复制到的路径-->
<outputDirectory>
${project.build.directory}/configservice/WEB-INF/lib
</outputDirectory>
<resources>
<resource>
<!--项目中文件的路径-->
<directory>target</directory>
</resource>
</resources>
<overwrite>true</overwrite>
</configuration>
</execution>
</executions>
</plugin>
2、打包时删除某些文件
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<delete file="${project.build.directory}/classes/jdbc.properties" />
<move file="${project.build.directory}/classes/online_jdbc.properties" tofile="${project.build.directory}/classes/jdbc.properties"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
3、打包时重命名某文件
<!--${log.conf}读取profile下的属性值-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<move file="${project.build.directory}/classes/${log.conf}"
tofile="${project.build.directory}/classes/log4j.properties" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
4、打包时解压某压缩包或者jar/war包
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>prepare</id>
<phase>validate</phase>
<configuration>
<tasks>
<echo message="prepare phase" />
<unzip src="zips/archive.zip" dest="output/" />
<unzip src="output/inner.zip" dest="output/" />
<unzip dest="output">
<fileset dir="archives">
<include name="prefix*.zip" />
</fileset>
</unzip>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>