为sbt的命令行版本更改Ivy主目录非常简单。您只需将选项添加到.-Dsbt.ivy.home=<new ivy home dir>
$SBT_HOME/conf/sbtconf.txt
我想对 IntelliJ IDEA 的 Scala 扩展做同样的事情(我的 C 驱动器上的磁盘空间不足)。因此,我通过以下方式修改了 SBT 设置:File -> Other Settings -> Default Settings -> Build, Execution, Deployment -> BuildTools -> SBT。在VM 参数下,我添加了条目-Dsbt.ivy.home=<new ivy home dir>
。这应该与命令行工具中的效果相同。
当我创建一个新的基于sbt的 Scala 项目(并添加一个打印出消息的 Scala 对象)时,一切似乎都运行良好。我可以构建和运行程序。但是在对源代码进行更改并制作项目(Build -> Make Project)两三次之后,我观察到以下错误:
Error:scalac: Error: assertion failed:
Precisely this override requires its invoker to hand out a non-null AbstractFile.
while compiling: D:\Temp\scala\scalatest3\src\main\scala\Main.scala
during phase: jvm
library version: version 2.12.0
compiler version: version 2.12.0
reconstructed args: -nobootcp -javabootclasspath ; -classpath C:\Program Files\Java\jdk1.8.0_102\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\rt.jar;D:\temp\scala\scalatest3\target\scala-2.12\classes;D:\Bin\.ivy2\cache\org.scala-lang\scala-library\jars\scala-library-2.12.0.jar
last tree to typer: TypeTree(class ListBuffer)
tree position: line 4 of D:\Temp\scala\scalatest3\src\main\scala\Main.scala
tree tpe: scala.collection.mutable.ListBuffer[() => Unit]
symbol: final class ListBuffer in package mutable
symbol definition: final class ListBuffer extends AbstractBuffer with Buffer with GenericTraversableTemplate with BufferLike with ReusableBuilder with SeqForwarder with Serializable (a ClassSymbol)
symbol package: scala.collection.mutable
symbol owners: class ListBuffer
call site: constructor Main$delayedInit$body in class Main$delayedInit$body in package <empty>
== Source file context for tree position ==
1 * Created by P20058 on 14.11.2016.
2 */
3 object Main extends App {
4 println("Hello scalatest")
5
6 }
java.lang.AssertionError: assertion failed:
Precisely this override requires its invoker to hand out a non-null AbstractFile.
while compiling: D:\Temp\scala\scalatest3\src\main\scala\Main.scala
during phase: jvm
library version: version 2.12.0
compiler version: version 2.12.0
reconstructed args: -nobootcp -javabootclasspath ; -classpath C:\Program Files\Java\jdk1.8.0_102\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_102\jre\lib\rt.jar;D:\temp\scala\scalatest3\target\scala-2.12\classes;D:\Bin\.ivy2\cache\org.scala-lang\scala-library\jars\scala-library-2.12.0.jar
last tree to typer: TypeTree(class ListBuffer)
tree position: line 4 of D:\Temp\scala\scalatest3\src\main\scala\Main.scala
tree tpe: scala.collection.mutable.ListBuffer[() => Unit]
symbol: final class ListBuffer in package mutable
symbol definition: final class ListBuffer extends AbstractBuffer with Buffer with GenericTraversableTemplate with BufferLike with ReusableBuilder with SeqForwarder with Serializable (a ClassSymbol)
symbol package: scala.collection.mutable
symbol owners: class ListBuffer
call site: constructor Main$delayedInit$body in class Main$delayedInit$body in package <empty>
== Source file context for tree position ==
1 * Created by P20058 on 14.11.2016.
2 */
3 object Main extends App {
4 println("Hello scalatest34")
5
6 }
at scala.tools.nsc.backend.jvm.BytecodeWriters$ClassBytecodeWriter.writeClass(BytecodeWriters.scala:120)
at scala.tools.nsc.backend.jvm.BytecodeWriters$ClassBytecodeWriter.writeClass$(BytecodeWriters.scala:118)
at scala.tools.nsc.backend.jvm.BytecodeWriters$$anon$4.writeClass(BytecodeWriters.scala:47)
at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase.sendToDisk$1(GenBCode.scala:408)
at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase.drainQ3(GenBCode.scala:427)
at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase.buildAndSendToDisk(GenBCode.scala:387)
at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase.run(GenBCode.scala:350)
at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1404)
at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1389)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:1384)
at scala.tools.nsc.Global$Run.compile(Global.scala:1478)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:115)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:94)
at xsbt.CompilerInterface.run(CompilerInterface.scala:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:101)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:47)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)
at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:29)
at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:26)
at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:67)
at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:24)
at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)
重建项目(Build -> Rebuild Project)有效。但是经过一些迭代后,上面的错误再次出现。有什么我想念的想法吗?