From 3ed167d03900f188592e491f89b6039e0ffec682 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 10 Jul 2021 17:17:34 -0400 Subject: [PATCH 1/2] Reproduce sbt/sbt 6587 --- ci-test/app2/build.sbt | 0 ci-test/app2/sbt.1.4.0.boot.properties | 31 ++++++++++++++++++++++++++ ci-test/test.sh | 5 ++++- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 ci-test/app2/build.sbt create mode 100644 ci-test/app2/sbt.1.4.0.boot.properties diff --git a/ci-test/app2/build.sbt b/ci-test/app2/build.sbt new file mode 100644 index 0000000..e69de29 diff --git a/ci-test/app2/sbt.1.4.0.boot.properties b/ci-test/app2/sbt.1.4.0.boot.properties new file mode 100644 index 0000000..95d0187 --- /dev/null +++ b/ci-test/app2/sbt.1.4.0.boot.properties @@ -0,0 +1,31 @@ +[scala] + version: ${sbt.scala.version-auto} + +[app] + org: ${sbt.organization-org.scala-sbt} + name: sbt + version: ${sbt.version-read(sbt.version)[1.4.0]} + class: ${sbt.main.class-sbt.xMain} + components: xsbti,extra + cross-versioned: ${sbt.cross.versioned-false} + resources: ${sbt.extraClasspath-} + +[repositories] + local + local-preloaded-ivy: file:///${sbt.preloaded-${sbt.global.base-${user.home}/.sbt}/preloaded/}, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext] + local-preloaded: file:///${sbt.preloaded-${sbt.global.base-${user.home}/.sbt}/preloaded/} + maven-central + sbt-maven-releases: https://repo.scala-sbt.org/scalasbt/maven-releases/, bootOnly + sbt-maven-snapshots: https://repo.scala-sbt.org/scalasbt/maven-snapshots/, bootOnly + typesafe-ivy-releases: https://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly + sbt-ivy-snapshots: https://repo.scala-sbt.org/scalasbt/ivy-snapshots/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly + +[boot] + directory: /tmp/boot0/ + lock: ${sbt.boot.lock-true} + +[ivy] + ivy-home: ${sbt.ivy.home-${user.home}/.ivy2/} + checksums: ${sbt.checksums-sha1,md5} + override-build-repos: ${sbt.override.build.repos-false} + repository-config: ${sbt.repository.config-${sbt.global.base-${user.home}/.sbt}/repositories} diff --git a/ci-test/test.sh b/ci-test/test.sh index 2304897..0734dc5 100755 --- a/ci-test/test.sh +++ b/ci-test/test.sh @@ -6,7 +6,10 @@ pushd ci-test/app0 COURSIER_CACHE=/tmp/cache/ java -jar $LAUNCHER @sbt.1.3.13.boot.properties exit popd -#!/bin/bash -e pushd ci-test/app1 COURSIER_CACHE=/tmp/cache/ java -jar $LAUNCHER @sbt.0.13.18.boot.properties exit popd + +pushd ci-test/app2 +COURSIER_CACHE=/tmp/cache/ java -jar $LAUNCHER @sbt.1.4.0.boot.properties exit +popd From 3e19f1c9133dab9d3a8572e5003ed25bf0f62e53 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 11 Jul 2021 01:16:47 -0400 Subject: [PATCH 2/2] Override Scala version for sbt 1.4.x Problem ------- During sbt 1.4.x series util-interface incorrectly depended on scala-library. Specifically for util-interface 1.4.0, 1.4.1, and 1.4.2, this was Scala 2.13. Ivy seemed to be ok with this, but Coursier evicts Scala 2.12 and resolves to 2.13, which creating a confusing `java.lang.NoClassDefFoundError: scala/Serializable` error. Solution -------- Explicitly override Scala version for sbt 1.4.x to Scala 2.12.12. --- ci-test/app2/sbt.1.4.0.boot.properties | 2 -- .../src/main/scala/xsbt/boot/CoursierUpdate.scala | 11 +++++++++++ .../src/main/scala/xsbt/boot/Launch.scala | 13 ++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ci-test/app2/sbt.1.4.0.boot.properties b/ci-test/app2/sbt.1.4.0.boot.properties index 95d0187..3256a11 100644 --- a/ci-test/app2/sbt.1.4.0.boot.properties +++ b/ci-test/app2/sbt.1.4.0.boot.properties @@ -12,8 +12,6 @@ [repositories] local - local-preloaded-ivy: file:///${sbt.preloaded-${sbt.global.base-${user.home}/.sbt}/preloaded/}, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext] - local-preloaded: file:///${sbt.preloaded-${sbt.global.base-${user.home}/.sbt}/preloaded/} maven-central sbt-maven-releases: https://repo.scala-sbt.org/scalasbt/maven-releases/, bootOnly sbt-maven-snapshots: https://repo.scala-sbt.org/scalasbt/maven-snapshots/, bootOnly diff --git a/launcher-implementation/src/main/scala/xsbt/boot/CoursierUpdate.scala b/launcher-implementation/src/main/scala/xsbt/boot/CoursierUpdate.scala index 9c09a5e..1cd9ab2 100644 --- a/launcher-implementation/src/main/scala/xsbt/boot/CoursierUpdate.scala +++ b/launcher-implementation/src/main/scala/xsbt/boot/CoursierUpdate.scala @@ -7,6 +7,7 @@ import coursier.core.{ Publication, Repository } import coursier.credentials.DirectCredentials import coursier.ivy.IvyRepository import coursier.maven.MavenRepository +import coursier.params.ResolutionParams import java.io.{ File, FileWriter, PrintWriter } import java.nio.file.{ Files, StandardCopyOption, Paths } import java.util.Properties @@ -108,10 +109,19 @@ class CousierUpdate(config: UpdateConfiguration) { deps: List[Dependency] ): UpdateResult = { val repos = config.repositories.map(toCoursierRepository) + val params = scalaVersion match { + case Some(sv) if sv != "auto" => + ResolutionParams() + .withScalaVersion(sv) + .withForceScalaVersion(true) + case _ => + ResolutionParams() + } val r: Resolution = Resolve() .withCache(coursierCache) .addDependencies(deps: _*) .withRepositories(repos) + .withResolutionParams(params) .run() val actualScalaVersion = (r.dependencySet.set collect { @@ -143,6 +153,7 @@ class CousierUpdate(config: UpdateConfiguration) { .withCache(coursierCache) .addDependencies(deps: _*) .withRepositories(repos) + .withResolutionParams(params) .run() downloadedJars foreach { downloaded => val t = diff --git a/launcher-implementation/src/main/scala/xsbt/boot/Launch.scala b/launcher-implementation/src/main/scala/xsbt/boot/Launch.scala index 5fde4bf..11b927e 100644 --- a/launcher-implementation/src/main/scala/xsbt/boot/Launch.scala +++ b/launcher-implementation/src/main/scala/xsbt/boot/Launch.scala @@ -306,9 +306,20 @@ class Launch private[xsbt] ( @tailrec private[this] final def getAppProvider0( id: xsbti.ApplicationID, - explicitScalaVersion: Option[String], + explicitScalaVersion0: Option[String], forceAppUpdate: Boolean ): xsbti.AppProvider = { + val explicitScalaVersion = explicitScalaVersion0 match { + case Some(sv) => Some(sv) + case _ => + // https://github.com/sbt/sbt/issues/6587 + // set the Scala version of sbt 1.4.x series to 2.12.12 explicitly + // since util-interface depends on Scala 2.13 by mistake + // https://github.com/sbt/sbt/blob/v1.4.0/project/Dependencies.scala + if (id.groupID() == "org.scala-sbt" && + id.name() == "sbt" && id.version().startsWith("1.4.")) Some("2.12.12") + else None + } val app = appModule(id, explicitScalaVersion, true, "app") /** Replace the version of an ApplicationID with the given one, if set. */