Maven 插件之 maven-antrun-plugin
来源:互联网 发布:python高手之路 第3版 编辑:程序博客网 时间:2024/06/15 13:56
虽然Maven已经代替Ant,成为Java 工业领域事实上的构建标准.但在某些情况下,如果可以用Ant命令,还是很方便的. 借助 maven-antrun-plugin
插件,可以在Maven执行时,额外执行Ant脚本.
maven-antrun-plugin
打包完成后,把构建结果复制到其他位置
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> <execution> <id>package</id> <phase>package</phase> <configuration> <target> <echo message="copy package to deplay dir"/> <copy file="${basedir}/target/archbase-${profiles.evn}-${project.version}.war" tofile="E:/Repositories/workspace/deplay/archbase.war" overwrite="true"/> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions></plugin>
<phase>package</phase>
表示插件要在Maven 的 package 时执行<goal>run</goal>
这时插件内部的一个执行目标<target></target>
之间可以写任何Ant支持的task
执行外部命令
再看一个列子,来自 Maven实战之antrun插件
<plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <id>package</id> <phase>package</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <echo message="make ..."/> <exec dir="src/main/c" executable="make" failonerror="true" /> </tasks> </configuration> </execution> <execution> <id>clean</id> <phase>clean</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <echo message="make clean ..."/> <exec dir="src/main/c" executable="make" failonerror="true"> <arg line="clean"/> </exec> </tasks> </configuration> </execution> </executions> </plugin>
引用外部build.xml文件
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.8</version> <executions> <execution> <id>compile</id> <phase>compile</phase> <configuration> <target> <property name="compile_classpath" refid="maven.compile.classpath"/> <property name="runtime_classpath" refid="maven.runtime.classpath"/> <property name="test_classpath" refid="maven.test.classpath"/> <property name="plugin_classpath" refid="maven.plugin.classpath"/> <ant antfile="${basedir}/build.xml"> <target name="test"/> </ant> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions></plugin>The build.xml:<?xml version="1.0"?><project name="test6"> <target name="test"> <echo message="compile classpath: ${compile_classpath}"/> <echo message="runtime classpath: ${runtime_classpath}"/> <echo message="test classpath: ${test_classpath}"/> <echo message="plugin classpath: ${plugin_classpath}"/> </target></project>
1 0
- Maven 插件之 maven-antrun-plugin
- maven-antrun-plugin插件
- maven-antrun-plugin(运行ant的插件)
- Maven实战之antrun插件
- Maven实战之antrun插件
- maven-antrun-plugin
- maven-antrun-plugin
- Maven antrun plugin 学习
- maven-antrun-plugin
- maven项目构建:maven-antrun-plugin插件实现文件内容拷贝和文件重命名
- Maven antrun plugin调用Ant Optional Task
- Maven学习之 插件plugin
- Maven插件之buildnumber-maven-plugin
- Maven插件之maven-assembly-plugin
- Maven插件之Maven-Enforcer-Plugin
- Maven插件之build-helper-maven-plugin
- Maven插件之properties-maven-plugin
- Maven插件之sql-maven-plugin
- java基础的练习题
- [Git] error: Your local changes to the following files would be overwritten by merge
- StringBuilder&StringBuffer&String
- Checking Whether a String is Numeric
- 双卡双待 getDeviceId unique device ID IMEI 不唯一 会变问题
- Maven 插件之 maven-antrun-plugin
- 01背包中是否背包装满问题
- 【备战NOIP2012图论专项模拟试题】位图
- 彻底搞懂字符编码(unicode,mbcs,utf-8,utf-16,utf-32,big endian,little endian...)
- Git问题Everything up-to-date解决
- 657 - The die is cast
- 解题报告:HDU2841 Visible Trees 莫比乌斯反演
- MTK Battery系统
- Power Network--最大流的EK()算法