1

我目前正在将我的 ANT 构建文件转换为 maven,并且遇到了一些问题。

如果您运行它们的主方法,我有一些类会自动为自己生成文档文件。我的构建过程的一部分是运行这些主要方法,将输出保存到文本文件,然后将它们上传到项目网站。

我的 ANT 目标看起来像这样:

<target name="generate-protocol-doc" depends="build">
   <java classname="abc.Protocol" output="builds/protocol.txt">
     <classpath refid="classpath" /> 
   </java>
</target>

有没有办法在 Maven 中做同样的事情?

4

2 回答 2

3

正如 Peter Lawrey 指出的那样,有一个名为 Antrun 的插件可以让您在 maven 中运行原生 Ant 代码。这是我的最终解决方案:

<build>
<!-- ... -->
<plugins>
<!-- ... -->
<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.6</version>
    <configuration>
        <target>
            <!-- It won't output to file unless the vm forks, apparently -->
            <java classname="abc.Protocol" output="builds/protocol.txt" fork="true"> 
                <classpath refid="maven.compile.classpath" />
            </java>
        </target>
    </configuration>
</plugin>
<!-- ... -->
</plugins>
<!-- ... -->
</build>
于 2011-01-26T22:12:26.193 回答
0

您可以使用Maven 执行插件

于 2011-01-26T20:46:40.660 回答