0

我在 ${basedir}/codebase 位置有一个名为 MakeJar.xml 的 xml 文件。在我的外壳上,如果我必须运行该文件,我曾经使用命令“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>    
4

1 回答 1

0

查看ant 任务定义,该属性antfile被描述为“要使用的构建文件。默认为“build.xml”。该文件应该是相对于给定 dir 属性的文件名。”

所以你可能必须使用:

<ant dir="${project.basedir}" antfile="codebase/MakeJar.xml" />

也不要忘记<phase>在插件部分指定 a (在您的代码中缺少)。以下定义对我有用:

<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>
于 2013-07-19T07:04:40.403 回答