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

Release projects with different scala version

Open ex0ns opened this issue 8 months ago • 0 comments

I am trying to publish a sbt plugin (2.12) based on Scala.js as well as a scala.js library (3.3.3) from the same project, my setup is as follow

// build.sbt
import sbt._
import ReleaseTransformations._

lazy val scala2Version = "2.12.19"
lazy val scala3Version = "3.3.3"

lazy val lib = project
  .in(file("lib"))
  .settings(Test / fork := false)
  .settings(
    organization := "org.test",
    scalaVersion := scala3Version,
    crossScalaVersions := Seq(scala3Version),
    libraryDependencies ++= Seq(
      "com.raquo" %%% "laminar" % "17.0.0",
    ),
  )
  .enablePlugins(ScalaJSPlugin)

lazy val plugin = project
  .in(file("plugin"))
  .settings(
    Seq(
      scalaVersion := scala2Version,
      crossScalaVersions := Seq(scala2Version),
      sbtPlugin := true,
      addSbtPlugin(("org.scala-js" % "sbt-scalajs" % "1.16.0").cross(CrossVersion.constant(scala2Version))),
    )
  )


lazy val root = project
  .in(file("."))
  .aggregate(lib, plugin)
  .settings(
    // crossScalaVersions := Nil,
    publish / skip := true,
    // releaseCrossBuild := false,
    /* Quick hack so we can test release in local */
    publishTo := Some(Resolver.file("local-maven", file(Path.userHome.absolutePath + "/.m2/repository"))),
    // scalaVersion := scala2Version,
    releaseProcess := Seq[ReleaseStep](
      checkSnapshotDependencies
    )
  )

And

// plugins.sbt
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.4.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")

However if I try to run a sbt release cross, sbt is trying to fetch laminar for scala 2.12, which does not exist.

sbt:root> release cross with-defaults
[info] Setting scala version to 2.12.19
[info] set current project to root (in build file:/Users/ex0ns/Projects/test-sbt-release/)
[info] Updating lib_sjs1_2.12
https://repo1.maven.org/maven2/com/raquo/laminar_sjs1_2.13/17.0.0/laminar_sjs1_2.12-17.0.0.jar

I really don't get why lib would be published in 2.12. I have tried a lot of different setup (with and without crossScala version, cross build and such), but I could not make this work.

I was able to narrow down the issue to checkSnapshotDependencies but I have no way to check that the steps after are not having the same issue as well.

https://github.com/sbt/sbt-release/blob/v1.4.0/src/main/scala/ReleaseExtra.scala#L17 is calling https://github.com/sbt/sbt-release/blob/v1.4.0/src/main/scala/ReleasePlugin.scala#L221

However I can't reproduce this error by simply calling root / Runtime / managedClasspath...

What did I miss here ?

ex0ns avatar Jun 07 '24 13:06 ex0ns