Scala plugin with fsc option fails due to internal compiler error on fresh Scala install 2.11.2 and gradle 2.0

Application is very simple, e.g.:

package com.rainysoft.decisiontree.application
  import com.rainysoft.decisiontree.tree._
  object Application extends App {
  println("Hello World")
}

Build file is:

apply plugin: 'scala'
  repositories {
  mavenCentral()
}
  dependencies {
  compile 'org.scala-lang:scala-library:2.11.2'
  testCompile 'org.scala-lang:scala-library:2.11.2'
}
  compileScala {
  scalaCompileOptions.useCompileDaemon = true
}

Gradle version is 2.0 (latest available as of writing, just downloaded). OS is Mac but I had the same issue on Windows.

Without scalaCompileOptions.useCompileDaemon there is no problem. With it, as stated under 25.8: http://www.gradle.org/docs/current/userguide/scala_plugin.html, there is an “internal compiler error” without much details.

Output from debug:

11:37:12.581 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:fsc] com/cinnober/scalagradletest/Application.scala added as com/cinnober/scalagradletest/Application.class doesn’t exist. 11:37:12.594 [INFO] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:fsc] Compiling 1 source file to /Users/mikael.ohman/Programming/scalagradletest/build/classes/main 11:37:12.595 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:fsc] com/cinnober/scalagradletest/Application.scala 11:37:12.792 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:fsc] Scalac params = ‘’ 11:37:12.821 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ‘:compileScala’ 11:37:12.821 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :compileScala FAILED 11:37:12.822 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :compileScala (Thread[main,5,main]) completed. Took 1.962 secs. 11:37:12.822 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 2.015 secs, idle: 0.004 secs 11:37:13.064 [ERROR] [org.gradle.BuildExceptionReporter] 11:37:13.065 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception. 11:37:13.065 [ERROR] [org.gradle.BuildExceptionReporter] 11:37:13.065 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong: 11:37:13.065 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ‘:compileScala’. 11:37:13.066 [ERROR] [org.gradle.BuildExceptionReporter] > Compilation failed because of an internal compiler error; see the error output for details. 11:37:13.066 [ERROR] [org.gradle.BuildExceptionReporter] 11:37:13.066 [ERROR] [org.gradle.BuildExceptionReporter] * Try: 11:37:13.066 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. 11:37:13.067 [LIFECYCLE] [org.gradle.BuildResultLogger] 11:37:13.067 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED 11:37:13.067 [LIFECYCLE] [org.gradle.BuildResultLogger] 11:37:13.067 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 6.693 secs 11:37:13.069 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache artifact-at-repository.bin (/Users/mikael.ohman/.gradle/caches/modules-2/metadata-2.12/artifact-at-repository.bin) 11:37:13.070 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-metadata.bin (/Users/mikael.ohman/.gradle/caches/modules-2/metadata-2.12/module-metadata.bin) 11:37:13.070 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on artifact cache (/Users/mikael.ohman/.gradle/caches/modules-2). 11:37:13.070 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on buildscript class cache for build file ‘/Users/mikael.ohman/Programming/scalagradletest/build.gradle’ (/Users/mikael.ohman/.gradle/caches/2.0/scripts/build_4oehpr3oe0oqmbrcr46acq7iu1/ProjectScript/buildscript). 11:37:13.070 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on no_buildscript class cache for build file ‘/Users/mikael.ohman/Programming/scalagradletest/build.gradle’ (/Users/mikael.ohman/.gradle/caches/2.0/scripts/build_4oehpr3oe0oqmbrcr46acq7iu1/ProjectScript/no_buildscript).

Out put from stacktrace:

  • Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:compileScala’.

at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)

at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)

at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)

at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)

at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)

at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)

at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)

at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)

at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)

at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:296)

at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)

at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)

at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)

at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)

at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:86)

at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)

at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)

at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)

at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)

at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)

at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)

at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)

at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:148)

at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:105)

at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:85)

at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:81)

at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)

at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)

at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:39)

at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:29)

at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)

at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)

at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)

at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)

at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)

at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)

at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)

at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)

at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)

at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)

at org.gradle.launcher.Main.doAction(Main.java:33)

at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)

at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)

at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)

at org.gradle.launcher.GradleMain.main(GradleMain.java:23) Caused by: : Compilation failed because of an internal compiler error; see the error output for details.

at scala.tools.ant.ScalaTask$class.buildError(ScalaMatchingTask.scala:27)

at scala.tools.ant.ScalaMatchingTask.buildError(ScalaMatchingTask.scala:30)

at scala.tools.ant.FastScalac.execute(FastScalac.scala:150)

at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)

at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)

at org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(BasicAntBuilder.java:71)

at org.gradle.api.internal.project.AntBuilderDelegate.nodeCompleted(DefaultIsolatedAntBuilder.groovy:176)

at org.gradle.api.internal.tasks.scala.AntScalaCompiler$_execute_closure1.doCall(AntScalaCompiler.groovy:64)

at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:59)

at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)

at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:91)

at org.gradle.util.ConfigureUtil$configure.call(Unknown Source)

at org.gradle.api.internal.project.DefaultIsolatedAntBuilder.execute(DefaultIsolatedAntBuilder.groovy:116)

at org.gradle.api.internal.project.IsolatedAntBuilder$execute$0.call(Unknown Source)

at org.gradle.api.internal.tasks.scala.AntScalaCompiler.execute(AntScalaCompiler.groovy:61)

at org.gradle.api.internal.tasks.scala.AntScalaCompiler.execute(AntScalaCompiler.groovy)

at org.gradle.api.internal.tasks.scala.DefaultScalaJavaJointCompiler.execute(DefaultScalaJavaJointCompiler.java:35)

at org.gradle.api.internal.tasks.scala.DefaultScalaJavaJointCompiler.execute(DefaultScalaJavaJointCompiler.java:25)

at org.gradle.api.internal.tasks.scala.DelegatingScalaCompiler.execute(DelegatingScalaCompiler.java:31)

at org.gradle.api.internal.tasks.scala.DelegatingScalaCompiler.execute(DelegatingScalaCompiler.java:22)

at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:33)

at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:24)

at org.gradle.api.tasks.scala.ScalaCompile.compile(ScalaCompile.java:141)

at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)

at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)

at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)

at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)

at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:570)

at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:553)

at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)

at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)

… 44 more

fsc is a thing of the past, and I’m not sure if it’s still supported in recent Scala versions (would be interesting to see the stack trace of the cause). Instead, I recommend to use ‘scalaCompileOptions.useAnt = false’, which activates the Zinc incremental Scala compiler.