如何在scalajs项目中的`Build.scala`中导入`%%%`?

时间:2015-04-06 14:34:43

标签: sbt scala.js

我们可以在scalajs项目的%%%中轻松使用build.sbt,例如:

libraryDependencies +=
  "com.lihaoyi" %%% "utest" % "0.3.0" % "test"

(现场演示:https://github.com/scala-js/scala-js-pickling/blob/master/build.sbt#L92

但是当我尝试使用project/Build.scala编写相同的构建文件时,它无法编译,我也不知道如何导入%%%

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

}

%%%行不可编辑,如何解决?

1 个答案:

答案 0 :(得分:5)

您需要添加以下导入

import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._