【问题标题】:how to download sbt plugins from nexus?如何从 nexus 下载 sbt 插件?
【发布时间】:2016-03-30 22:38:07
【问题描述】:

我遇到了从我的 corp nexus 获取插件依赖项的问题。具体来说,似乎 addSbtPlugin 的解析器正在路径中寻找 scala 版本和 sbt 版本,但我找不到在 nexus 工件上传选项中指定的方法。

我的 plugins.sbt 中定义了以下插件:

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.8")

// web plugins

addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.0.0")

我还有以下用于存储库配置的 .sbt-repositories 文件:

[repositories]
  nexus1: https://nexus.somecorp.com/nexus1/content/repositories/central/content/
  nexus2: https://nexus.somecorp.com/nexus2/content/repositories/central/content/

我是这样运行 sbt 的:

sbt run -Dsbt.override.build.repos=true -Dsbt.repository.config=.sbt-repositories

我所有的常规库依赖项都可以正常下载,但是通过 addSbtPlugin 添加的 sbt 插件不能 - 他们正在寻找不存在的工件的路径(scala 版本和 sbt 版本)。

例如:

[warn] module not found: com.typesafe.play#sbt-plugin;2.3.8
[warn] ==== nexus1: tried
[warn] https://nexus.somecorp.com/nexus1/content/repositories/central/content/com/typesafe/play/sbt-plugin_2.10_0.13/2.3.8/sbt-plugin-2.3.8.pom

不起作用,因为 pom 文件的正确路径应该是:

https://nexus.somecorp.com/nexus1/content/repositories/central/content/com/typesafe/play/sbt-plugin_2.10_0.13/2.3.8/sbt-plugin_2.10_0.13-2.3.8.pom

我还尝试使用 ivy 的参数将特定的解析器添加到我的 .sbt-repositories 文件中:

nexus1: https://nexus.somecorp.com/nexus1/content/repositories/central/content/, [organization]/[module]_[scalaVersion]_[sbtVersion]/[revision]/[module]_[scalaVersion]_[sbtVersion]-[artifact](-[classifier]).[ext]

但这也不起作用,原因有两个:

  1. [组织] 解析为 ex。 com.typesafe.play 不适合 nexus 的 com/typesafe/play
  2. 我什至尝试对组织值进行硬编码,但随后 sbt 抱怨工件的 pom 文件与 sbt 和 scala 版本不匹配(尚未找到在 nexus 或 pom 文件中指定这些内容的方法)
  3. .[ext] 解析为常春藤的 .xml

我如何使用 sbt 插件和我的仓库?

万一这很重要,我正在使用 sbt 0.13,并且现在已经多次阅读 sbt 文档来尝试解决这个问题。

【问题讨论】:

    标签: scala sbt nexus


    【解决方案1】:

    你可以添加

    resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
    

    到您的plugins.sbt。另请记住,.sbt 文件中的每一行都需要用两个换行符分隔。

    【讨论】:

    • 不幸的是,这并没有帮助,因为我需要从 nexus 下载 sbt 插件,然后我们遇到与上述相同的问题......
    • 可能是Plugin.scala 并签入使用自定义存储库所需的代码?
    • 有没有机会知道与让 sbt 尊重我的 plugin.scala + 相关的文档,并且仍然使用 addSbtPlugin?
    • 它与任何其他.scala 构建文件相同。您基本上是在指定元元项目。
    • 将对其进行调查并报告...同时,我收到了使用常春藤代理设置 nexus 的建议
    猜你喜欢
    • 2012-04-10
    • 2017-06-18
    • 2015-12-23
    • 2012-06-09
    • 2014-11-14
    • 1970-01-01
    • 1970-01-01
    • 2020-01-22
    • 2018-09-12
    相关资源
    最近更新 更多