为什么 SBT 不使用根项目中的解析器(在多模块项目中)

问题描述 投票:0回答:2

在多模块项目中,SBT 在构建模块时似乎没有使用

resolvers
。解析器在根项目的
build.sbt
中声明如下:

resolvers += "SpringSource Milestone Repository" at "http://repo.springsource.org/milestone"

项目声明如下:

lazy val core = project.settings(
    libraryDependencies ++= { ... }
)

但是在编译时,解析器没有被使用,我得到:

[info] Resolving org.springframework.scala#spring-scala;1.0.0.BUILD-SNAPSHOT ...
[warn]  module not found: org.springframework.scala#spring-scala;1.0.0.BUILD-SNAPSHOT
[warn] ==== local: tried
[warn]   /home/ariskk/.ivy2/local/org.springframework.scala/spring-scala/1.0.0.BUILD-SNAPSHOT/ivys/ivy.xml
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/org/springframework/scala/spring-scala/1.0.0.BUILD-SNAPSHOT/spring-scala-1.0.0.BUILD-SNAPSHOT.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.springframework.scala#spring-scala;1.0.0.BUILD-SNAPSHOT: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::

有什么想法可能是错的吗?

sbt
2个回答
10
投票

在根项目的

build.sbt
中使用以下内容:

resolvers in ThisBuild += "SpringSource Milestone Repository" at "http://repo.springsource.org/milestone"

in ThisBuild
就是答案。请参阅范围


正如评论中所指出的,较新的 sbt 版本使用以下语法:

ThisBuild / resolvers += "SpringSource Milestone Repository" at "http://repo.springsource.org/milestone"

请参阅 从 sbt shell 引用作用域键


0
投票

我在 Scala / ScalaJS 项目中也遇到了类似的问题。

解析器仅在添加到“子项目”时才被获取。

//this works NOT
resolvers += Resolver.sonatypeRepo("snapshots")

// this works
lazy val client = (project in file("client")).settings(
   scalaVersion := scalaV,
   ...,
   resolvers += Resolver.sonatypeRepo("snapshots"),
   ...

(sbt 0.13.15)

© www.soinside.com 2019 - 2024. All rights reserved.