How to import `%%%` in `Build.scala` in a scalajs project?

和自甴很熟 提交于 2019-12-11 02:53:14

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!