SBT 解析因 Ivy 额外属性而失败

2024-02-09

我正在尝试将 Ivy 额外属性与 SBT 一起使用。我有两个模块:foo-model 和 foo-api。对于他们两个,我将其添加到build.sbt:

projectID <<= projectID { id =>
   id extra("branch" -> "master-api-model-separation")
}

Foo-model 正在发布到 Artifactory(通过 sbt 发布)。发布的 POM 文件如下所示:

<?xml version='1.0' encoding='UTF-8'?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.foo</groupId>
    <artifactId>foo-model</artifactId>
    <packaging>jar</packaging>
    <description>foo-model</description>
    <version>1.0</version>
    <name>foo-model</name>
    <organization>
        <name>com.foo</name>
    </organization>
    <properties>
        <branch>master-api-model-separation</branch>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.10.3</version>
        </dependency>
        ...

然后我需要 foo-api 来使用 foo-model,所以我将其添加到其 build.sbt 中:

def appDependencies = Seq(
    "com.foo"%"foo-model"%"1.0" extra( "branch" -> "master-api-model-separation" ) changing(),
    ...

但是,当我尝试运行 SBT(更新或包)时,我得到以下信息:

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.foo#foo-model;1.0: java.text.ParseException: inconsistent module descriptor file found in 'http://xdctest-app-01:8081/artifactory/foo-master/com/foo/foo-model/1.0/foo-model-1.0.pom': bad branch found in http://xdctest-app-01:808/artifactory/foo-master/com/foo/foo-model/1.0/foo-model-1.0.pom: expected='master-api-model-separation' found='null';
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]          com.foo:foo-model:1.0 (branch=master-api-model-separation)
[warn] 

并且有一个异常和一个错误。我尝试使用 SBT 0.13.0 和 0.13.1。

我没有设法获得更有用的调试输出。我只从最后一个命令得到这个:

[debug]                 tried http://xdctest-app-01:8081/artifactory/foo-master/com/foo/foo-model/1.0/foo-model-1.0.jar
[debug] com.foo#foo-model;1.0 is changing, but has not changed: will trust cached artifacts if any
[debug] Deleting additional old artifacts from cache for changed module com.foo#foo-model;1.0:
[debug]         
[error]         foo-master: bad branch found in http://xdctest-app-01:8081/artifactory/foo-master/com/foo/foo-model/1.0/foo-model-1.0.pom: expected='master-api-model-separation' found='null'
[debug] problem occurred while resolving dependency: com.foo#foo-model;1.0 {compile=[default(compile)]} with foo-master: java.text.ParseException: inconsistent module descriptor file found in 'http://xdctest-app-01:8081/artifactory/foo-master/com/foo/foo-model/1.0/foo-model-1.0.pom': bad branch found in http://xdctest-app-01:8081/artifactory/foo-master/com/foo/foo-model/1.0/foo-model-1.0.pom: expected='master-api-model-separation' found='null';
[debug]         at org.apache.ivy.plugins.resolver.BasicResolver.checkDescriptorConsistency(BasicResolver.java:640)
[debug]         at org.apache.ivy.plugins.resolver.BasicResolver.getDependency(BasicResolver.java:284)
[debug]         at org.apache.ivy.plugins.resolver.IBiblioResolver.getDependency(IBiblioResolver.java:503)
[debug]         at sbt.ConvertResolver$PluginCapableResolver$1.sbt$ConvertResolver$DescriptorRequired$$super$getDependency(ConvertResolver.scala:28)
...

上述URL处的POM文件确实存在,其内容如上所引用,即:它具有值为 master-api-model-separation 的分支属性。

我究竟做错了什么?


Ivy 额外属性可能需要 Ivy 存储库才能工作,如果您使用 Artifactory,这应该可以工作。 sbt 确实在内部使用额外的属性来编码 Maven 存储库上的 Scala 版本,但我不知道这些位是否公开。

这是我用作测试的内容。

构建.sbt

lazy val root = (project in file(".")).
  settings(
    bintrayReleaseOnPublish in ThisBuild := false
  )

val customPattern = "[organisation]/[module]/" +
  "(scala_[scalaVersion]/)(sbt_[sbtVersion]/)(branch_[branch_name]/)" +
  "[revision]/[type]s/[artifact](-[classifier]).[ext]"

