title: How do I increase PermGen space for Scala compilation under Gradle?
body: <p>I'm getting <code>org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileScala'</code> trying to build my Scala project with Gradle, and if I run Gradle with <code>--stacktrace</code> it looks like the culprit is <code>java.lang.OutOfMemoryError: PermGen space</code>.</p>
  
  <p>I tried forking the compilation task and adding <code>MaxPermSize</code> to the forked JVM arguments, but all that did is move the OOME behind an <code>InvocationTargetException</code>.</p>
  
  <p>Here's my <code>build.gradle</code> block for the <code>compileScala</code> task:</p>
  
  <pre><code>compileScala {
    options.fork = true
    options.forkOptions.jvmArgs = ['-XX:MaxPermSize=512m']
    scalaCompileOptions.additionalParameters = [
        "-feature",
        "-language:reflectiveCalls", // used for config structural typing
        "-language:postfixOps"
    ]
  }
  </code></pre>
  
  <p>I know I can work around this by increasing PermGen space globally using <code>$JAVA_OPTIONS</code>, but I'd prefer a solution that I can check in with the source so that nobody needs to customize anything locally to build the project.</p>
  
  <p>FWIW, I'm using Gradle 1.11 with Scala 2.10.3 under Java 1.6.0_65 on Mac OS 10.9.3.</p>