mirror of
https://github.com/sbt/sbt.git
synced 2026-09-07 11:01:08 +02:00
Allow to swap Scala mainline dependencies by Typelevel ones
This commit is contained in:
@@ -6,6 +6,7 @@ import java.net.{ URL, URLClassLoader }
|
||||
import java.util.jar.{ Manifest => JManifest }
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
import coursier.cli.typelevel.Typelevel
|
||||
import coursier.ivy.IvyRepository
|
||||
import coursier.util.{Print, Parse}
|
||||
|
||||
@@ -287,7 +288,8 @@ class Helper(
|
||||
filter = Some(dep => keepOptional || !dep.optional),
|
||||
userActivations =
|
||||
if (userEnabledProfiles.isEmpty) None
|
||||
else Some(userEnabledProfiles.iterator.map(_ -> true).toMap)
|
||||
else Some(userEnabledProfiles.iterator.map(_ -> true).toMap),
|
||||
mapDependencies = if (typelevel) Some(Typelevel.swap(_)) else None
|
||||
)
|
||||
|
||||
val loggerFallbackMode =
|
||||
|
||||
@@ -85,6 +85,8 @@ case class CommonOptions(
|
||||
@Value("profile")
|
||||
@Short("F")
|
||||
profile: List[String],
|
||||
@Help("Swap the mainline Scala JARs by Typelevel ones")
|
||||
typelevel: Boolean = false,
|
||||
@Recurse
|
||||
cacheOptions: CacheOptions
|
||||
) {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package coursier.cli.typelevel
|
||||
|
||||
import coursier.{Dependency, Module}
|
||||
|
||||
object Typelevel {
|
||||
|
||||
val mainLineOrg = "org.scala-lang"
|
||||
val typelevelOrg = "org.typelevel"
|
||||
|
||||
val modules = Set(
|
||||
"scala-compiler",
|
||||
"scala-library",
|
||||
"scala-library-all",
|
||||
"scala-reflect",
|
||||
"scalap"
|
||||
// any other?
|
||||
)
|
||||
|
||||
def swap(module: Module): Module =
|
||||
if (module.organization == mainLineOrg && modules(module.name) && module.attributes.isEmpty)
|
||||
module.copy(
|
||||
organization = typelevelOrg
|
||||
)
|
||||
else
|
||||
module
|
||||
|
||||
def swap(dependency: Dependency): Dependency =
|
||||
dependency.copy(
|
||||
module = swap(dependency.module)
|
||||
)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user