SBT 在 Artifactory Maven 存储库中找不到快照 [英] SBT cannot find snapshots in an Artifactory maven repository

查看:52
本文介绍了SBT 在 Artifactory Maven 存储库中找不到快照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始尝试使用 Scala 和 sbt 设置工作流程,但我的存储库遇到了问题.我正在尝试发布一个由两个项目组成的简单测试库,并从另一个程序中使用它.

I'm just starting out trying to set up a workflow with scala and sbt, and I'm having trouble with my repository. I am trying to publish a simple test library, which is composed of two projects, and use it from another program.

我的源库的构建包含以下内容:

My source library's build contains the following:

val sharedSettings = Seq(
  name := "test-lib",
  organization := "com.example",
  version := "0.1-SNAPSHOT",
  scalaVersion := "2.11.0",
  publishTo := Some("Artifactory Realm" at "http://localhost:8081/artifactory/libs-snapshot-local"),
  publishMavenStyle := true,
  credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
)

lazy val root = project.in(file(".")).settings(sharedSettings: _*).aggregate(child1, child2)

lazy val sharedCode = project.settings(sharedSettings: _*)

val child1Settings = sharedSettings ++ Seq(unmanagedSourceDirectories in Compile <++= (unmanagedSourceDirectories in sharedCode) in Compile)

val child2Settings = sharedSettings ++ Seq(unmanagedSourceDirectories in Compile <++= (unmanagedSourceDirectories in sharedCode) in Compile)

lazy val child1 = project.settings(child1Settings: _*)

lazy val child2 = project.settings(child2Settings: _*)

我可以运行 sbt publish,它会在 repo 中创建目录 com/example/test-lib/XXX.

I can run sbt publish okay, and it creates the directory com/example/test-lib/XXX in the repo.

在我的测试程序中,我有以下内容:

In my test program, I have the following:

scalaVersion := "2.11.0",

resolvers += "Artifactory Realm" at "http://localhost:8081/artifactory/libs-snapshot-local",

libraryDependencies += "com.example" %% "test-lib" % "0.1-SNAPSHOT"

当测试程序试图编译时,它无法解析com.example,原因如下:

When the test program attempts to compile, it cannot resolve com.example, because of the following:

[warn] ==== Artifactory Realm: tried
[warn]   http://localhost:8081/artifactory/libs-snapshot-local/com/example/test-lib_2.11/0.1-SNAPSHOT/test-lib_2.11-0.1-SNAPSHOT.pom

查看存储库目录本身,我的 pom 文件上多了一个时间戳:

Looking at the repository directory itself, I am getting an additional timestamp on my pom files:

test-lib_2.11-0.1-20140510.183027-1.pom               10-May-2014 19:30  793 bytes
test-lib_2.11-0.1-20140510.183027-2.pom               10-May-2014 19:30  793 bytes
...
test-lib_2.11-0.1-20140510.183121-9.pom               10-May-2014 19:31  793 bytes

目录中的maven-metadata.xml引用这些还行,sbt是直接找没有时间戳的pom文件,找不到.pom 文件包含正确的信息.

maven-metadata.xml in the directory is referencing these okay, sbt is looking directly for a pom file without a timestamp and cannot find it. The pom files contain the correct information.

我做错了什么?

推荐答案

问题不在于我的 sbt 配置,而在于我的存储库服务器.

The issue was not with my sbt configuration after all, but with my repository server.

我正在使用 Artifactory,默认情况下,快照存储库配置为使用唯一快照".这些快照的文件名在发布时被修改为包含时间戳,sbt 13.x 似乎无法理解.

I'm using Artifactory, and the snapshots repository was configured to use "unique snapshots" by default. The filenames of these snapshots are modified as they are published to include a timestamp, which sbt 13.x doesn't seem to understand.

将存储库的Maven Snapshot Version Behaviour"从Unique"更改为Nonunique"后,一切都开始工作了.

After changing the repository's "Maven Snapshot Version Behaviour" from "Unique" to "Nonunique", everything started to work.

这篇关于SBT 在 Artifactory Maven 存储库中找不到快照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