运行sbt的项目根目录中的java.lang.NullPointerException

时间:2018-02-10 12:30:22

标签: scala sbt

我是从Scala开始的,我试图在build.sbt所在的项目文件夹中运行sbt。当我收到此错误时,此文件夹是唯一的文件夹。如果我在src文件夹或我的Documents文件夹中运行它,我就不会收到错误。谁能告诉我为什么会这样?我不知道如何表示文件夹结构,它将是build.sbt的主根,src文件夹内的example/src/main/scala/example/Lists.scala。它是一个来自coursera的文件夹,所以我没有创建它。构建是:

name := course.value + "-" + assignment.value

scalaVersion := "2.11.7"

scalacOptions ++= Seq("-deprecation")

// grading libraries
libraryDependencies += "junit" % "junit" % "4.10" % Test

// for funsets
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4"

// include the common dir
commonSourcePackages += "common"

courseId := "bRPXgjY9EeW6RApRXdjJPw" 

错误是:

java.lang.NullPointerException
    at java.base/java.util.regex.Matcher.getTextLength(Matcher.java:1769)
    at java.base/java.util.regex.Matcher.reset(Matcher.java:416)
    at java.base/java.util.regex.Matcher.<init>(Matcher.java:253)
    at java.base/java.util.regex.Pattern.matcher(Pattern.java:1147)
    at java.base/java.util.regex.Pattern.split(Pattern.java:1264)
    at java.base/java.util.regex.Pattern.split(Pattern.java:1335)
    at sbt.IO$.pathSplit(IO.scala:744)
    at sbt.IO$.parseClasspath(IO.scala:859)
    at sbt.compiler.CompilerArguments.extClasspath(CompilerArguments.scala:62)
    at sbt.compiler.MixedAnalyzingCompiler$.withBootclasspath(MixedAnalyzingCompiler.scala:189)
    at sbt.compiler.MixedAnalyzingCompiler$.searchClasspathAndLookup(MixedAnalyzingCompiler.scala:167)
    at sbt.compiler.MixedAnalyzingCompiler$.apply(MixedAnalyzingCompiler.scala:177)
    at sbt.compiler.IC$.incrementalCompile(IncrementalCompiler.scala:138)
    at sbt.Compiler$.compile(Compiler.scala:128)
    at sbt.Compiler$.compile(Compiler.scala:114)
    at sbt.Defaults$.sbt$Defaults$$compileIncrementalTaskImpl(Defaults.scala:829)
    at sbt.Defaults$$anonfun$compileIncrementalTask$1.apply(Defaults.scala:820)
    at sbt.Defaults$$anonfun$compileIncrementalTask$1.apply(Defaults.scala:818)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.base/java.lang.Thread.run(Thread.java:844)
[error] (compile:compileIncremental) java.lang.NullPointerException
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q

1 个答案:

答案 0 :(得分:3)

您的问题可能是旧的SBT版本。

确保您使用SBT 0.13.17+实现JDK 9兼容性(即在项目/ build.properties中设置sbt.version=0.13.17

参考:https://github.com/sbt/sbt/pull/3848