为什么我的sbt项目依赖不起作用? (坚持试图远程获取它)

时间:2014-07-27 20:11:50

标签: sbt scala.js

我想在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")

1 个答案:

答案 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文件的参数。