【发布时间】:2019-09-06 18:06:25
【问题描述】:
我们将 Maven 与 Ant build.xml 文件结合用于我们的构建。
maven-antrun-plugin 看起来像这样:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<!-- Version 1.8 uses Ant 1.9.4 -->
<version>1.8</version>
<executions>
<execution>
<id>Compile sources</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<mkdir dir="${temp.dir}"/>
<mkdir dir="${dist.dir}"/>
<exec dir="${project.basedir}" executable="${ant.exec}" failonerror="true">
<arg
line="-f xlatedb.ant.xml -DDLC ${dlc} -lib ${lib.dir}
-Dtarget.dir ${target.dir}
-Ddist.dir ${dist.dir}
-Dtemp.dir ${temp.dir}
-Dproject.version ${project.version} "/>
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
maven-antrun-plugin 在内部使用 Ant 1.9.4。有没有办法通过调用该内部 ant jar 来替换对 ${ant.exec} 的依赖?
现在我们将 ant.exec 传递给 mvn 命令。使用 ant 任务不起作用,因为我们还需要将 -lib 传递给 ant。 (lib 文件夹包含所有下载的依赖项)。
使用这种 ant.exec 方法的好处是我们可以使用 ant 1.10.5。但是,我可以在依赖项中指定 ant 1.10.5 并将该 jar 下载到 lib 文件夹中……但我需要一种方法来使用该 1.10.5 jar 启动 ant,而不是启动 ant.bat 文件。
【问题讨论】:
-
我猜
specify ant 1.10.5 in the dependencies是指项目依赖项。在这种情况下你应该更新这个插件的依赖,对于插件你也可以更新依赖。