【问题标题】:How to set ANT_OPTS for maven antrun plugin如何为 maven antrun 插件设置 ANT_OPTS
【发布时间】:2013-06-18 07:07:14
【问题描述】:

我正在使用 maven-antrun-plugin 将我的 ant 的 build.xml 转换为 maven 项目 pom.xml,我收到 java.lang.OutOfMemoryError: Java heap space 错误。 当我尝试在构建期间将相当大的文件 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 构建时,ANT_OPTS 已设置为 -Xmx4g,并且 ant 脚本工作正常。但是当我运行 maven package 命令时,它会抛出一个错误,如下所示。

发生了 Ant BuildException:java.lang.OutOfMemoryError: Java heap space

我相信 maven 插件不会读取 ANT_OPTS 环境变量,而是有一个默认值。有谁知道为什么会发生这种情况以及是否有办法将 ANT_OPTS 变量传递给 antrun 插件?

【问题讨论】:

    标签: maven ant maven-antrun-plugin


    【解决方案1】:

    ant 可能不是子进程。在这种情况下,您可以尝试 MAVEN_OPTS。查看Maven Out of Memory Build Failure的一些提示

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-16
      • 1970-01-01
      • 1970-01-01
      • 2012-06-30
      • 1970-01-01
      • 2011-04-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多