lazy val libExtra = (project in file("libExtra")).
  settings(
    version := "0.1",
    scalaVersion := "2.11.7",
    organization := "com.example",
    name := "somelibrary",
    projectID := {
      val previous = projectID.value
      previous.extra("branch_name" -> "master-api-model-separation")
    },
    licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
    bintrayVcsUrl := Some("[email protected] /cdn-cgi/l/email-protection:you/your-repo.git"),
    bintrayOrganization := None,
    bintrayRepository := "test-test-test",
    publishMavenStyle := false,
    checksums in publish := Nil,
    publishTo := {
      Some(URLRepository("test-bintray-ivy", Patterns(
        s"https://api.bintray.com/content/you/${bintrayRepository.value}/" +
        customPattern +
        s";bt_package={normalizedName.value};bt_version={version.value}")))
    }
  )

lazy val app = (project in file("app")).
  settings(
    scalaVersion := "2.11.7",
    organization := "foo",
    libraryDependencies += "com.example" %% "somelibrary" % "0.1" extra("branch_name" -> "master-api-model-separation"),
    resolvers += Resolver.url("test-bintray-ivy", url("https://dl.bintray.com/you/test-test-test/"))(Patterns(
      customPattern)),
    fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project")
  )

项目/build.properties

sbt.version=0.13.8

项目/bintray.sbt

addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0")

libExtra/src/main/scala/Something

object Something

一半的设置基本上设置为发布到虚拟 Bintray 存储库以进行测试。以下是一些注意事项:

  • 名字branch已被占用,所以我认为您无法使用它。我是苏金branch_name.
  • publishTo 包含一个自定义工件模式,其中包含嵌入在 URL 中的额外属性。

Using app我能够从 Bintray 解析 JAR:

app> compile
[info] Updating {file:/Users/xxx/extra-attribute-test/}app...
[info] Resolving jline#jline;2.12.1 ...
[info] downloading https://dl.bintray.com/eed3si9n/test-test-test/com/example/somelibrary_2.11/branch_master-api-model-separation/0.1/jars/somelibrary_2.11.jar ...

