Travis CI忽略了MAVEN_OPTS吗? [英] Travis CI ignoring MAVEN_OPTS?

查看:107
本文介绍了Travis CI忽略了MAVEN_OPTS吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Scala项目(由Maven管理)无法在Travis上构建,尽管在本地使用相同的MAVEN_OPTS=-Xmx3g -XX:MaxPermSize=512m进行了很好的编译,但仍引发了GC overhead limit exceeded错误.我怀疑Travis某种程度上忽略了我的MAVEN_OPTS:当我尝试针对Oracle JDK 8进行测试时,Travis日志:

My Scala project (Maven-managed) is failing to build on Travis, throwing a GC overhead limit exceeded error despite compiling fine locally with the same MAVEN_OPTS=-Xmx3g -XX:MaxPermSize=512m. I suspect that Travis is somehow ignoring my MAVEN_OPTS: When I try to test against Oracle JDK 8, Travis logs:

$ Setting environment variables from .travis.yml
$ export MAVEN_OPTS="-XX:MaxPermSize=512m -Xmx3g"

看起来不错.但是,在它记录后不久:

which looks good. However, soon after it logs:

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=192m; support was removed in 8.0

令人不安的是,因为现在我仅指定512m而不是-XX:MaxPermSize=192m. (这使我相信我的-Xmx3g也会被忽略,从而导致编译失败.)

which is troubling since NOWHERE am I specifying -XX:MaxPermSize=192m, only 512m. (This leads me to believe my -Xmx3g is also being ignored, causing the compilation failure.)

我尝试在pom中的许多其他位置指定MAVEN_OPTS,但无济于事.例如,对于maven-scala-plugin,我有:

I tried specifying the MAVEN_OPTS in many additional places in my pom, to no avail. For example, for the maven-scala-plugin, I have:

<configuration>
  ...
  <jvmArgs>
    <jvmArg>-Xmx3g</jvmArg>
    <jvmArg>-XX:MaxPermSize=512m</jvmArg>
  </jvmArgs>
</configuration>

在maven-surefire-plugin和scalatest插件下也有以下内容,尽管在编译而不是测试过程中构建失败:

And I also have the following under the maven-surefire-plugin and scalatest plugin, though the build is failing during compilation not tests:

<configuration>
  <argLine>-Xmx3g -XX:MaxPermSize=512m</argLine>
</configuration>

以下是我的.travis.yml的全部内容:

The following is the entirety of my .travis.yml:

language: java
env:
  global:
    - MAVEN_OPTS="-XX:MaxPermSize=512m -Xmx3g"
script: mvn clean install
jdk:
    - oraclejdk8
    - oraclejdk7

我正在使用Scala 2.11.2和scala-maven-plugin 3.2.0.

I'm using Scala 2.11.2 and scala-maven-plugin 3.2.0.

推荐答案

更新(11/2/15):

终于在此处完全解决了.报价:

This was finally fully resolved here. Quoting:

如果要使用基于容器的构建(不依赖sudo),则可以将所需内容回显到$HOME/.mavenrc文件中,并且优先于/etc/mavenrc,如下所示:

If you want to use container-based builds (not relying on sudo), you can echo what you want into a $HOME/.mavenrc file and that will take precedence over /etc/mavenrc, like so:

.travis.yml中:

before_script:
  - echo "MAVEN_OPTS='-Xmx2g -XX:MaxPermSize=512m'" > ~/.mavenrc

(根据您的设置,您也可以将其放在before_install中.)

(you could also put this in before_install depending on your setup).

旧答案:

我终于在此处,其中引用了此问题(已解决,但尚未解决) Travis CI github.

I finally found the answer here, which references this (closed but not resolved) issue on the Travis CI github.

看来Travis通过文件/etc/mavenrc作为根导出了MAVEN_OPTS环境变量,然后该文件不会被任何其他MAVEN_OPTS定义所覆盖(例如,通过travis配置中的env/global设置).解决方法是在设置自定义MAVEN_OPTS之前删除/etc/mavenrc.

It seems like Travis exports a MAVEN_OPTS environment variable as root via the file /etc/mavenrc, which then does not get overridden by any other MAVEN_OPTS definitions (e.g. via env/global settings in the travis config). The workaround is to delete /etc/mavenrc before setting custom MAVEN_OPTS.

我能够设置自定义MAVEN_OPTS并使用.travis.yml中的以下内容成功构建:

I was able to set custom MAVEN_OPTS and build successfully using the following in my .travis.yml:

script:
  - sudo rm /etc/mavenrc
  - export MAVEN_OPTS="-Xmx2469m -XX:MaxPermSize=512m"
  - mvn clean install

请注意,我没有在travis配置中使用language: java,而是直接通过script指令调用maven.

Note that I am NOT using language: java in my travis config, just calling maven directly via the script directive.

这篇关于Travis CI忽略了MAVEN_OPTS吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