Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT Publish only when version does not exist

Tags:

scala

sbt

nexus

ivy

So I have a job in my CI app that publishes to Nexus when a change pushed to develop on an app.

Is there a way to make ./sbt publish idempotent? Because occasionally we want to run the job again because of a temporary issue, and it'll error out with:

[16:31:24]java.io.IOException: destination file exists and overwrite == false
[16:31:24]  at org.apache.ivy.plugins.repository.url.URLRepository.put(URLRepository.java:75)
[16:31:24]  at org.apache.ivy.plugins.repository.AbstractRepository.put(AbstractRepository.java:130)
[16:31:24]  at sbt.ConvertResolver$ChecksumFriendlyURLResolver$class.put(ConvertResolver.scala:78)
[16:31:24]  at sbt.ConvertResolver$PluginCapableResolver$1.put(ConvertResolver.scala:103)
[16:31:24]  at org.apache.ivy.plugins.resolver.RepositoryResolver.publish(RepositoryResolver.java:216)

Because we've not bumped the version number. Right now I'm going with a hacky:

./sbt publish || true

So the job doesnt exit 1 and error in CI. Is there a better way?

like image 526
Peter Souter Avatar asked Dec 17 '14 16:12

Peter Souter


1 Answers

You can use

isSnapshot := true

This only allows a file to be overwritten. It seems likely that this behavior may change in the future.

like image 127
Christopher Helck Avatar answered Sep 20 '22 03:09

Christopher Helck