mirror of https://github.com/sbt/sbt.git
Merge pull request #249 from alexarchambault/evicted
Don't report evictions about modules in dependencyOverrides
This commit is contained in:
commit
f29a170b9c
|
|
@ -210,6 +210,7 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
||||||
classifiers = classifiers,
|
classifiers = classifiers,
|
||||||
configs = configs,
|
configs = configs,
|
||||||
dependencies = dependencies,
|
dependencies = dependencies,
|
||||||
|
forceVersions = conf.forceVersions.map { case (m, v) => (ToCoursier.module(m), v) }.toMap,
|
||||||
interProjectDependencies = interProjectDependencies,
|
interProjectDependencies = interProjectDependencies,
|
||||||
res = resolutions,
|
res = resolutions,
|
||||||
includeSignatures = false,
|
includeSignatures = false,
|
||||||
|
|
|
||||||
|
|
@ -138,8 +138,7 @@ private[internal] object SbtUpdateReport {
|
||||||
artifactFileOpt: (Module, String, Attributes, Artifact) => Option[File],
|
artifactFileOpt: (Module, String, Attributes, Artifact) => Option[File],
|
||||||
fullArtifactsOpt: Option[Map[(Dependency, Publication, Artifact), Option[File]]],
|
fullArtifactsOpt: Option[Map[(Dependency, Publication, Artifact), Option[File]]],
|
||||||
log: Logger,
|
log: Logger,
|
||||||
keepPomArtifact: Boolean = false,
|
includeSignatures: Boolean,
|
||||||
includeSignatures: Boolean = false,
|
|
||||||
classpathOrder: Boolean,
|
classpathOrder: Boolean,
|
||||||
missingOk: Boolean
|
missingOk: Boolean
|
||||||
): Vector[ModuleReport] = {
|
): Vector[ModuleReport] = {
|
||||||
|
|
@ -167,13 +166,10 @@ private[internal] object SbtUpdateReport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val depArtifacts0 =
|
val depArtifacts0 = depArtifacts1.filter {
|
||||||
if (keepPomArtifact)
|
case (_, pub, _, _) =>
|
||||||
depArtifacts1
|
pub.attributes != Attributes(Type.pom, Classifier.empty)
|
||||||
else
|
}
|
||||||
depArtifacts1.filter {
|
|
||||||
case (_, pub, _, _) => pub.attributes != Attributes(Type.pom, Classifier.empty)
|
|
||||||
}
|
|
||||||
|
|
||||||
val depArtifacts =
|
val depArtifacts =
|
||||||
if (includeSignatures) {
|
if (includeSignatures) {
|
||||||
|
|
@ -298,10 +294,10 @@ private[internal] object SbtUpdateReport {
|
||||||
artifactFileOpt: (Module, String, Attributes, Artifact) => Option[File],
|
artifactFileOpt: (Module, String, Attributes, Artifact) => Option[File],
|
||||||
fullArtifactsOpt: Option[Map[(Dependency, Publication, Artifact), Option[File]]],
|
fullArtifactsOpt: Option[Map[(Dependency, Publication, Artifact), Option[File]]],
|
||||||
log: Logger,
|
log: Logger,
|
||||||
keepPomArtifact: Boolean = false,
|
includeSignatures: Boolean,
|
||||||
includeSignatures: Boolean = false,
|
|
||||||
classpathOrder: Boolean,
|
classpathOrder: Boolean,
|
||||||
missingOk: Boolean
|
missingOk: Boolean,
|
||||||
|
forceVersions: Map[Module, String]
|
||||||
): UpdateReport = {
|
): UpdateReport = {
|
||||||
|
|
||||||
val configReports = resolutions.map {
|
val configReports = resolutions.map {
|
||||||
|
|
@ -315,7 +311,6 @@ private[internal] object SbtUpdateReport {
|
||||||
artifactFileOpt,
|
artifactFileOpt,
|
||||||
fullArtifactsOpt,
|
fullArtifactsOpt,
|
||||||
log,
|
log,
|
||||||
keepPomArtifact = keepPomArtifact,
|
|
||||||
includeSignatures = includeSignatures,
|
includeSignatures = includeSignatures,
|
||||||
classpathOrder = classpathOrder,
|
classpathOrder = classpathOrder,
|
||||||
missingOk = missingOk
|
missingOk = missingOk
|
||||||
|
|
@ -340,28 +335,30 @@ private[internal] object SbtUpdateReport {
|
||||||
OrganizationArtifactReport(rep.module.organization, rep.module.name, Vector(rep))
|
OrganizationArtifactReport(rep.module.organization, rep.module.name, Vector(rep))
|
||||||
}
|
}
|
||||||
|
|
||||||
val evicted = coursier.graph.Conflict(subRes).flatMap { c =>
|
val evicted = for {
|
||||||
// FIXME The project for c.wantedVersion is possibly not around (it's likely it was just not fetched)
|
c <- coursier.graph.Conflict(subRes)
|
||||||
val projOpt = subRes.projectCache.get((c.module, c.wantedVersion))
|
// ideally, forceVersions should be taken into account by coursier.core.Resolution itself, when
|
||||||
|
// it computes transitive dependencies. It only handles forced versions at a global level for now,
|
||||||
|
// rather than handing them for each dependency (where each dependency could have its own forced
|
||||||
|
// versions, and apply and pass them to its transitive dependencies, just like for exclusions today).
|
||||||
|
if !forceVersions.contains(c.module)
|
||||||
|
projOpt = subRes.projectCache.get((c.module, c.wantedVersion))
|
||||||
.orElse(subRes.projectCache.get((c.module, c.version)))
|
.orElse(subRes.projectCache.get((c.module, c.version)))
|
||||||
projOpt.toSeq.map {
|
(_, proj) <- projOpt.toSeq
|
||||||
case (_, proj) =>
|
} yield {
|
||||||
// likely misses some details (transitive, exclusions, …)
|
val dep = Dependency(c.module, c.wantedVersion)
|
||||||
val dep = Dependency(c.module, c.wantedVersion)
|
val dependee = Dependency(c.dependeeModule, c.dependeeVersion)
|
||||||
val dependee = Dependency(c.dependeeModule, c.dependeeVersion)
|
val dependeeProj = subRes.projectCache.get((c.dependeeModule, c.dependeeVersion)) match {
|
||||||
val dependeeProj = subRes.projectCache
|
case Some((_, p)) =>
|
||||||
.get((c.dependeeModule, c.dependeeVersion)) match {
|
ProjectInfo(p.version, p.configurations.keys.toVector.map(c => ConfigRef(c.value)), p.properties)
|
||||||
case Some((_, p)) =>
|
case None =>
|
||||||
ProjectInfo(p.version, p.configurations.keys.toVector.map(c => ConfigRef(c.value)), p.properties)
|
// should not happen
|
||||||
case _ =>
|
ProjectInfo(c.dependeeVersion, Vector.empty, Vector.empty)
|
||||||
// should not happen
|
}
|
||||||
ProjectInfo(c.dependeeVersion, Vector.empty, Vector.empty)
|
val rep = moduleReport((dep, Seq((dependee, dependeeProj)), proj.withVersion(c.wantedVersion), Nil))
|
||||||
}
|
.withEvicted(true)
|
||||||
val rep = moduleReport((dep, Seq((dependee, dependeeProj)), proj.withVersion(c.wantedVersion), Nil))
|
.withEvictedData(Some("version selection")) // ??? put latest-revision like sbt/ivy here?
|
||||||
.withEvicted(true)
|
OrganizationArtifactReport(c.module.organization.value, c.module.name.value, Vector(rep))
|
||||||
.withEvictedData(Some("version selection")) // ??? put latest-revision like sbt/ivy here?
|
|
||||||
OrganizationArtifactReport(c.module.organization.value, c.module.name.value, Vector(rep))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val details = (mainReportDetails ++ evicted)
|
val details = (mainReportDetails ++ evicted)
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ final case class UpdateParams(
|
||||||
classifiers: Option[Seq[Classifier]],
|
classifiers: Option[Seq[Classifier]],
|
||||||
configs: Map[Configuration, Set[Configuration]],
|
configs: Map[Configuration, Set[Configuration]],
|
||||||
dependencies: Seq[(Configuration, Dependency)],
|
dependencies: Seq[(Configuration, Dependency)],
|
||||||
|
forceVersions: Map[Module, String],
|
||||||
interProjectDependencies: Seq[Project],
|
interProjectDependencies: Seq[Project],
|
||||||
res: Map[Configuration, Resolution],
|
res: Map[Configuration, Resolution],
|
||||||
includeSignatures: Boolean,
|
includeSignatures: Boolean,
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,8 @@ object UpdateRun {
|
||||||
log,
|
log,
|
||||||
includeSignatures = params.includeSignatures,
|
includeSignatures = params.includeSignatures,
|
||||||
classpathOrder = params.classpathOrder,
|
classpathOrder = params.classpathOrder,
|
||||||
missingOk = params.missingOk
|
missingOk = params.missingOk,
|
||||||
|
params.forceVersions
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
package coursier.sbtcoursier
|
package coursier.sbtcoursier
|
||||||
|
|
||||||
import coursier.core._
|
import coursier.core._
|
||||||
import lmcoursier.definitions.ToCoursier
|
|
||||||
import lmcoursier.internal.{SbtBootJars, SbtCoursierCache, UpdateParams, UpdateRun}
|
|
||||||
import coursier.sbtcoursier.Keys._
|
import coursier.sbtcoursier.Keys._
|
||||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||||
|
import lmcoursier.definitions.ToCoursier
|
||||||
|
import lmcoursier.Inputs
|
||||||
|
import lmcoursier.internal.{SbtBootJars, SbtCoursierCache, UpdateParams, UpdateRun}
|
||||||
import sbt.Def
|
import sbt.Def
|
||||||
import sbt.Keys._
|
import sbt.Keys._
|
||||||
import sbt.librarymanagement.UpdateReport
|
import sbt.librarymanagement.UpdateReport
|
||||||
|
|
@ -110,6 +111,14 @@ object UpdateTasks {
|
||||||
val artifactFilesOrErrors0 = artifactFilesOrErrors0Task.value
|
val artifactFilesOrErrors0 = artifactFilesOrErrors0Task.value
|
||||||
val classifiers = classifiersTask.value
|
val classifiers = classifiersTask.value
|
||||||
val configs = configsTask.value
|
val configs = configsTask.value
|
||||||
|
val sv = scalaVersion.value
|
||||||
|
val sbv = scalaBinaryVersion.value
|
||||||
|
val forceVersions = Inputs.forceVersions(dependencyOverrides.value, sv, sbv)
|
||||||
|
.map {
|
||||||
|
case (m, v) =>
|
||||||
|
(ToCoursier.module(m), v)
|
||||||
|
}
|
||||||
|
.toMap
|
||||||
|
|
||||||
val params = UpdateParams(
|
val params = UpdateParams(
|
||||||
(p.module, p.version),
|
(p.module, p.version),
|
||||||
|
|
@ -118,6 +127,7 @@ object UpdateTasks {
|
||||||
classifiers,
|
classifiers,
|
||||||
configs,
|
configs,
|
||||||
dependencies,
|
dependencies,
|
||||||
|
forceVersions,
|
||||||
interProjectDependencies,
|
interProjectDependencies,
|
||||||
res,
|
res,
|
||||||
includeSignatures,
|
includeSignatures,
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,25 @@ lazy val b = project
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
lazy val c = project
|
||||||
|
.settings(
|
||||||
|
scalaVersion := "2.12.8",
|
||||||
|
libraryDependencies ++= Seq(
|
||||||
|
"org.slf4s" %% "slf4s-api" % "1.7.25", // depends on org.slf4j:slf4j-api:1.7.25
|
||||||
|
"ch.qos.logback" % "logback-classic" % "1.1.2" // depends on org.slf4j:slf4j-api:1.7.6
|
||||||
|
),
|
||||||
|
dependencyOverrides += "org.slf4j" % "slf4j-api" % "1.7.30"
|
||||||
|
)
|
||||||
|
|
||||||
lazy val check = taskKey[Unit]("")
|
lazy val check = taskKey[Unit]("")
|
||||||
|
|
||||||
check := {
|
check := {
|
||||||
|
|
||||||
val aReport = update.in(a).value
|
val aReport = update.in(a).value
|
||||||
val bReport = update.in(b).value
|
val bReport = update.in(b).value
|
||||||
|
val cReport = update.in(c).value
|
||||||
|
|
||||||
def doCheck(report: UpdateReport): Unit = {
|
def doCheck(report: UpdateReport, evictionsExpected: Boolean = true): Unit = {
|
||||||
|
|
||||||
val compileReport = report
|
val compileReport = report
|
||||||
.configurations
|
.configurations
|
||||||
|
|
@ -36,12 +47,12 @@ check := {
|
||||||
}
|
}
|
||||||
|
|
||||||
val foundEvictions = compileReport.details.exists(_.modules.exists(_.evicted))
|
val foundEvictions = compileReport.details.exists(_.modules.exists(_.evicted))
|
||||||
if (!foundEvictions)
|
if (foundEvictions != evictionsExpected)
|
||||||
compileReport.details.foreach(println)
|
compileReport.details.foreach(println)
|
||||||
assert(foundEvictions)
|
assert(foundEvictions == evictionsExpected)
|
||||||
}
|
}
|
||||||
|
|
||||||
// needs https://github.com/coursier/coursier/pull/1217
|
doCheck(aReport)
|
||||||
// doCheck(aReport)
|
|
||||||
doCheck(bReport)
|
doCheck(bReport)
|
||||||
|
doCheck(cReport, evictionsExpected = false)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3")
|
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3")
|
||||||
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.7.0")
|
addSbtPlugin("com.github.alexarchambault.tmp" % "sbt-mima-plugin" % "0.7.1-SNAPSHOT")
|
||||||
|
|
||||||
addSbtPlugin("io.get-coursier" % "sbt-shading" % "2.0.0")
|
addSbtPlugin("io.get-coursier" % "sbt-shading" % "2.0.0")
|
||||||
|
|
||||||
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
|
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
|
||||||
|
|
||||||
|
resolvers += Resolver.sonatypeRepo("snapshots")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue