Skip to content

Commit

Permalink
Merge pull request #98 from eed3si9n/wip/sbt-6587
Browse files Browse the repository at this point in the history
Override Scala version for sbt 1.4.x
  • Loading branch information
eed3si9n authored Jul 11, 2021
2 parents de073d1 + 3e19f1c commit d4285b8
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
Empty file added ci-test/app2/build.sbt
Empty file.
29 changes: 29 additions & 0 deletions ci-test/app2/sbt.1.4.0.boot.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[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
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}
5 changes: 4 additions & 1 deletion ci-test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -143,6 +153,7 @@ class CousierUpdate(config: UpdateConfiguration) {
.withCache(coursierCache)
.addDependencies(deps: _*)
.withRepositories(repos)
.withResolutionParams(params)
.run()
downloadedJars foreach { downloaded =>
val t =
Expand Down
13 changes: 12 additions & 1 deletion launcher-implementation/src/main/scala/xsbt/boot/Launch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit d4285b8

Please sign in to comment.