Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to overwrite local stable version artifacts using publishLocal?

Tags:

sbt

I've got several projects. I use publishLocal to update the local repository. Sometimes I'm working on a couple of them in parallel and I don't want to keep updating the version numbers.

So I use publishLocal that works fine, but it issues this warning

[warn]  This usage is deprecated and will be removed in sbt 1.0.
[warn] Attempting to overwrite /home/tim/.ivy2/local/com.optrak/vrpmodel_2.11/0.8.3/ivys/ivy.xml.sha1

So presumably I'm supposed to use something else. But what?

like image 256
Tim Pigden Avatar asked Sep 27 '14 17:09

Tim Pigden


People also ask

Can I still download an artifact published using publish build artifacts?

Artifacts published using the Publish Build Artifacts task can still be downloaded using Download Build Artifacts, but we recommend using the latest Download Pipeline Artifact task instead. When migrating from build artifacts to pipeline artifacts:

What types of artifacts can I publish in a repository?

See [Resolvers] for other supported repository types. By default, the main binary jar, a sources jar, and a API documentation jar are published. You can declare other types of artifacts to publish and disable or modify the default artifacts. See the Artifacts page for details.

What is the publishlocal action used for?

The publishLocal action is used to publish your project to your Ivy local file repository, which is usually located at $HOME/.ivy2/local/. You can then use this project from other projects on the same machine.

Can this task publish artifacts to a shared folder?

A: Build artifacts are the files generated by your build. See Build Artifacts to learn more about how to publish and consume your build artifacts. Q: Can this task publish artifacts to a shared folder? A: Not currently, but this feature is planned.


Video Answer


1 Answers

It all begins as a workaround for #1156 that says (in #1156):

Basically, as of sbt 0.13.2 you can no longer republish a release if it already exists. This is quite a dangerous thing to do because it leads to broken caches all over. Only -SNAPSHOTs are allowed to be republished.

It means that you publishLocal a stable version not SNAPSHOT and the preferred option is to not overwrite stable versions.

As a workaround you can use isSnapshot := true as confirmed in @jsuereth's comment:

isSnapshot, currently, only denotes that the build can overwrite previous values.

I confirmed it myself, too, with the following build.sbt:

version := "1.0.0"

See the session:

➜  stable-version-published-twice  xsbt
JAVA_HOME=/Library/Java/JavaVirtualMachines/java8/Contents/Home
SBT_OPTS= -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -Dfile.encoding=UTF-8
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Updating {file:/Users/jacek/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to stable-version-published-twice (in build file:/Users/jacek/sandbox/stable-version-published-twice/)
> show version
[info] 1.0.0

As you may have noticed the project is at 1.0.0 version. Here goes the first publishLocal.

> publishLocal
[info] Updating {file:/Users/jacek/sandbox/stable-version-published-twice/}stable-version-published-twice...
[info] Packaging /Users/jacek/sandbox/stable-version-published-twice/target/scala-2.10/stable-version-published-twice_2.10-1.0.0-sources.jar ...
[info] Done packaging.
[info] Wrote /Users/jacek/sandbox/stable-version-published-twice/target/scala-2.10/stable-version-published-twice_2.10-1.0.0.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] :: delivering :: default#stable-version-published-twice_2.10;1.0.0 :: 1.0.0 :: release :: Sun Sep 28 22:46:10 CEST 2014
[info]  delivering ivy file to /Users/jacek/sandbox/stable-version-published-twice/target/scala-2.10/ivy-1.0.0.xml
[info] Packaging /Users/jacek/sandbox/stable-version-published-twice/target/scala-2.10/stable-version-published-twice_2.10-1.0.0-javadoc.jar ...
[info] Done packaging.
[info] Packaging /Users/jacek/sandbox/stable-version-published-twice/target/scala-2.10/stable-version-published-twice_2.10-1.0.0.jar ...
[info] Done packaging.
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/poms/stable-version-published-twice_2.10.pom
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/jars/stable-version-published-twice_2.10.jar
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/srcs/stable-version-published-twice_2.10-sources.jar
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/docs/stable-version-published-twice_2.10-javadoc.jar
[info]  published ivy to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/ivys/ivy.xml
[success] Total time: 0 s, completed Sep 28, 2014 10:46:10 PM

