Emma Strubell Emma Strubell - 1 year ago 102
Scala Question

Travis CI ignoring MAVEN_OPTS?

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
: 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

which is troubling since NOWHERE am I specifying
, only
. (This leads me to believe my
is also being ignored, causing the compilation failure.)

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


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

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

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

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

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

Answer Source

UPDATE (11/2/15):

This was finally fully resolved here. Quoting:

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:

in .travis.yml:

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

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

Old answer:

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

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.

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

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

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download