- 在pom中声明ant插件:maven-antrun-plugin
- 设置ant在maven哪个"phase"和“goal”执行
- 编写ant task
- 在pom文件声明package类型为war包:<packaging>war</packaging>
-
打包:mvn clean package 或者 mvn clean package -DskipTests=true##复制文件 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <id>copy-jar-file</id> <phase>package</phase> <goals> <goal>run</goal> </goals> <configuration> <target> <copy todir="${project.basedir}"> <fileset dir="${project.basedir}/target"> <include name="*.jar" /> </fileset> </copy> </target> </configuration> </execution> </executions> </plugin> </plugins> </build>
<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>
<!-- 打jar包时需要把配置文件给排除在外 --> 51 <plugin> 52 <groupId>org.apache.maven.plugins</groupId> 53 <artifactId>maven-jar-plugin</artifactId> 54 <executions> 55 <execution> 56 <phase>package</phase> 57 <goals> 58 <goal>jar</goal> 59 </goals> 60 <configuration> 61 <classifier>lib</classifier> 62 <excludes> 63 <exclude>config.xml</exclude> 64 <exclude>log4j.xml</exclude> 65 </excludes> 66 </configuration> 67 </execution> 68 </executions> 69 </plugin>
maven打war包过程中对文件进行copy、rename、move、delete操作
最新推荐文章于 2023-04-24 10:44:38 发布