Merge "Increase stack space for javac processes."
diff --git a/build.gradle b/build.gradle
index eed9769..06a0632 100644
--- a/build.gradle
+++ b/build.gradle
@@ -416,6 +416,13 @@
     targetCompatibility = JavaVersion.VERSION_1_8
 }
 
+// Javac often runs out of stack space when compiling the tests.
+// Increase the stack size for the javac process.
+tasks.withType(JavaCompile) {
+    options.fork = true
+    options.forkOptions.jvmArgs = ["-Xss4m"]
+}
+
 tasks.withType(JavaCompile) {
     options.compilerArgs << '-Xlint:unchecked'
 }