maven-antrun-plugin(运行ant的插件)

在Maven实际使用过程中,有时候在对一些旧有的项目的做从Makefile和ant到Maven迁移时需要对一些步骤做特殊处理,比如说编译JNI代码,虽然Maven有个native插件可以用,但需要将原有项目JNI的编译步骤重写,这在有些时候显然不太适合,比如时间压力比较大的情况下。其实这种情况可以使用Maven的antrun插件来做,这样做的好处就是可以重用原来写好的Makefile,相对来说还是比较简单也是最快的。具体信息可以参考http://maven.apache.org/plugins/maven-antrun-plugin/。

Maven的antrun用起来也是非常简单的,就是在代码里嵌入类似以下代码片段:

[html]   view plain copy print ?
  1. <build>
        <plugins>
  2.       <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</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"/>
  3.                 <ant antfile="${basedir}/build.xml">
                      <target name="release"/>
                    </ant>
                  </target>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>

<?xml version="1.0" encoding="UTF-8"?>

<project name="jsdx-dmtp-build" default="release" basedir=".">
 <!-- 环境属性文件 -->
 <property file="build.properties" />
 
 <target name="release" >
  <echo message="-----------构建项目-------------" />
  <delete dir="${project.webapp}"/>
  <mkdir dir="${project.webapp}"/>
  <copy todir="${project.webapp}">
   <fileset dir="${maven.webapp}">
    <include name="**/*" />
   </fileset>
  </copy>
  <copy todir="${project.webapp}/WEB-INF/classes">
   <fileset dir="${basedir}/../maven-m1/target/classes">
    <include name="**/*" />
   </fileset>
  </copy>

 </target>
</project>

在构建时,会出现以下错误,was cached in the local repository, resolution will not be reattempted until

该错误是由于插件没有下载成功的原因。

解决方法:删除本地仓库相关插件。

猜你喜欢

转载自275012124.iteye.com/blog/1952548
今日推荐