Allow to swap Scala mainline dependencies by Typelevel ones

This commit is contained in:
Alexandre Archambault
2016-11-15 00:27:23 +01:00
parent 0ae415c55e
commit 5e0189fa7e
5 changed files with 46 additions and 5 deletions
@@ -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)
)
}