It went fine (as expected). Here goes the other publishLocal (that should succeed with warnings - This usage is deprecated and will be removed in sbt 1.0. - since we're republishing the stable version).

> publishLocal
[info] Wrote /Users/jacek/sandbox/stable-version-published-twice/target/scala-2.10/stable-version-published-twice_2.10-1.0.0.pom
[info] :: delivering :: default#stable-version-published-twice_2.10;1.0.0 :: 1.0.0 :: release :: Sun Sep 28 22:46:18 CEST 2014
[info]  delivering ivy file to /Users/jacek/sandbox/stable-version-published-twice/target/scala-2.10/ivy-1.0.0.xml
[warn] Attempting to overwrite /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/poms/stable-version-published-twice_2.10.pom
[warn]  This usage is deprecated and will be removed in sbt 1.0.
[warn] Attempting to overwrite /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/poms/stable-version-published-twice_2.10.pom.sha1
[warn]  This usage is deprecated and will be removed in sbt 1.0.
[warn] Attempting to overwrite /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/poms/stable-version-published-twice_2.10.pom.md5
[warn]  This usage is deprecated and will be removed in sbt 1.0.
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/poms/stable-version-published-twice_2.10.pom
[warn] Attempting to overwrite /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/jars/stable-version-published-twice_2.10.jar
[warn]  This usage is deprecated and will be removed in sbt 1.0.
[warn] Attempting to overwrite /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/jars/stable-version-published-twice_2.10.jar.sha1
[warn]  This usage is deprecated and will be removed in sbt 1.0.
[warn] Attempting to overwrite /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/jars/stable-version-published-twice_2.10.jar.md5
[warn]  This usage is deprecated and will be removed in sbt 1.0.
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/jars/stable-version-published-twice_2.10.jar
[warn] Attempting to overwrite /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/srcs/stable-version-published-twice_2.10-sources.jar
[warn]  This usage is deprecated and will be removed in sbt 1.0.
[warn] Attempting to overwrite /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/srcs/stable-version-published-twice_2.10-sources.jar.sha1
[warn]  This usage is deprecated and will be removed in sbt 1.0.
[warn] Attempting to overwrite /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/srcs/stable-version-published-twice_2.10-sources.jar.md5
[warn]  This usage is deprecated and will be removed in sbt 1.0.
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/srcs/stable-version-published-twice_2.10-sources.jar
[warn] Attempting to overwrite /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/docs/stable-version-published-twice_2.10-javadoc.jar
[warn]  This usage is deprecated and will be removed in sbt 1.0.
[warn] Attempting to overwrite /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/docs/stable-version-published-twice_2.10-javadoc.jar.sha1
[warn]  This usage is deprecated and will be removed in sbt 1.0.
[warn] Attempting to overwrite /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/docs/stable-version-published-twice_2.10-javadoc.jar.md5
[warn]  This usage is deprecated and will be removed in sbt 1.0.
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/docs/stable-version-published-twice_2.10-javadoc.jar
[warn] Attempting to overwrite /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/ivys/ivy.xml
[warn]  This usage is deprecated and will be removed in sbt 1.0.
[warn] Attempting to overwrite /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/ivys/ivy.xml.sha1
[warn]  This usage is deprecated and will be removed in sbt 1.0.
[warn] Attempting to overwrite /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/ivys/ivy.xml.md5
[warn]  This usage is deprecated and will be removed in sbt 1.0.
[info]  published ivy to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/ivys/ivy.xml
[success] Total time: 0 s, completed Sep 28, 2014 10:46:18 PM

That went as expected. The warnings are there.

Let's set isSnapshot to true to denote the stable version as changing.

NOTE I wouldn't recommend it, though, since some other code in the build could be relying on a proper isSnapshot to be false for 1.0.0.

> set isSnapshot := true
[info] Defining *:isSnapshot
[info] The new value will be used by *:deliverLocalConfiguration, *:publishConfiguration and 1 others.
[info]  Run `last` for details.
[info] Reapplying settings...
[info] Set current project to stable-version-published-twice (in build file:/Users/jacek/sandbox/stable-version-published-twice/)

Let's publishLocal the stable version again.

> publishLocal
[info] Wrote /Users/jacek/sandbox/stable-version-published-twice/target/scala-2.10/stable-version-published-twice_2.10-1.0.0.pom
[info] :: delivering :: default#stable-version-published-twice_2.10;1.0.0 :: 1.0.0 :: integration :: Sun Sep 28 22:46:44 CEST 2014
[info]  delivering ivy file to /Users/jacek/sandbox/stable-version-published-twice/target/scala-2.10/ivy-1.0.0.xml
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/poms/stable-version-published-twice_2.10.pom
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/jars/stable-version-published-twice_2.10.jar
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/srcs/stable-version-published-twice_2.10-sources.jar
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/docs/stable-version-published-twice_2.10-javadoc.jar
[info]  published ivy to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/ivys/ivy.xml
[success] Total time: 0 s, completed Sep 28, 2014 10:46:44 PM

It went without warnings. Let's try publishLocal out again.

> publishLocal
[info] Wrote /Users/jacek/sandbox/stable-version-published-twice/target/scala-2.10/stable-version-published-twice_2.10-1.0.0.pom
[info] :: delivering :: default#stable-version-published-twice_2.10;1.0.0 :: 1.0.0 :: integration :: Sun Sep 28 22:46:46 CEST 2014
[info]  delivering ivy file to /Users/jacek/sandbox/stable-version-published-twice/target/scala-2.10/ivy-1.0.0.xml
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/poms/stable-version-published-twice_2.10.pom
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/jars/stable-version-published-twice_2.10.jar
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/srcs/stable-version-published-twice_2.10-sources.jar
[info]  published stable-version-published-twice_2.10 to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/docs/stable-version-published-twice_2.10-javadoc.jar
[info]  published ivy to /Users/jacek/.ivy2/local/default/stable-version-published-twice_2.10/1.0.0/ivys/ivy.xml
[success] Total time: 0 s, completed Sep 28, 2014 10:46:46 PM

Again, no warnings - it works as advertised.

like image 142
Jacek Laskowski Avatar answered Jan 03 '23 05:01

Jacek Laskowski