Scala 无法在sbt生成定义代码内使用导入

Scala 无法在sbt生成定义代码内使用导入,scala,sbt,Scala,Sbt,我尝试在sbt中导入JSON库,以便我的自定义sbt任务可以使用JSON api编写JSON文件。然而,sbt似乎无法导入这些库,而是只能导入标准库,如scala.io.Source、java.io.File等 下面两条注释掉的行都会导致sbt失败: libraryDependencies += "com.typesafe.play" %% "play-json" % "2.3.7" libraryDependencies += "io.argonaut" %% "argonaut" % "6

我尝试在sbt中导入JSON库,以便我的自定义sbt任务可以使用JSON api编写JSON文件。然而,sbt似乎无法导入这些库,而是只能导入标准库,如scala.io.Source、java.io.File等

下面两条注释掉的行都会导致sbt失败:

libraryDependencies += "com.typesafe.play" %% "play-json" % "2.3.7"

libraryDependencies += "io.argonaut" %% "argonaut" % "6.0.4"    

compile in Compile <<= (compile in Compile) map { c => 
  import scala.io.Source
  //import play.api.libs.json.Json
  //import argonaut._, Argonaut._
当然,我可以徒手对json进行字符串插值,但我想知道它可能是什么


谢谢

根据中的这段代码,您只需要在plugins.sbt中包含依赖项,而不是构建定义,即不需要插件

// [within plugins.sbt]
// plain library (not an sbt plugin) for use in the build definition
libraryDependencies += "org.example" % "utilities" % "1.3"
因此,您应该能够将这些添加到plugins.sbt:


根据的这段代码,您只需要在plugins.sbt中包含依赖项,而不是构建定义,即不需要插件

// [within plugins.sbt]
// plain library (not an sbt plugin) for use in the build definition
libraryDependencies += "org.example" % "utilities" % "1.3"
因此,您应该能够将这些添加到plugins.sbt:

libraryDependencies += "com.typesafe.play" %% "play-json" % "2.3.7"

libraryDependencies += "io.argonaut" %% "argonaut" % "6.0.4"