Skip to content

Commit

Permalink
Switch to coursier 2.0.0-RC4 (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault authored Oct 14, 2019
1 parent 14a4a69 commit b27615c
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 30 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ inThisBuild(List(
)
))

val coursierVersion0 = "2.0.0-RC3-4"
val coursierVersion0 = "2.0.0-RC4"

lazy val `lm-coursier` = project
.enablePlugins(ContrabandPlugin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object ToCoursier {
def authentication(authentication: Authentication): coursier.core.Authentication =
coursier.core.Authentication(authentication.user, authentication.password)
.withOptional(authentication.optional)
.withRealm(authentication.realmOpt)
.withRealmOpt(authentication.realmOpt)

def module(module: Module): coursier.core.Module =
coursier.core.Module(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final case class ResolutionParams(
val cleanCache = cache
.withPool(null)
.withLogger(null)
.withSync[Task](null)
.withS(null)
SbtCoursierCache.ResolutionKey(
dependencies,
internalRepositories,
Expand All @@ -60,7 +60,7 @@ final case class ResolutionParams(
parallel = 0,
cache = cleanCache
),
ResolutionParams.cacheKey(cleanCache),
cleanCache,
sbtClassifiers
)
}
Expand All @@ -73,18 +73,6 @@ final case class ResolutionParams(
// private[coursier]
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] = {

val ivyHome = sys.props
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ object ResolutionRun {
.params
.addForceVersion((if (isCompileConfig) params.interProjectDependencies.map(_.moduleVersion) else Nil): _*)
.withForceScalaVersion(isCompileOrScalaToolConfig && params.autoScalaLibOpt.nonEmpty)
.withScalaVersion(params.autoScalaLibOpt.map(_._2))
.withScalaVersionOpt(params.autoScalaLibOpt.map(_._2))
.withTypelevel(params.params.typelevel && isCompileOrScalaToolConfig)
.withRules(rules)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import java.util.concurrent.ConcurrentHashMap

import coursier.core._
import sbt.librarymanagement.UpdateReport
import coursier.cache.FileCache
import coursier.util.Task

// private[coursier]
class SbtCoursierCache {
Expand Down Expand Up @@ -45,7 +47,7 @@ object SbtCoursierCache {
mainRepositories: Seq[Repository],
fallbackRepositories: Seq[Repository],
params: ResolutionParams,
tmpCacheKey: Object, // temporary, until we can use https://github.com/coursier/coursier/pull/1090
cache: FileCache[Task],
sbtClassifiers: Boolean
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,10 @@ private[internal] object SbtUpdateReport {
if (notFound.isEmpty)
depArtifacts0.flatMap {
case (dep, pub, a) =>
val sigPub = pub.copy(
val sigPub = pub
// not too sure about those
ext = Extension(pub.ext.value),
`type` = Type(pub.`type`.value)
)
.withExt(Extension(pub.ext.value))
.withType(Type(pub.`type`.value))
Seq((dep, pub, a)) ++
a.extra.get("sig").toSeq.map((dep, sigPub, _))
}
Expand All @@ -183,7 +182,10 @@ private[internal] object SbtUpdateReport {
}.toMap

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
.toVector
Expand All @@ -201,10 +203,10 @@ private[internal] object SbtUpdateReport {

// FIXME Likely flaky...
val dependees = reverseDependencies
.getOrElse(clean(dep.copy(version = "")), Vector.empty)
.getOrElse(clean(dep.withVersion("")), Vector.empty)
.map { dependee0 =>
val version = versions(dependee0.module)
val dependee = dependee0.copy(version = version)
val dependee = dependee0.withVersion(version)
val (_, dependeeProj) = res.projectCache(dependee.moduleVersion)
(dependee, dependeeProj)
}
Expand Down Expand Up @@ -283,7 +285,7 @@ private[internal] object SbtUpdateReport {
// should not happen
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)
.withEvictedData(Some("version selection")) // ??? put latest-revision like sbt/ivy here?
OrganizationArtifactReport(c.module.organization.value, c.module.name.value, Vector(rep))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ object UpdateRun {
allDependenciesByConfig(res, depsByConfig, configs)
.flatMap {
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 {
case (dep, l) =>
dep.copy(configuration = Configuration.join(l.map(_.configuration).toSeq: _*))
dep.withConfiguration(Configuration.join(l.map(_.configuration).toSeq: _*))
}
.toSet

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ object ResolutionTasks {
authenticationByRepositoryId.get(resolver.name).map { a =>
Authentication(a.user, a.password)
.withOptional(a.optional)
.withRealm(a.realmOpt)
.withRealmOpt(a.realmOpt)
}
)
}
Expand Down

0 comments on commit b27615c

Please sign in to comment.