如何使用publishLocal覆盖本地稳定版本工件?

时间:2014-09-27 17:41:49

标签: sbt

我有几个项目。我使用publishLocal来更新本地存储库。有时我正在并行处理其中的几个,我不想继续更新版本号。

所以我使用publishLocal工作正常,但会发出此警告

[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

所以我想应该使用别的东西。但是什么?

1 个答案:

答案 0 :(得分:26)

这一切都以a workaround for #1156开头{(3 {3}})开始:

  

基本上,从sbt 0.13.2起,你不能再重新发布一个版本   它已经存在。这是非常危险的事情,因为它   导致全部破碎的缓存。只允许-SNAPSHOT   转载。

这意味着您publishLocal是稳定版本而非SNAPSHOT,首选选项是覆盖稳定版本。

作为一种变通方法,您可以使用#1156中确认的isSnapshot := true

  

isSnapshot,目前只表示构建可以覆盖   以前的价值观。

我自己也确认了以下build.sbt

version := "1.0.0"

参见会议:

➜  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

您可能已经注意到该项目位于1.0.0版本。这是第一个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

一切顺利(如预期的那样)。这是另一个publishLocal(应该成功发出警告 - This usage is deprecated and will be removed in sbt 1.0. - 因为我们正在重新发布稳定版本。)

> 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

这与预期一致。警告就在那里。

我们将isSnapshot设置为true以将稳定版本表示为更改

注意但我不建议这样做,因为构建中的其他一些代码可能依赖于isSnapshotfalse 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/) }。

publishLocal

让我们再次> 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 稳定版本。

publishLocal

没有警告。我们再试一次> 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

{{1}}

同样,没有任何警告 - 它的效果与宣传的一样。