sbt-release
sbt-release copied to clipboard
Can't release on a multi project build due to `publishTo`
My folder structure:
- root
- project A (won't be released)
- project B (dependsOn project A and will be released)
Running in the interactive console with the root project scope:
> release with-defaults skip-tests
Gives:
java.lang.RuntimeException: Repository for publishing is not specified.
at scala.sys.package$.error(package.scala:27)
at sbt.Classpaths$$anonfun$getPublishTo$1.apply(Defaults.scala:1544)
at sbt.Classpaths$$anonfun$getPublishTo$1.apply(Defaults.scala:1544)
at scala.Option.getOrElse(Option.scala:120)
at sbt.Classpaths$.getPublishTo(Defaults.scala:1544)
at sbtrelease.ReleaseStateTransformations$$anonfun$publishArtifacts$1.apply(ReleaseExtra.scala:260)
at sbtrelease.ReleaseStateTransformations$$anonfun$publishArtifacts$1.apply(ReleaseExtra.scala:256)
at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$4$$anonfun$apply$4.apply(ReleasePlugin.scala:167)
at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$4$$anonfun$apply$4.apply(ReleasePlugin.scala:167)
at scala.collection.immutable.List.foreach(List.scala:318)
at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$4.apply(ReleasePlugin.scala:167)
at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$4.apply(ReleasePlugin.scala:132)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
at sbt.Command$.process(Command.scala:93)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
at sbt.State$$anon$1.process(State.scala:184)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.MainLoop$.next(MainLoop.scala:96)
at sbt.MainLoop$.run(MainLoop.scala:89)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:68)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:63)
at sbt.Using.apply(Using.scala:24)
at sbt.MainLoop$.runWithNewLog(MainLoop.scala:63)
at sbt.MainLoop$.runAndClearLast(MainLoop.scala:46)
at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:30)
at sbt.MainLoop$.runLogged(MainLoop.scala:22)
at sbt.StandardMain$.runManaged(Main.scala:54)
at sbt.xMain.run(Main.scala:29)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:41)
at xsbt.boot.Boot$.main(Boot.scala:17)
at xsbt.boot.Boot.main(Boot.scala)
Running in the interactive console with the root project scope:
> publish
Without recurring to sbt-release
the publish succeeds. With the usage of this plugin the publishTo
setting is somehow lost...
Project configuration is as follows
val commonSettings = Seq(
// other settings
publishTo := {
val nexus = "http://mynexushost/nexus/content/repositories/"
if (isSnapshot.value) {
Some("snapshots" at nexus + "snapshots")
} else Some("releases" at nexus + "releases")
},
// other settings
lazy val root = (project in file(".").settings(commonSettings: _*)
lazy val projectA = (project in file("projectA").settings(commonSettings: _*)
lazy val projectB = (project in file("projectB").dependsOn(projectA).settings(commonSettings: _*)
@xuwei-k, is there any plan to work on this issue? The plugin should definitely check if skip in publish
is set to true
during this check... This pretty much prevents users to use the default release process on multi project builds.
For other people having the same problem, copying the default process and replacing publishArtifacts
with releaseStepCommandAndRemaining("publish")
makes the plugin work, since the latter does not check if the publishTo
is defined beforehand.
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("publish"),
setNextVersion,
commitNextVersion,
pushChanges)
@ruippeixotog thanks for tips to make the plugin work. I was able to make it publish but still having Repository for publishing is not specified.
from both projectA and projectB in the example above.
[error] (projectB/*:publishConfiguration) Repository for publishing is not specified.
[error] (projectA/*:publishConfiguration) Repository for publishing is not specified.
is this expected before this issue is fixed?
AFAIK the fix I mention above still works, although I didn't test it with the latest versions of the plugin. Don't forget that besides tweaking the releaseProcess
you need to set skip in publish := true
in the projects you don't want published.
@ruippeixotog Thanks for reply!! I did that, but still getting the same errors. I have this setting in projectA which I don't want to publish
skip in publish := true,
releaseProcess := Seq[ReleaseStep](
inquireVersions,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("publish"),
setNextVersion,
commitNextVersion,
pushChanges
)
And in projectB which to be published:
releaseProcess := Seq[ReleaseStep](
inquireVersions,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("publish"),
setNextVersion,
commitNextVersion,
pushChanges
)
The artifact for projectB is published but with sbt errors.
@yangnirinny I am not too knowledgeable on this project, but it seems that releaseProcess
only applies to the build root, especially that release
command can only be run in root. Therefore, put releaseProcess
directly in your build.sbt
, skip in publish in ThisBuild := true
next to it and then skip in publish := false
for the project you want to publish.