我想在sbt项目中为 Scala.js和Snap.svg建立桥梁,但也包括桥梁的演示代码. 在做demos / compile时,sbt开始说它无法解决依赖.看起来它正试图到达桥梁,好像它是一个公开的外部项目,但它就在这里
在做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 >
还有一件事,项目/ plugins.sbt:
addSbtPlugin("org.scala-lang.modules.scalajs" % "scalajs-sbt-plugin" % "0.5.0")问题的根本原因是桥项目使用scalaVersion:=“2.11.1”(由build.sbt指定,但您的demos项目使用默认的scalaVersion(在sbt 0.13,IIRC中为2.10.2).在尝试将项目与不同的scalaVersions关联时,dependsOn关系会变得混乱.请参阅此问题: https://github.com/sbt/sbt/issues/1448
你可能认为root build.sbt中的scalaVersion:=“2.11.1”将适用于所有子项目.但事实并非如此,它只适用于根植于的子项目. (这里,桥).您还必须将此设置(以及您希望共享的其他设置)指定为演示的settings()方法的参数,或者在scalajs_demos / build.sbt文件中指定.