如何为maven antrun插件设置ANT_OPTS

时间:2013-06-18 07:07:15

标签: maven ant maven-antrun-plugin

我正在使用maven-antrun-plugin将我的ant的build.xml转换为maven项目pom.xml,我得到了java.lang.OutOfMemoryError:Java堆空间错误。 当我尝试在构建时将一个相当大的文件2g复制到某个位置时发生此错误

这个代码只是

<copy todir="dist/${cgapp.home}/${push.root}/${cgapp.toolchain}" >
            <fileset dir="${env.PUSH_TOOLCHAIN}" includes="**"/>
</copy>

现在使用maven-antrun-plugin,pom.xml看起来像这样

<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration><exportAntProperties>true</exportAntProperties>
<target>
.........
    <copy verbose="true" todir="app/${cgapp.home}/${push.root}/${cgapp.toolchain}">                                   
    <fileset dir="${env.PUSH_TOOLCHAIN}" includes="**"/>                      
    </copy>
....
</target>
</..>

在运行ant build时,ANT_OPTS已设置为-Xmx4g,并且ant脚本运行正常。但是当我运行maven包命令时,它会抛出一个错误,如下所示。

发生了Ant BuildException:java.lang.OutOfMemoryError:Java堆空间

我认为maven插件不会读取ANT_OPTS env变量,而是具有默认值。有没有人知道为什么会这样,有没有办法将ANT_OPTS变量传递给antrun插件?

1 个答案:

答案 0 :(得分:2)

蚂蚁可能不是儿童过程。在这种情况下,您可以尝试MAVEN_OPTS。请参阅Maven Out of Memory Build Failure

上的一些提示
相关问题