mirror of https://github.com/sbt/sbt.git
Merge pull request #6221 from eed3si9n/wip/eviction_error
Replace EvictionWarning with EvictionError
This commit is contained in:
commit
f9d8d8c45f
|
|
@ -2689,6 +2689,8 @@ object Classpaths {
|
|||
defaultConfiguration :== Some(Configurations.Compile),
|
||||
dependencyOverrides :== Vector.empty,
|
||||
libraryDependencies :== Nil,
|
||||
libraryDependencySchemes :== Nil,
|
||||
evictionErrorLevel :== Level.Error,
|
||||
excludeDependencies :== Nil,
|
||||
ivyLoggingLevel := (// This will suppress "Resolving..." logs on Jenkins and Travis.
|
||||
if (insideCI.value)
|
||||
|
|
@ -3460,13 +3462,7 @@ object Classpaths {
|
|||
.withMetadataDirectory(dependencyCacheDirectory.value)
|
||||
}
|
||||
|
||||
val evictionOptions = Def.taskDyn {
|
||||
if (executionRoots.value.exists(_.key == evicted.key))
|
||||
Def.task(EvictionWarningOptions.empty)
|
||||
else Def.task((evictionWarningOptions in update).value)
|
||||
}.value
|
||||
|
||||
val extracted = (Project extract state0)
|
||||
val extracted = Project.extract(state0)
|
||||
val isPlugin = sbtPlugin.value
|
||||
val thisRef = thisProjectRef.value
|
||||
val label =
|
||||
|
|
@ -3486,7 +3482,8 @@ object Classpaths {
|
|||
force = shouldForce,
|
||||
depsUpdated = transitiveUpdate.value.exists(!_.stats.cached),
|
||||
uwConfig = (unresolvedWarningConfiguration in update).value,
|
||||
ewo = evictionOptions,
|
||||
evictionLevel = evictionErrorLevel.value,
|
||||
versionSchemeOverrides = libraryDependencySchemes.value,
|
||||
mavenStyle = publishMavenStyle.value,
|
||||
compatWarning = compatibilityWarningOptions.value,
|
||||
includeCallers = includeCallers,
|
||||
|
|
|
|||
|
|
@ -455,6 +455,7 @@ object Keys {
|
|||
val updateFull = taskKey[UpdateReport]("Resolves and optionally retrieves dependencies, producing a full report with callers.").withRank(CTask)
|
||||
val evicted = taskKey[EvictionWarning]("Display detailed eviction warnings.").withRank(CTask)
|
||||
val evictionWarningOptions = settingKey[EvictionWarningOptions]("Options on eviction warnings after resolving managed dependencies.").withRank(DSetting)
|
||||
val evictionErrorLevel = settingKey[Level.Value]("The log level for detected eviction errors. Level.Error will throw an error.")
|
||||
val transitiveUpdate = taskKey[Seq[UpdateReport]]("UpdateReports for the internal dependencies of this project.").withRank(DTask)
|
||||
val updateClassifiers = TaskKey[UpdateReport]("updateClassifiers", "Resolves and optionally retrieves classified artifacts, such as javadocs and sources, for dependency definitions, transitively.", BPlusTask, update)
|
||||
val transitiveClassifiers = settingKey[Seq[String]]("List of classifiers used for transitively obtaining extra artifacts for sbt or declared dependencies.").withRank(BSetting)
|
||||
|
|
@ -533,6 +534,7 @@ object Keys {
|
|||
val checksums = settingKey[Seq[String]]("The list of checksums to generate and to verify for dependencies.").withRank(BSetting)
|
||||
val forceUpdatePeriod = settingKey[Option[FiniteDuration]]("Duration after which to force a full update to occur").withRank(CSetting)
|
||||
val versionScheme = settingKey[Option[String]]("""Version scheme used for the subproject: Supported values are Some("early-semver"), Some("pvp"), and Some("semver-spec")""").withRank(BSetting)
|
||||
val libraryDependencySchemes = settingKey[Seq[ModuleID]]("""Version scheme to use for specific modules set as "org" %% "name" % "<scheme>": Supported values are "early-semver", "pvp", "semver-spec", "always", and "strict".""").withRank(BSetting)
|
||||
|
||||
val classifiersModule = taskKey[GetClassifiersModule]("classifiers-module").withRank(CTask)
|
||||
val compatibilityWarningOptions = settingKey[CompatibilityWarningOptions]("Configures warnings around Maven incompatibility.").withRank(CSetting)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import sbt.io.IO
|
|||
import sbt.io.syntax._
|
||||
import sbt.Project.richInitializeTask
|
||||
import sjsonnew.JsonFormat
|
||||
import scala.compat.Platform.EOL
|
||||
|
||||
private[sbt] object LibraryManagement {
|
||||
implicit val linter: sbt.dsl.LinterLevel.Ignore.type = sbt.dsl.LinterLevel.Ignore
|
||||
|
|
@ -36,7 +37,8 @@ private[sbt] object LibraryManagement {
|
|||
force: Boolean,
|
||||
depsUpdated: Boolean,
|
||||
uwConfig: UnresolvedWarningConfiguration,
|
||||
ewo: EvictionWarningOptions,
|
||||
evictionLevel: Level.Value,
|
||||
versionSchemeOverrides: Seq[ModuleID],
|
||||
mavenStyle: Boolean,
|
||||
compatWarning: CompatibilityWarningOptions,
|
||||
includeCallers: Boolean,
|
||||
|
|
@ -61,9 +63,19 @@ private[sbt] object LibraryManagement {
|
|||
val report1 = transform(report)
|
||||
|
||||
// Warn of any eviction and compatibility warnings
|
||||
val ew = EvictionWarning(module, ewo, report1)
|
||||
ew.lines.foreach(log.warn(_))
|
||||
ew.infoAllTheThings.foreach(log.info(_))
|
||||
val evictionError = EvictionError(report1, module, versionSchemeOverrides)
|
||||
if (evictionError.incompatibleEvictions.isEmpty) ()
|
||||
else
|
||||
evictionLevel match {
|
||||
case Level.Error =>
|
||||
val msgs = List(
|
||||
"",
|
||||
"this can be overridden using libraryDependencySchemes or evictionErrorLevel"
|
||||
)
|
||||
sys.error((evictionError.lines ++ msgs).mkString(EOL))
|
||||
case _ =>
|
||||
evictionError.lines.foreach(log.log(evictionLevel, _: String))
|
||||
}
|
||||
CompatibilityWarning.run(compatWarning, module, mavenStyle, log)
|
||||
val report2 = transformDetails(report1, includeCallers, includeDetails)
|
||||
report2
|
||||
|
|
@ -245,11 +257,6 @@ private[sbt] object LibraryManagement {
|
|||
// logical clock is folded into UpdateConfiguration
|
||||
conf1.withLogicalClock(LogicalClock(state0.hashCode))
|
||||
}
|
||||
val evictionOptions = Def.taskDyn {
|
||||
if (executionRoots.value.exists(_.key == evicted.key))
|
||||
Def.task(EvictionWarningOptions.empty)
|
||||
else Def.task((evictionWarningOptions in update).value)
|
||||
}.value
|
||||
cachedUpdate(
|
||||
// LM API
|
||||
lm = lm,
|
||||
|
|
@ -263,7 +270,8 @@ private[sbt] object LibraryManagement {
|
|||
force = shouldForce,
|
||||
depsUpdated = transitiveUpdate.value.exists(!_.stats.cached),
|
||||
uwConfig = (unresolvedWarningConfiguration in update).value,
|
||||
ewo = evictionOptions,
|
||||
evictionLevel = Level.Debug,
|
||||
versionSchemeOverrides = Nil,
|
||||
mavenStyle = publishMavenStyle.value,
|
||||
compatWarning = compatibilityWarningOptions.value,
|
||||
includeCallers = false,
|
||||
|
|
|
|||
|
|
@ -1,15 +1,10 @@
|
|||
// ThisBuild / useCoursier := false
|
||||
ThisBuild / organization := "com.example"
|
||||
ThisBuild / scalaVersion := "2.12.12"
|
||||
ThisBuild / scalaVersion := "2.13.3"
|
||||
ThisBuild / versionScheme := Some("semver-spec")
|
||||
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
|
||||
|
||||
def commonSettings: Seq[Def.Setting[_]] =
|
||||
Seq(
|
||||
ivyPaths := IvyPaths(
|
||||
(ThisBuild / baseDirectory).value,
|
||||
Some((LocalRootProject / target).value / "ivy-cache")
|
||||
),
|
||||
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project"),
|
||||
publishTo := Some(MavenCache("local-maven", (LocalRootProject / target).value / "local-maven")),
|
||||
resolvers += MavenCache("local-maven", (LocalRootProject / target).value / "local-maven"),
|
||||
|
|
@ -56,7 +51,17 @@ val use = project
|
|||
}
|
||||
log.info(s"extraAttributes = $extraAttributes")
|
||||
assert(extraAttributes.nonEmpty, s"$extraAttributes is empty")
|
||||
val ew = EvictionWarning(ivyModule.value, (evicted / evictionWarningOptions).value, report)
|
||||
assert(ew.directEvictions.isEmpty, s"${ew.directEvictions} is not empty")
|
||||
},
|
||||
)
|
||||
|
||||
val use2 = project
|
||||
.settings(commonSettings)
|
||||
.settings(
|
||||
name := "use2",
|
||||
libraryDependencies ++= Seq(
|
||||
"org.http4s" %% "http4s-blaze-server" % "0.21.11",
|
||||
// https://repo1.maven.org/maven2/org/typelevel/cats-effect_2.13/3.0.0-M4/cats-effect_2.13-3.0.0-M4.pom
|
||||
// is published with early-semver
|
||||
"org.typelevel" %% "cats-effect" % "3.0.0-M4",
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,3 +3,4 @@
|
|||
> middle/publish
|
||||
|
||||
> use/check
|
||||
-> use2/update
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ private[sbt] object ZincComponentCompiler {
|
|||
private[sbt] final lazy val incrementalVersion: String = ZincComponentManager.version
|
||||
|
||||
private val CompileConf = Some(Configurations.Compile.name)
|
||||
private val lock: AnyRef = new {}
|
||||
|
||||
private[sbt] def getDefaultBridgeModule(scalaVersion: String): ModuleID = {
|
||||
val compilerBridgeId = scalaVersion match {
|
||||
|
|
@ -68,7 +69,7 @@ private[sbt] object ZincComponentCompiler {
|
|||
bridgeSources: ModuleID,
|
||||
scalaInstance: ScalaInstance,
|
||||
logger: Logger,
|
||||
): File = {
|
||||
): File = lock.synchronized {
|
||||
val raw = new RawCompiler(scalaInstance, ClasspathOptionsUtil.auto, logger)
|
||||
val zinc =
|
||||
new ZincComponentCompiler(raw, manager, dependencyResolution, bridgeSources, logger)
|
||||
|
|
@ -312,7 +313,7 @@ private object ZincLMHelper {
|
|||
logger.info(s"Attempting to fetch $dependencies.")
|
||||
dependencyResolution.update(module, updateConfiguration, warningConf, logger) match {
|
||||
case Left(uw) =>
|
||||
logger.debug(s"Couldn't retrieve module(s) ${prettyPrintDependency(module)}.")
|
||||
logger.debug(s"couldn't retrieve module(s) ${prettyPrintDependency(module)}.")
|
||||
val unretrievedMessage = s"The $desc could not be retrieved."
|
||||
val unresolvedLines = UnresolvedWarning.unresolvedWarningLines.showLines(uw).mkString("\n")
|
||||
throw new InvalidComponent(s"$unretrievedMessage\n$unresolvedLines")
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ class ZincComponentManager(
|
|||
def notFound = invalid(s"Could not find required component '$id'")
|
||||
def getOrElse(orElse: => Iterable[File]): Iterable[File] = {
|
||||
val existing = provider.component(id)
|
||||
if (existing.isEmpty) orElse else existing
|
||||
// log.info(s"[zinc-lm] existing = ${existing.toList}")
|
||||
if (existing.isEmpty) orElse
|
||||
else existing
|
||||
}
|
||||
|
||||
def createAndCache = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue