Switch to coursier 2.0.0-RC4 (#148)

This commit is contained in:
Alexandre Archambault 2019-10-14 13:52:32 +02:00 committed by GitHub
parent 14a4a6998a
commit b27615cf25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 30 deletions

View File

@ -15,7 +15,7 @@ inThisBuild(List(
) )
)) ))
val coursierVersion0 = "2.0.0-RC3-4" val coursierVersion0 = "2.0.0-RC4"
lazy val `lm-coursier` = project lazy val `lm-coursier` = project
.enablePlugins(ContrabandPlugin) .enablePlugins(ContrabandPlugin)

View File

@ -26,7 +26,7 @@ object ToCoursier {
def authentication(authentication: Authentication): coursier.core.Authentication = def authentication(authentication: Authentication): coursier.core.Authentication =
coursier.core.Authentication(authentication.user, authentication.password) coursier.core.Authentication(authentication.user, authentication.password)
.withOptional(authentication.optional) .withOptional(authentication.optional)
.withRealm(authentication.realmOpt) .withRealmOpt(authentication.realmOpt)
def module(module: Module): coursier.core.Module = def module(module: Module): coursier.core.Module =
coursier.core.Module( coursier.core.Module(

View File

@ -48,7 +48,7 @@ final case class ResolutionParams(
val cleanCache = cache val cleanCache = cache
.withPool(null) .withPool(null)
.withLogger(null) .withLogger(null)
.withSync[Task](null) .withS(null)
SbtCoursierCache.ResolutionKey( SbtCoursierCache.ResolutionKey(
dependencies, dependencies,
internalRepositories, internalRepositories,
@ -60,7 +60,7 @@ final case class ResolutionParams(
parallel = 0, parallel = 0,
cache = cleanCache cache = cleanCache
), ),
ResolutionParams.cacheKey(cleanCache), cleanCache,
sbtClassifiers sbtClassifiers
) )
} }
@ -73,18 +73,6 @@ final case class ResolutionParams(
// private[coursier] // private[coursier]
object ResolutionParams { object ResolutionParams {
private lazy val m = {
val cls = classOf[FileCache[Task]]
//cls.getDeclaredMethods.foreach(println)
val m = cls.getDeclaredMethod("params")
m.setAccessible(true)
m
}
// temporary, until we can use https://github.com/coursier/coursier/pull/1090
private def cacheKey(cache: FileCache[Task]): Object =
m.invoke(cache)
def defaultIvyProperties(ivyHomeOpt: Option[File]): Map[String, String] = { def defaultIvyProperties(ivyHomeOpt: Option[File]): Map[String, String] = {
val ivyHome = sys.props val ivyHome = sys.props

View File

@ -89,7 +89,7 @@ object ResolutionRun {
.params .params
.addForceVersion((if (isCompileConfig) params.interProjectDependencies.map(_.moduleVersion) else Nil): _*) .addForceVersion((if (isCompileConfig) params.interProjectDependencies.map(_.moduleVersion) else Nil): _*)
.withForceScalaVersion(isCompileOrScalaToolConfig && params.autoScalaLibOpt.nonEmpty) .withForceScalaVersion(isCompileOrScalaToolConfig && params.autoScalaLibOpt.nonEmpty)
.withScalaVersion(params.autoScalaLibOpt.map(_._2)) .withScalaVersionOpt(params.autoScalaLibOpt.map(_._2))
.withTypelevel(params.params.typelevel && isCompileOrScalaToolConfig) .withTypelevel(params.params.typelevel && isCompileOrScalaToolConfig)
.withRules(rules) .withRules(rules)
) )

View File

@ -4,6 +4,8 @@ import java.util.concurrent.ConcurrentHashMap
import coursier.core._ import coursier.core._
import sbt.librarymanagement.UpdateReport import sbt.librarymanagement.UpdateReport
import coursier.cache.FileCache
import coursier.util.Task
// private[coursier] // private[coursier]
class SbtCoursierCache { class SbtCoursierCache {
@ -45,7 +47,7 @@ object SbtCoursierCache {
mainRepositories: Seq[Repository], mainRepositories: Seq[Repository],
fallbackRepositories: Seq[Repository], fallbackRepositories: Seq[Repository],
params: ResolutionParams, params: ResolutionParams,
tmpCacheKey: Object, // temporary, until we can use https://github.com/coursier/coursier/pull/1090 cache: FileCache[Task],
sbtClassifiers: Boolean sbtClassifiers: Boolean
) )

View File

@ -156,11 +156,10 @@ private[internal] object SbtUpdateReport {
if (notFound.isEmpty) if (notFound.isEmpty)
depArtifacts0.flatMap { depArtifacts0.flatMap {
case (dep, pub, a) => case (dep, pub, a) =>
val sigPub = pub.copy( val sigPub = pub
// not too sure about those // not too sure about those
ext = Extension(pub.ext.value), .withExt(Extension(pub.ext.value))
`type` = Type(pub.`type`.value) .withType(Type(pub.`type`.value))
)
Seq((dep, pub, a)) ++ Seq((dep, pub, a)) ++
a.extra.get("sig").toSeq.map((dep, sigPub, _)) a.extra.get("sig").toSeq.map((dep, sigPub, _))
} }
@ -183,7 +182,10 @@ private[internal] object SbtUpdateReport {
}.toMap }.toMap
def clean(dep: Dependency): Dependency = def clean(dep: Dependency): Dependency =
dep.copy(configuration = Configuration.empty, exclusions = Set.empty, optional = false) dep
.withConfiguration(Configuration.empty)
.withExclusions(Set.empty)
.withOptional(false)
val reverseDependencies = res.reverseDependencies val reverseDependencies = res.reverseDependencies
.toVector .toVector
@ -201,10 +203,10 @@ private[internal] object SbtUpdateReport {
// FIXME Likely flaky... // FIXME Likely flaky...
val dependees = reverseDependencies val dependees = reverseDependencies
.getOrElse(clean(dep.copy(version = "")), Vector.empty) .getOrElse(clean(dep.withVersion("")), Vector.empty)
.map { dependee0 => .map { dependee0 =>
val version = versions(dependee0.module) val version = versions(dependee0.module)
val dependee = dependee0.copy(version = version) val dependee = dependee0.withVersion(version)
val (_, dependeeProj) = res.projectCache(dependee.moduleVersion) val (_, dependeeProj) = res.projectCache(dependee.moduleVersion)
(dependee, dependeeProj) (dependee, dependeeProj)
} }
@ -283,7 +285,7 @@ private[internal] object SbtUpdateReport {
// should not happen // should not happen
Project(c.dependeeModule, c.dependeeVersion, Nil, Map(), None, Nil, Nil, Nil, None, None, None, false, None, Nil, coursier.core.Info.empty) Project(c.dependeeModule, c.dependeeVersion, Nil, Map(), None, Nil, Nil, Nil, None, None, None, false, None, Nil, coursier.core.Info.empty)
} }
val rep = moduleReport((dep, Seq((dependee, dependeeProj)), proj.copy(version = c.wantedVersion), Nil)) val rep = moduleReport((dep, Seq((dependee, dependeeProj)), proj.withVersion(c.wantedVersion), Nil))
.withEvicted(true) .withEvicted(true)
.withEvictedData(Some("version selection")) // ??? put latest-revision like sbt/ivy here? .withEvictedData(Some("version selection")) // ??? put latest-revision like sbt/ivy here?
OrganizationArtifactReport(c.module.organization.value, c.module.name.value, Vector(rep)) OrganizationArtifactReport(c.module.organization.value, c.module.name.value, Vector(rep))

View File

@ -42,12 +42,12 @@ object UpdateRun {
allDependenciesByConfig(res, depsByConfig, configs) allDependenciesByConfig(res, depsByConfig, configs)
.flatMap { .flatMap {
case (config, deps) => case (config, deps) =>
deps.map(dep => dep.copy(configuration = config --> dep.configuration)) deps.map(dep => dep.withConfiguration(config --> dep.configuration))
} }
.groupBy(_.copy(configuration = Configuration.empty)) .groupBy(_.withConfiguration(Configuration.empty))
.map { .map {
case (dep, l) => case (dep, l) =>
dep.copy(configuration = Configuration.join(l.map(_.configuration).toSeq: _*)) dep.withConfiguration(Configuration.join(l.map(_.configuration).toSeq: _*))
} }
.toSet .toSet

View File

@ -122,7 +122,7 @@ object ResolutionTasks {
authenticationByRepositoryId.get(resolver.name).map { a => authenticationByRepositoryId.get(resolver.name).map { a =>
Authentication(a.user, a.password) Authentication(a.user, a.password)
.withOptional(a.optional) .withOptional(a.optional)
.withRealm(a.realmOpt) .withRealmOpt(a.realmOpt)
} }
) )
} }