【发布时间】:2014-06-28 08:29:14
【问题描述】:
我刚开始尝试使用 scala 和 sbt 设置工作流程,但我的存储库遇到了问题。我正在尝试发布一个由两个项目组成的简单测试库,并在另一个程序中使用它。
我的源库构建包含以下内容:
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。
在我的测试程序中,我有以下内容:
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,原因如下:
[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 文件上获得了一个额外的时间戳:
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是引用这些ok的,sbt是直接找一个没有时间戳的pom文件,找不到。 pom 文件包含正确的信息。
我做错了什么?
【问题讨论】:
-
它正在寻找
my-repo作为一个常春藤风格的回购,但你已经在你的样本中正确地将它定义为一个 Maven 风格的回购。但是,您的输出显示为my-repo,而您的示例显示为Artifactory Realm,因此您在发布此内容时已经修改了一些内容。我们可以看看原件,这样我们就知道它的名字my-repo来自哪里。 -
好收获!我之前在搞乱 ivy vs maven repos 并且一定是从错误的控制台窗口复制了它......实际上我更了解这个问题并且会调整我的问题以反映这一点。
-
尝试将 publishMavenStyle := true 添加到您的 build.sbt 中,这可能会在您发布时删除时间戳。