如何在Go SBT任务中指定JVM标志?

时间:2015-12-11 15:18:58

标签: java scala sbt jvm-arguments go-cd

我正在使用Go CD和gocd-sbt-plugin使用SBT构建Java + Scala多模块项目。但是,当我尝试编译和打包模块时,我的内存不足(java.lang.OutOfMemoryError: Java heap space)。

在Jenkins CI中,SBT插件为我提供了在构建操作中添加JVM标志和sbt标志的选项。目前我们正在使用这些JVM标志:

-Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Xss2M

我在Go文档中找不到答案,或者尝试将上述参数放在“其他选项”文本框中。

Edit SBT task screenshot

当我尝试后者时,我得到了这个堆栈跟踪:

15:02:23.288 [info] Compiling 54 Scala sources and 3495 Java sources to /gocd/var/lib/go-agent/pipelines/de/component/build/scala-2.11/classes...
15:04:31.744 java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
15:04:31.744    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
15:04:31.744    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
... 
15:04:31.744    at xsbt.boot.Boot.main(Boot.scala)
15:04:31.744 Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
15:04:31.744    at java.util.jar.Attributes.read(Attributes.java:394)
15:04:31.744    at java.util.jar.Manifest.read(Manifest.java:199)
...
15:04:31.744    at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5373)
15:04:31.744 [error] java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
15:04:31.744 [error] Use 'last' for the full log.
15:04:31.760 [error] Expected key
15:04:31.760 [error] Expected '*'
15:04:31.760 [error] XX:+CMSClassUnloadingEnabled
15:04:31.760 [error]    ^
15:04:31.858 Error: Interaction with plugin with id 'sbt.task.plugin' implementing 'task' extension failed while requesting for 'execute'. Reason: [Unsuccessful response from plugin. Plugin returned with code '500' and the following response: '{"exception":null,"success":false,"message":"Build failure"}']
15:04:31.865 [go] Current job status: failed.

我相信任务仍然失败,因为它没有使用这些标志导致Jenkins构建成功。有人可以指出我可以将上述JVM标志传递到Go SBT任务的位置吗?

1 个答案:

答案 0 :(得分:-1)

尝试传递

-J-Xmx2G
-J-Xss2M

等。作为附加选项(见https://medium.com/@jan______/sbtconfig-is-deprecated-650d6ff10236)。