Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT cannot find snapshots in an Artifactory maven repository

Tags:

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

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?

like image 505
mseddon Avatar asked May 10 '14 17:05

mseddon


1 Answers

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.

like image 100
mseddon Avatar answered Sep 18 '22 18:09

mseddon