问题
We can easily use %%%
in a build.sbt
in a scalajs project, like:
libraryDependencies +=
"com.lihaoyi" %%% "utest" % "0.3.0" % "test"
(live demo: https://github.com/scala-js/scala-js-pickling/blob/master/build.sbt#L92)
But when I try to use project/Build.scala
to write the same build file, it can't compile, and I've no idea how to import the %%%
:
import org.scalajs.sbtplugin.cross.{CrossType, CrossProject}
import sbt._
import Keys._
object Build extends sbt.Build {
lazy val crossProject = CrossProject("server", "client", file("."), CrossType.Full)
.settings(
/* Shared settings */
libraryDependencies ++= Seq(
"io.github.widok" %%% "widok" % "0.2.1", // !!! can't compile
"com.lihaoyi" %%% "upickle" % "0.2.6")
)
.jsSettings(
/* Scala.js settings */
)
.jvmSettings(
/* JVM settings */
)
lazy val js = crossProject.js
lazy val jvm = crossProject.jvm
}
The lines with %%%
are not compilable, how to fix them?
回答1:
You need to add following import
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
来源:https://stackoverflow.com/questions/29473377/how-to-import-in-build-scala-in-a-scalajs-project