From 4668faff7c48e30753cedbb554017cc03a3d4477 Mon Sep 17 00:00:00 2001 From: Michael Pollmeier Date: Thu, 23 Nov 2017 11:52:07 +1300 Subject: [PATCH] don't require publishTo specified if publishArtifact is `false` Even with `publishArtifact := false` the user is still forced to define a (dummy) resolver that's never used, e.g. `publishTo := { Some("publishMeNot" at "https://publish/me/not") }` Otherwise the following error is thrown: ``` publish [error] java.lang.RuntimeException: Repository for publishing is not specified. [error] at scala.sys.package$.error(package.scala:27) [error] at sbt.Classpaths$.$anonfun$getPublishTo$1(Defaults.scala:2436) [error] at scala.Option.getOrElse(Option.scala:121) [error] at sbt.Classpaths$.getPublishTo(Defaults.scala:2436) [error] at sbt.Classpaths$.$anonfun$ivyBaseSettings$48(Defaults.scala:1917) ``` --- main/src/main/scala/sbt/Defaults.scala | 6 ++++-- .../publishTo-not-required-if-not-publishing.md | 12 ++++++++++++ sbt/src/sbt-test/project/no-publish/build.sbt | 3 +++ sbt/src/sbt-test/project/no-publish/test | 1 + 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 notes/1.2.0/publishTo-not-required-if-not-publishing.md create mode 100644 sbt/src/sbt-test/project/no-publish/build.sbt create mode 100644 sbt/src/sbt-test/project/no-publish/test diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 1f2dcfd3a..3bc4a3a20 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -1935,8 +1935,10 @@ object Classpaths { if (isSnapshot.value) "integration" else "release", ivyConfigurations.value.map(c => ConfigRef(c.name)).toVector, packagedArtifacts.in(publish).value.toVector, - checksums.in(publish).value.toVector, - getPublishTo(publishTo.value).name, + checksums.in(publish).value.toVector, { //resolvername: not required if publishTo is false + val publishToOption = publishTo.value + if (publishArtifact.value) getPublishTo(publishToOption).name else "local" + }, ivyLoggingLevel.value, isSnapshot.value ) diff --git a/notes/1.2.0/publishTo-not-required-if-not-publishing.md b/notes/1.2.0/publishTo-not-required-if-not-publishing.md new file mode 100644 index 000000000..b2c4ca842 --- /dev/null +++ b/notes/1.2.0/publishTo-not-required-if-not-publishing.md @@ -0,0 +1,12 @@ + +[@mpollmeier]: https://github.com/mpollmeier + +[#3760]: https://github.com/sbt/sbt/pull/3760 + +### Fixes with compatibility implications + +### Improvements + +### Bug fixes + +- Remove requirement on `publishTo` if `publishArtifact` is false. [#3760][] by [@mpollmeier][] diff --git a/sbt/src/sbt-test/project/no-publish/build.sbt b/sbt/src/sbt-test/project/no-publish/build.sbt new file mode 100644 index 000000000..36e1cdfd8 --- /dev/null +++ b/sbt/src/sbt-test/project/no-publish/build.sbt @@ -0,0 +1,3 @@ +// this is supposed to do nothing, and more importantly: not fail +// https://github.com/sbt/sbt/pull/3760 +publishArtifact := false diff --git a/sbt/src/sbt-test/project/no-publish/test b/sbt/src/sbt-test/project/no-publish/test new file mode 100644 index 000000000..c78ab3f9f --- /dev/null +++ b/sbt/src/sbt-test/project/no-publish/test @@ -0,0 +1 @@ +> publish \ No newline at end of file