sbt-release icon indicating copy to clipboard operation
sbt-release copied to clipboard

Aggregate project with different crossScalaVersions

Open TBonnin opened this issue 6 years ago • 7 comments

I am trying to release in a single step multiple projects using an aggregate project. Subprojects don't have the same cross build versions.

lazy val root = (project in file(".")).aggregate(projectA, projectB)

lazy val projectA = project.in(file("A"))
  .settings(
    crossScalaVersions:= Seq(scala211),
...
)

lazy val projectB = project.in(file("B"))
  .settings(
    crossScalaVersions:= Seq(scala211, scala212),
    releaseCrossBuild := true,
...
)

When running sbt release only the 2.11 version of projectB is being built.

Am I trying to do something not supported by sbt-release?

TBonnin avatar Nov 03 '17 11:11 TBonnin

@TBonnin You can use the sbt-doge plugin for this. The plugin is here, and an example build is here. I have no connection to the guys here but I've had the problem before, hope it helps.

alexflav23 avatar Nov 30 '17 14:11 alexflav23

@alexflav23 I am currently having the same issue. As sbt-doge is retired because sbt 1 contains the same functionality it would be cool if this plugin could come up with a solution as well.

dpfeiffer avatar Dec 11 '17 16:12 dpfeiffer

According to some reports the following doge workaround is applicable to sbt 1.x:

  releaseCrossBuild := false
  releaseProcess := Seq[ReleaseStep](
    checkSnapshotDependencies,
    inquireVersions,
    runClean,
    releaseStepCommandAndRemaining("+test"),
    setReleaseVersion,
    commitReleaseVersion,
    tagRelease,
    releaseStepCommandAndRemaining("+publish"),
    setNextVersion,
    commitNextVersion,
    pushChanges
  )

eed3si9n avatar Feb 26 '18 06:02 eed3si9n

Thanks for the workaround! Worked

I think I had the same issue in sttp, where sub-projects have different cross versions. More concretely, the jvm/js backends target both 2.11 and 2.12, while the native one only 2.11.

To make things work, I had to:

  1. change the release process to use +publishSigned etc. (no idea though what's the difference between releaseStepCommandAndRemaining and releaseStepCommand :) )
  2. set the default scala version in the root project to 2.11 (otherwise release tried to download native-2.12 even though it explicitly stated that it's only using 2.11)

The final release process is here: https://github.com/softwaremill/sttp/blob/master/build.sbt#L20-L31

adamw avatar Jul 24 '18 12:07 adamw

Thanks all -- just ran in to this with scodec-bits and was able to get it fixed thanks to the comments here.

mpilquist avatar Nov 15 '18 21:11 mpilquist

The doge workaround specified in @eed3si9n wouldn't work if some modules have a custom releasePublishArtifactsAction right? Unless there is a way to set releasePublishArtifactsAction to a cross command like +assembly?

kailuowang avatar Apr 03 '19 01:04 kailuowang

revisiting this as it is still problem specially now with 2.13 ...

in addition to @eed3si9n workaround in order to be able to skip-tests i'm doing...

  releaseProcess := Seq[ReleaseStep](
    checkSnapshotDependencies,
    inquireVersions,
    runClean,
    ReleaseStep { st: State =>
      if (!st.get(ReleaseKeys.skipTests).getOrElse(false)) {
        releaseStepCommandAndRemaining("+test")(st)
      } else {
        st
      }
    },
    setReleaseVersion,
    commitReleaseVersion,
    tagRelease,
    releaseStepCommandAndRemaining("+publishSigned"),
    releaseStepCommand("sonatypeBundleRelease"),
    setNextVersion,
    commitNextVersion,
    pushChanges
  )

regadas avatar Dec 04 '19 15:12 regadas