未来的改进:这是我尝试使用 Maven 存储库来做到这一点的尝试 -https://gist.github.com/eed3si9n/a6de413b1ced84649ae0 https://gist.github.com/eed3si9n/a6de413b1ced84649ae0

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SBT 解析因 Ivy 额外属性而失败 的相关文章

  • 如何缓存 sbt TaskKey 的结果?

    我有一项昂贵的任务需要在测试中参考 lazy val exampleSources TaskKey Seq File exampleSources for use in tests exampleSources updateClassifi
  • SBT停止运行而不退出

    如何在不退出的情况下终止 SBT 中的运行 我正在尝试 CTRL C 但它退出 SBT 有没有办法在保持 SBT 打开的情况下仅退出正在运行的应用程序 从 sbt 版本 0 13 5 开始 您可以添加到您的 build sbt cancel
  • 如何将tools.jar添加为sbt中的“动态依赖项”。是否可以?

    我需要在我的项目中使用tools jar 但是将其打包在jar中没有多大意义 因为用户已经拥有它 那么 是否可以将其用作 动态依赖项 意思是 我希望我的代码compile通过使用tools jar文件发现于my JAVA HOME 但我不希
  • 显示从 SBT 构建发出的确切 scala 命令

    当我针对本地版本的 Scala 构建我的 相对复杂的 SBT 项目时 出现以下错误 scalac error bad option Ydelambdafy method 这可能是一个错误scalac或我们的构建文件 但是 我无法在调用时重现
  • SBT、依赖项、类路径和编辑器

    我最近将 sbt 设置更新到版本 0 11 如您所知 新的 SBT 使用 ivy2 文件夹来存储 缓存所有检索到的 jar 文件 我正在使用 IntelliJ 我想知道将依赖项导入编辑器类路径的推荐方法是什么 一种选择是手动访问 ivy2
  • 配置 sbt 项目以在“sbt run”中包含外部 Main 方法

    创建一个依赖于外部 jar 的 sbt 项目对我来说很常见 并且旨在使用外部 jar 中的 Main 方法运行 目前 我只是使用 run main xxx 运行它 但我更希望能够将 Main 方法包含在 sbt 提供的 run 选项列表中
  • 如何覆盖 sbt 中对某些任务的依赖

    我想在某些任务中覆盖对项目的依赖 我有一个使用 Spark 的 sbt 多项目 lazy val core Some Project val sparkLibs Seq org apache spark spark core 1 6 1 v
  • 如何防止gitlab ci每次都下载sbt?

    我们有一个play2 scala我们正在使用 gitlab ci 构建的应用程序 Our gitlab ci yml 至少重要部分 如下所示 image hseeberger scala sbt variables SBT GLOBAL B
  • sbt-proguard 与 play 2.2.3

    我们使用 play 2 2 3 开发了一个 Web 应用程序 并希望对其进行混淆 我正在尝试使用sbt proguard https github com sbt sbt proguard插入 我把下面的行PROJECT FOLDER pr
  • IntelliJ IDEA 不会从 SBT 项目加载 Lift 库

    我通过创建了一个空白项目sbt使用最基本的指南 具体来说 gt cd xyz gt sbt here we create a new project w Scala 2 8 1 gt lift is org lifty lifty 1 6
  • 如何编写 sbt 插件来通过代理启动应用程序

    我想在开源之前为我的项目创建一个 sbt 插件 该项目在应用程序运行开始时附加一个 Java 代理 以对其进行各种类型的分析 代理写出文本文件以供以后处理 我希望能够编写一个 sbt 插件 有一个替代方案run called runWith
  • Scala SBT 版本依赖性二进制兼容性错误 scala-xml

    我有一个在 GitHub 上托管的项目 我使用 scala steward 来保持我的插件和依赖项最新 这在一段时间内有效 但现在使用此类自动更新却变成了一场噩梦 事情是这样的 在我的plugins sbt中 我依赖于scoverage 它
  • 如何使用 `ProjectRef` 来引用 sbt 1.x 中的本地项目?

    其他答案中有很多含糊不清的内容 或者涉及到更旧版本的 sbt 即 0 12 x 但似乎没有人真正回答这个问题 鉴于我有一个文件夹 并且我已经运行 sbt new scala scala seed g8 name Scala Seed Pro
  • sbt:编译测试时设置特定的 scalacOptions 选项

    通常我使用这组选项来编译 Scala 代码 scalacOptions Seq deprecation encoding UTF 8 feature unchecked language higherKinds language impli
  • 如何设置 jacoco4sbt 来处理 Play 中主模块和子模块中的类?

    我有一些问题要解决雅可可4sbt https github com sbt jacoco4sbt正在使用我的 Play 2 3 4 项目 我的项目由 3 个子模块组成 common api and frontend并且没有代码app根文件夹
  • Build.scala中%和%%符号含义

    我是新来玩的 Framework 2 1 java版本 并且没有scala经验 我不明白什么是以及什么是 and 在 Build scala 中表示 我用谷歌搜索了它们但找不到它们的含义 在我的 Build scala 文件中 我有 org
  • 如何通过 SBT 项目依赖项将 sbt-web 输出与 xsbt-web-plugin 一起使用?

    我正在尝试在没有播放框架的情况下使用 sbt web 插件 而是使用 xsbt web plugin 构建一个 web 应用程序 我已经让 sbt web 插件在处理资产管道时正确工作 并让它创建有效的 webjar 输出 通过 packa
  • 如何更改 SBT 命令内的设置?

    我想要一个命令publish snapshot这将运行publish修改后的任务version设置 该设置将在执行命令时计算 我想出了如何获取当前值version内部命令 以及Project runTask task scope 似乎是调用
  • scala sbt 在多项目上测试运行设置和清理命令一次

    我知道我可以通过修改 testOptions 在 sbt 中添加设置和清理代码以用于测试阶段 例如 val embedMongoTestSettings Seq Setting Seq testOptions in Test Tests S
  • sbt 使用不同选项编译任务

    我有一个基本的 sbt 项目 我想用相同的源文件打包两个 jar 但使用不同的选项进行编译 因此 一个项目 2 个编译 但具有不同的选项 scalacOptions 和 2 个 jar 作为输出 我不想执行 sbt 两次 更改选项 有人有想

随机推荐