【问题标题】:SBT depend on specific snapshot versionSBT 取决于特定的快照版本
【发布时间】:2012-08-26 04:10:57
【问题描述】:

我有多个快照版本的工件,例如artifact-0.1-20120831.103456-5

我的项目取决于特定的快照版本。 如果我告诉 SBT 下载 0.1-20120831.103456-5 版本而不是 0.1-SNAPSHOT 它会在更新任务上失败。

// build.sbt
libraryDependencies ++= Seq(
"com.example" % "smith" % "0.1-20120906.110133-36")

// sbt update
[warn] ==== My Repo snapshots: tried
[warn]   http://repo.localhost/snapshots/com/example/smith/0.1-20120906.110133-36/commons-0.1-20120906.110133-36.pom

如何在http://repo.localhost/snapshots/com/example/smith/0.1-SNAPSHOT 目录中制作 SBT 搜索工件但使用唯一的快照版本?

【问题讨论】:

  • 嗨,这应该可以正常工作。您能否编辑您的问题并包含您的 SBT 文件中的确切代码以及更新任务期间的错误?
  • @asflierl & @rs_atl,我添加了来自build.sbtsbt update output 的sn-ps。
  • 这个[帖子可能会有所帮助][1] [1]:stackoverflow.com/questions/1368625/…

标签: scala maven sbt


【解决方案1】:

添加 除了唯一的版本插件,sbt 还有 aether-deploy 插件(见下文)。

unique version plugin 可以让您按照自己的意愿解决工件。引自页面:

如何指向它

"0.1.0" or "0.1.0-20120602-073010" you can always use the static version number.
"0.1.0-+" selects the latest 0.1.0 snapshot.
"latest.integration" selects the latest revision regardless of its status.
"latest.milestone" selects the latest revision with either Milestone or Release status.
"latest.release" selects the latest with the Release status.

但您还必须使用此插件发布,因为工件以与版本有关的不同方式发布:在您的示例中,工件不会存储在 0.1-SNAPSHOT 目录下,而是存储在 0.1-20120831.103456-5

加法 还有使用Aetheraether-deploy plugin(Aether 提供了与Maven 存储库交互的标准方式)。问题是这个插件目前仅适用于部署(正如插件名称所暗示的那样)。也许作者计划对其进行扩展,以便它也可以用于解析(听起来对我来说是一个有用的功能)。如果您无法使用唯一版本插件发布(例如,如果快照不归您所有),那么您可以在 sbt forum 处询问。

因此,我无法提供与 maven 一样适用于您的用例的解决方案,但希望它能为您和其他人提供一些有用的信息。

【讨论】:

  • 我的 jenkins 正在部署我要为其指定快照版本的包,而 sbt-unique version-plugin 解决了我的问题。谢谢!
  • 动态修订版“0.1.0-+”在 sbt 中开箱即用,不需要 sbt-unique-version。
【解决方案2】:

一个丑陋的解决方法是使用 install:instal-file 将快照工件安装在您自己的 groupId(比如 smith.external)中,而不是作为 SNAPSHOT 并声明所需的版本号,而不是声明快照的用法。

由于您不希望版本发生变化,因此您可以依赖它,直到您让它与提供的稳定版本(和常规 groupId)一起工作

【讨论】:

    【解决方案3】:

    不是最好的解决方案,但您可以尝试使用 Ivy (see apache docs) 提供的冲突管理器。例如,默认使用 'latest-revision' 并且 'latest-compatible' 管理器应该禁止任何依赖冲突。

    虽然设置起来并不容易,但 google sbt 组的someone 发布了以下规则:

    def addConflictManager(org: String, name: String, conflictManager: String) =
      ivyModule <<= (ivyModule, streams) map { (module, s) =>
        module.withModule(s.log) { (ivy, desc, _) =>
            import _root_.org.apache.ivy.{core, plugins}
            import core.module.id.ModuleId
            import plugins.matcher.PatternMatcher
    
            desc.addConflictManager(
              ModuleId.newInstance(org, name),
              ivy.getSettings.getMatcher(PatternMatcher.EXACT),
              ivy.getSettings.getConflictManager("latest-compatible"))
            module
        }
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多