2014-09-27 73 views
14

我有几个项目。我使用publishLocal来更新本地存储库。有时我正在并行处理其中的几个,我不想更新版本号。如何使用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 

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

+0

你可以分享什么依赖项目?他们都属于一个应用程序单元吗?它们之间的依赖程度如何?你可以使用'ProjectRef'来代替。 – 2014-09-27 22:24:22

+0

这些项目都在一个应用程序的同一个家族中,但是因为有些需要akka而有些不需要而被拆分。一些将在android上使用。在直接集合中存在关系的有向图 - 即不存在循环依赖关系。他们都坐在山姆git回购(不知道这是否有任何区别),并在磁盘上在同一(空)父级的子目录。 – 2014-09-29 07:00:07

回答

21

这一切都始于为a workaround for #1156,说(在#1156):

基本上,SBT 0.13.2,你可以不再重新发布,如果 它已经存在一个释放。这是一件非常危险的事情,因为它会导致破碎的缓存全部结束。只有-SNAPSHOT被允许为 重新发布。

这意味着你publishLocal一个稳定的版本不SNAPSHOT和最佳的选择是覆盖的稳定版本。

作为一种变通方法,您可以使用isSnapshot := true作为@jsuereth's comment证实:

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表示稳定版本为变更

注意我不会推荐它,虽然,因为在构建一些其他的代码可以依靠适当的isSnapshotfalse1.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

谢谢,需要在ThisBuild中设置isSnapshot:= true,用于多项目构建。 – virtualeyes 2016-11-30 23:10:37