我想在sbt项目中为Scala.js和Snap.svg建立桥梁,但也包括桥梁的演示代码。
在做demos/compile
时,sbt开始说它无法解决依赖关系。看起来它似乎试图到达桥梁,好像它是一个公开的外部项目,但它就在这里,它编译。
我做错了什么?
删除特定于发布的文件似乎没有带来变化。
目录结构:
├── build.sbt ├── project │ ├── (PublishToBintray.scala) │ ├── build.properties │ ├── build.sbt │ ├── project │ │ └── ... │ └── target │ │ └── ... ├── (publishing.sbt) ├── scalajs_demos │ ├── main │ │ └── scala │ │ └── clock.scala │ └── target │ └── ... ├── src │ └── main │ └── scala │ └── org │ └── scalajs │ └── snapsvg │ ├── SnapSvg.scala │ └── package.scala └── target └── ...
build.sbt:
scalaJSSettings
name := "Scala.js Snap.svg"
normalizedName := "scalajs-snapsvg"
version := "0.01"
organization := "org.scala-lang.modules.scalajs"
scalaVersion := "2.11.1"
crossScalaVersions := Seq("2.10.4", "2.11.1") // note: not tested with 2.10.x
libraryDependencies +=
"org.scala-lang.modules.scalajs" %%% "scalajs-dom" % "0.6" // TBD: probably need it, just like jQuery bridge does
ScalaJSKeys.jsDependencies +=
"org.webjars" % "Snap.svg" % "0.3.0" / "snap.svg.js"
homepage := Some(url("http://snapsvg.io/"))
licenses += ("Apache 2.0", url("https://github.com/adobe-webplatform/Snap.svg/blob/master/LICENSE"))
//---
// bridge (main) project
//
lazy val bridge = project.in( file(".") )
//---
// demos project
//
lazy val demos = project.in( file("scalajs_demos") ).dependsOn(bridge)
sbt:
出了什么问题> demos/compile [info] Updating {file:/Users/asko/Hg/scala-js-snapsvg/}demos... [info] Resolving org.scala-lang.modules.scalajs#scalajs-snapsvg_sjs0.5_2.10;0.01 ... [warn] module not found: org.scala-lang.modules.scalajs#scalajs-snapsvg_sjs0.5_2.10;0.01 [warn] ==== local: tried [warn] /Users/asko/.ivy2/local/org.scala-lang.modules.scalajs/scalajs-snapsvg_sjs0.5_2.10/0.01/ivys/ivy.xml [warn] ==== public: tried [warn] http://repo1.maven.org/maven2/org/scala-lang/modules/scalajs/scalajs-snapsvg_sjs0.5_2.10/0.01/scalajs-snapsvg_sjs0.5_2.10-0.01.pom [info] Resolving org.fusesource.jansi#jansi;1.4 ... [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: UNRESOLVED DEPENDENCIES :: [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: org.scala-lang.modules.scalajs#scalajs-snapsvg_sjs0.5_2.10;0.01: not found [warn] :::::::::::::::::::::::::::::::::::::::::::::: [trace] Stack trace suppressed: run last demos/*:update for the full output. [error] (demos/*:update) sbt.ResolveException: unresolved dependency: org.scala-lang.modules.scalajs#scalajs-snapsvg_sjs0.5_2.10;0.01: not found [error] Total time: 0 s, completed 27.7.2014 22:57:22 >
还有一件事,project/plugins.sbt
:
addSbtPlugin("org.scala-lang.modules.scalajs" % "scalajs-sbt-plugin" % "0.5.0")
答案 0 :(得分:10)
问题的根本原因是bridge
项目使用scalaVersion := "2.11.1"
(由build.sbt
指定,但您的demos
项目使用默认scalaVersion
}(在sbt 0.13,IIRC中为2.10.2)。dependsOn
关系在尝试将项目与不同的scalaVersions关联时会感到困惑。请参阅此问题:https://github.com/sbt/sbt/issues/1448
您可能认为根scalaVersion := "2.11.1"
中的build.sbt
将适用于所有子项目。但事实并非如此,它仅适用于以.
(此处为bridge
)为根的子项目。您还必须将此设置(以及您希望共享的其他设置)指定为settings()
demos
方法或scalajs_demos/build.sbt
文件的参数。