4

I am using artifactory to serve the jar files. I have scala projects with SBT. SBT is not able to resolve the latest snapshots. It is always resolving the 2nd version. I mean, if I clear the particular jar files from the artifactory, I need to build twice. Only then, it is getting resolved.

Clearing the jars and after the first build, these are the arifacts :

- 1.2-SNAPSHOT
   - frameworks_2.11-1.2-20150221.064040-1-javadoc.jar
   - frameworks_2.11-1.2-20150221.064040-1-sources.jar
   - frameworks_2.11-1.2-20150221.064040-1.pom
   - frameworks_2.11-1.2-20150221.064040-2.jar
   - maven-metadata.xml
 - maven-metadata.xml

Even if the jar is present, not is not getting resolved in my local project. After building the framework jar once again, here is the artifactory list.

- 1.2-SNAPSHOT
   - frameworks_2.11-1.2-20150221.064040-1-javadoc.jar
   - frameworks_2.11-1.2-20150221.064040-1-sources.jar
   - frameworks_2.11-1.2-20150221.064040-1.pom
   - frameworks_2.11-1.2-20150221.064040-2-javadoc.jar
   - frameworks_2.11-1.2-20150221.064040-2-sources.jar
   - frameworks_2.11-1.2-20150221.064040-2.jar
   - frameworks_2.11-1.2-20150221.064040-2.pom
   - frameworks_2.11-1.2-20150221.064040-3.jar
   - maven-metadata.xml
 - maven-metadata.xml

After this, it is getting resolved. Now even if a make some changes are build the jar, it is always resolving from this only. None of the new changes will be getting reflected.

Can someone please tell me how to fix this issue ? Because of this, I need to clear the artifactory always and build the jars twice.

Yadu Krishnan
  • 3,492
  • 5
  • 41
  • 80
  • Are you using the sbt-unique-version plugin for generating the unique snapshot version of doing it by configuring the repository to use "unique snapshots"? – Dror Bereznitsky Feb 21 '15 at 15:28
  • @drorb No, I am not using it. For Snampshots, artifactory should automatically return the latest jar right ? – Yadu Krishnan Feb 23 '15 at 04:18
  • It should. However it looks like there is something wrong with the unique snapshot identifier generation which is causing the issue. In your first example, notice that the .jar file does not have the same version identifier. – Dror Bereznitsky Feb 23 '15 at 06:39
  • @drorb So, should I use sbt-unique-version plugin? That will publish to artifiactory with a unique version ? – Yadu Krishnan Feb 23 '15 at 08:48

1 Answers1

5

The problem is with the unique snapshot version that is calculated for the jar artifact. While the other artifacts get the version 2.11-1.2-20150221.064040-1 the jar artifact has a different version - 2.11-1.2-20150221.064040-2.
The root cause for this situation lies with the combination of Artifactory behavior when the repository Maven Snapshot Version Behavior is configured for unique snapshots and the way SBT deploys the artifacts. See the answer to this stackoverflow question for a good explanation of the problem.
If you would like to use unique snapshots than you could:

1) Apply the solution described in the Artifactory mailing list (based on the mentioned stackoverflow question/answer)
You will need to define the repository in the following way in order to pass the build.timestamp matrix param:

publishTo := Some("Artifactory Realm" at "http://localhost:8081/artifactory/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)

2) Try using sbt-unique-version. It this case you will need to change the Maven Snapshot Version Behavior to "Deployer".

Community
  • 1
  • 1
Dror Bereznitsky
  • 20,048
  • 3
  • 48
  • 57