2012-12-28 89 views
3

我似乎無法得到gradle這個正確編譯一個簡單的斯卡拉項目。該目錄是這樣的:搖籃無法編譯基本斯卡拉項目

. 
├── build.gradle 
└── src 
    └── Main.scala 

build.gradle很簡單:

apply plugin: 'scala' 

sourceSets { 
    main { 
     scala { 
      srcDir 'src' 
     } 
    } 
} 

它失敗,這個迷人的小錯誤:

* Exception is: 
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileScala'. 
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:68) 
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) 
     at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:34) 
     at org.gradle.api.internal.changedetection.CacheLockHandlingTaskExecuter$1.run(CacheLockHandlingTaskExecuter.java:34) 
     at org.gradle.internal.Factories$1.create(Factories.java:22) 
     at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:179) 
     at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:232) 
     at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:138) 
     at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.java:83) 
     at org.gradle.api.internal.changedetection.CacheLockHandlingTaskExecuter.execute(CacheLockHandlingTaskExecuter.java:32) 
     at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:55) 
     at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57) 
     at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41) 
     at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51) 
     at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52) 
     at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42) 
     at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:247) 
     at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.executeTask(DefaultTaskPlanExecutor.java:52) 
     at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.processTask(DefaultTaskPlanExecutor.java:38) 
     at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:30) 
     at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:83) 
     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.api.internal.changedetection.TaskCacheLockHandlingBuildExecuter$1.run(TaskCacheLockHandlingBuildExecuter.java:31) 
     at org.gradle.internal.Factories$1.create(Factories.java:22) 
     at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:124) 
     at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:112) 
     at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:130) 
     at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:79) 
     at org.gradle.api.internal.changedetection.TaskCacheLockHandlingBuildExecuter.execute(TaskCacheLockHandlingBuildExecuter.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:158) 
     at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113) 
     at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81) 
     at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:38) 
     at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39) 
     at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:25) 
     at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50) 
     at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:137) 
     at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201) 
     at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174) 
     at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170) 
     at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139) 
     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:48) 
     at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45) 
     at org.gradle.launcher.Main.main(Main.java:39) 
     at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50) 
     at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32) 
     at org.gradle.launcher.GradleMain.main(GradleMain.java:26) 
Caused by: java.lang.NullPointerException: Cannot invoke method withInputStream() on null object 
     at org.gradle.api.internal.project.AntBuilderDelegate.taskdef(DefaultIsolatedAntBuilder.groovy:136) 
     at org.gradle.api.internal.tasks.scala.AntScalaCompiler$_execute_closure1.doCall(AntScalaCompiler.groovy:62) 
     at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58) 
     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:112) 
     at org.gradle.api.internal.project.IsolatedAntBuilder$execute.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.IncrementalJavaCompilerSupport.execute(IncrementalJavaCompilerSupport.java:33) 
     at org.gradle.api.internal.tasks.compile.IncrementalJavaCompilerSupport.execute(IncrementalJavaCompilerSupport.java:23) 
     at org.gradle.api.tasks.scala.ScalaCompile.compile(ScalaCompile.java:131) 
     at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:216) 
     at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:122) 
     at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147) 
     at org.gradle.api.tasks.scala.ScalaCompile_Decorated.invokeMethod(Unknown Source) 
     at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23) 
     at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$4.execute(AnnotationProcessingTaskFactory.java:161) 
     at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$4.execute(AnnotationProcessingTaskFactory.java:156) 
     at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:472) 
     at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:461) 
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:60) 
     ... 57 more 


BUILD FAILED 

gradle --version是:

------------------------------------------------------------ 
Gradle 1.3 
------------------------------------------------------------ 

Gradle build time: Tuesday, November 20, 2012 11:37:38 AM UTC 
Groovy: 1.8.6 
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012 
Ivy: 2.2.0 
JVM: 1.6.0_24 (Sun Microsystems Inc. 20.0-b12) 
OS: Linux 3.2.0-29-generic amd64 

世界上發生了什麼事情?

回答

5

您還沒有宣佈的Scala版本要使用的,如在文檔和示例。 (該錯誤消息在即將到來的Gradle 1.4中得到修復。)

repositories { 
    mavenCentral() 
} 

dependencies { 
    scalaTools "org.scala-lang:scala-compiler:2.9.2" 
    compile "org.scala-lang:scala-library:2.9.2" 
} 
+0

補充說,現在我得到「無法找到方法斯卡拉()的論點之後[org.scala- lang:scala-compiler:2.9.2]在根項目'grad'上「。 –

+0

啊...'scalaTools' :-) –

+0

權,這是'scalaTools'(固定)。 Gradle 1.4會從'compile'依賴性中自動推斷出來。 –

0

我在Gradle 2.1上遇到了這個問題。 (雖然我沒有得到同樣的錯誤,谷歌發現這對我來說)。我有一個「產生的原因::編譯失敗,因爲內部編譯器錯誤的;詳見錯誤輸出」錯誤,這並沒有告訴我什麼嘿。

我沒有看到anything on the documentation,以表明我需要使用scalaTools或類似的東西。

我結束了關閉基於螞蟻編譯使用類型安全編譯鋅代替

tasks.withType(ScalaCompile) { 
    scalaCompileOptions.useAnt = false 
}