Frage

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: _*)

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"

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

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 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.

What am I doing wrong?

War es hilfreich?

Lösung

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

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.

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

Andere Tipps

actually, the inconsistency of timestamp & build number suffix in maven-metadata.xml and jar/pom files genereated by sbt publish lead to such error.

enter image description here

with the following plugin sbt-maven-resolver during deployment procedure, the suffix will be kept same, looks like:

enter image description here

currently, adding this plugin on the deployment side (once the timestamp & build suffix are same, both sbt/maven can find the snapshots):

in plugins.sbt

addSbtPlugin("org.scala-sbt" % "sbt-maven-resolver" % "0.1.0")

hope to solve your case.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top