plugin.sbt
:我在这里定义了解析器和插件。
logLevel := Level.Debug
resolvers += "JCenter repo" at "https://bintray.com/bintray/jcenter/"
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"
resolvers += "mvnrepository" at "http://mvnrepository.com/artifact/"
resolvers += "Atlassian Releases" at "https://maven.atlassian.com/public/"
resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.2")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.3")
addSbtPlugin("com.vmunier" % "sbt-play-scalajs" % "0.2.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.0")
build.sbt
:此文件中有3个项目:共享,客户端和服务器。客户端是Scala.js应用程序,服务器是Play应用程序,共享是在服务器和客户端项目中使用代码的项目。
import sbt.Project.projectToRef
lazy val clients = Seq(client)
lazy val scalaV = "2.11.6"
lazy val server = (project in file("server")).settings(
scalaVersion := scalaV,
scalaJSProjects := clients,
pipelineStages := Seq(scalaJSProd, gzip),
libraryDependencies ++= Seq(
"com.vmunier" %% "play-scalajs-scripts" % "0.3.0",
"org.webjars" % "jquery" % "1.11.1",
"org.json4s" %% "json4s-jackson" % "3.2.11",
"com.github.benhutchison" %% "prickle" % "1.1.7",
"com.kyleu" %% "jdub-async" % "1.0",
specs2 % Test
)
).enablePlugins(PlayScala).
aggregate(clients.map(projectToRef): _*).
dependsOn(exampleSharedJvm)
lazy val client = (project in file("client")).settings(
scalaVersion := scalaV,
persistLauncher := true,
persistLauncher in Test := false,
sourceMapsDirectories += exampleSharedJs.base / "..",
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "0.8.0",
"org.scala-js" %%% "scala-parser-combinators" % "1.0.2",
"com.github.benhutchison" %%% "prickle" % "1.1.7"
)
).enablePlugins(ScalaJSPlugin, ScalaJSPlay).
dependsOn(exampleSharedJs)
lazy val shared = (crossProject.crossType(CrossType.Pure) in file("shared")).
settings(scalaVersion := scalaV).
jsConfigure(_ enablePlugins ScalaJSPlay).
jsSettings(sourceMapsBase := baseDirectory.value / "..")
lazy val exampleSharedJvm = shared.jvm
lazy val exampleSharedJs = shared.js
onLoad in Global := (Command.process("project server", _: State)) compose (onLoad in Global).value
在编译服务器项目期间,我收到错误:unresolved dependency: com.kyleu#jdub-async_2.11;1.0: not found
。如何解决这个问题?