我在$ {basedir} / codebase位置有一个名为MakeJar.xml的xml文件。 在我的shell上,如果我必须运行该文件,我曾经使用命令“ant -f MakeJar.xml”。 现在,如果我必须使用pom.xml运行此文件,我该怎么办?
我准备了以下pom.xml。但它很有效!
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>default-cli</id>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<ant antfile="${basedir}/codebase/MakeJar.xml"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
答案 0 :(得分:0)
查看ant task定义,属性antfile
被描述为“要使用的构建文件。默认为”build.xml“。此文件应该是相对于dir属性给出。“
所以你可能不得不使用:
<ant dir="${project.basedir}" antfile="codebase/MakeJar.xml" />
另外,不要忘记在插件部分指定<phase>
(代码中缺少)。以下定义适用于我:
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>install</phase>
<configuration>
<target>
<ant
dir="${project.basedir}"
antfile="codebase/MakeJar.xml" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>