mirror of
https://github.com/sbt/sbt.git
synced 2026-10-06 01:54:17 +02:00
Add Test configuration to evictionWarningOptions
This commit is contained in:
@@ -1228,6 +1228,18 @@ lazy val lmCore = (project in file("lm-core"))
|
||||
},
|
||||
mimaSettings,
|
||||
mimaBinaryIssueFilters ++= Seq(
|
||||
ProblemFilters.exclude[IncompatibleMethTypeProblem](
|
||||
"sbt.librarymanagement.EvictionError.apply"
|
||||
),
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem](
|
||||
"sbt.librarymanagement.EvictionError.processEvictions*"
|
||||
),
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem](
|
||||
"sbt.librarymanagement.EvictionError.<init>$*"
|
||||
),
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem](
|
||||
"sbt.librarymanagement.EvictionError.configuration"
|
||||
)
|
||||
),
|
||||
)
|
||||
.dependsOn(utilLogging, utilPosition, utilCache)
|
||||
|
||||
@@ -30,7 +30,7 @@ object EvictionError {
|
||||
assumedVersionScheme,
|
||||
assumedVersionSchemeJava,
|
||||
assumedEvictionErrorLevel,
|
||||
Configurations.Compile,
|
||||
EvictionWarningOptions.full,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -41,9 +41,8 @@ object EvictionError {
|
||||
assumedVersionScheme: String,
|
||||
assumedVersionSchemeJava: String,
|
||||
assumedEvictionErrorLevel: Level.Value,
|
||||
configuration: ConfigRef,
|
||||
options: EvictionWarningOptions,
|
||||
): EvictionError = {
|
||||
val options = EvictionWarningOptions.full.withConfigurations(Vector(configuration))
|
||||
val evictions = EvictionWarning.buildEvictions(options, report)
|
||||
processEvictions(
|
||||
module,
|
||||
@@ -53,7 +52,6 @@ object EvictionError {
|
||||
assumedVersionScheme,
|
||||
assumedVersionSchemeJava,
|
||||
assumedEvictionErrorLevel,
|
||||
configuration,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -65,7 +63,6 @@ object EvictionError {
|
||||
assumedVersionScheme: String,
|
||||
assumedVersionSchemeJava: String,
|
||||
assumedEvictionErrorLevel: Level.Value,
|
||||
configuration: ConfigRef = Configurations.Compile,
|
||||
): EvictionError = {
|
||||
val directDependencies = module.directDependencies
|
||||
val pairs = reports map { detail =>
|
||||
@@ -155,7 +152,6 @@ object EvictionError {
|
||||
new EvictionError(
|
||||
incompatibleEvictions.toList,
|
||||
assumedIncompatibleEvictions.toList,
|
||||
configuration,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -167,7 +163,6 @@ object EvictionError {
|
||||
final class EvictionError private[sbt] (
|
||||
val incompatibleEvictions: Seq[(EvictionPair, String)],
|
||||
val assumedIncompatibleEvictions: Seq[(EvictionPair, String)],
|
||||
val configuration: ConfigRef = Configurations.Compile,
|
||||
) {
|
||||
def run(): Unit =
|
||||
if (incompatibleEvictions.nonEmpty) {
|
||||
@@ -178,13 +173,9 @@ final class EvictionError private[sbt] (
|
||||
|
||||
def toAssumedLines: List[String] = toLines(assumedIncompatibleEvictions, true)
|
||||
|
||||
private def configurationLabel: String =
|
||||
if (configuration.name == Configurations.Compile.name) "library dependencies"
|
||||
else s"${configuration.name.capitalize} dependencies"
|
||||
|
||||
def toLines(evictions: Seq[(EvictionPair, String)], assumed: Boolean): List[String] = {
|
||||
val out: mutable.ListBuffer[String] = mutable.ListBuffer()
|
||||
out += s"found version conflict(s) in $configurationLabel; some are suspected to be binary incompatible:"
|
||||
out += "found version conflict(s) in library dependencies; some are suspected to be binary incompatible:"
|
||||
out += ""
|
||||
evictions.foreach({ (a, scheme) =>
|
||||
val seen: mutable.Set[ModuleID] = mutable.Set()
|
||||
|
||||
@@ -2,6 +2,7 @@ package sbt.librarymanagement
|
||||
|
||||
import collection.mutable
|
||||
import Configurations.Compile
|
||||
import Configurations.Test
|
||||
import ScalaArtifacts.{ LibraryID, CompilerID }
|
||||
import sbt.internal.librarymanagement.{ VersionSchemes, VersionRange }
|
||||
import sbt.util.Logger
|
||||
@@ -74,7 +75,7 @@ object EvictionWarningOptions {
|
||||
def default: EvictionWarningOptions = summary
|
||||
def full: EvictionWarningOptions =
|
||||
new EvictionWarningOptions(
|
||||
Vector(Compile),
|
||||
Vector(Compile, Test),
|
||||
warnScalaVersionEviction = true,
|
||||
warnDirectEvictions = true,
|
||||
warnTransitiveEvictions = true,
|
||||
|
||||
@@ -2985,7 +2985,7 @@ object Classpaths {
|
||||
Defaults.globalDefaults(
|
||||
Seq(
|
||||
conflictWarning :== ConflictWarning.default("global"),
|
||||
evictionWarningOptions := EvictionWarningOptions.default,
|
||||
evictionWarningOptions := EvictionWarningOptions.full,
|
||||
compatibilityWarningOptions :== CompatibilityWarningOptions.default,
|
||||
homepage :== None,
|
||||
startYear :== None,
|
||||
@@ -3405,8 +3405,6 @@ object Classpaths {
|
||||
ConflictWarning(conflictWarning.value, report, streams.value.log)
|
||||
report
|
||||
},
|
||||
update / evictionWarningOptions := evictionWarningOptions.value,
|
||||
evicted / evictionWarningOptions := EvictionWarningOptions.full,
|
||||
evicted := Def.uncached {
|
||||
import ShowLines.*
|
||||
val report = updateTask.value
|
||||
@@ -3908,6 +3906,7 @@ object Classpaths {
|
||||
Seq[UpdateReport],
|
||||
UnresolvedWarningConfiguration,
|
||||
Level.Value,
|
||||
EvictionWarningOptions,
|
||||
Seq[ModuleID],
|
||||
Level.Value,
|
||||
String,
|
||||
@@ -3938,6 +3937,7 @@ object Classpaths {
|
||||
transitiveUpdate.toTaskable,
|
||||
(update / unresolvedWarningConfiguration).toTaskable,
|
||||
evictionErrorLevel.toTaskable,
|
||||
(update / evictionWarningOptions).toTaskable,
|
||||
libraryDependencySchemes.toTaskable,
|
||||
assumedEvictionErrorLevel.toTaskable,
|
||||
assumedVersionScheme.toTaskable,
|
||||
@@ -3968,6 +3968,7 @@ object Classpaths {
|
||||
tu,
|
||||
uwConfig,
|
||||
eel,
|
||||
ewo,
|
||||
lds,
|
||||
aeel,
|
||||
avs,
|
||||
@@ -4036,6 +4037,7 @@ object Classpaths {
|
||||
transitiveUpdates = tu,
|
||||
uwConfig = uwConfig,
|
||||
evictionLevel = eel,
|
||||
evictionWarningOptions = ewo,
|
||||
versionSchemeOverrides = lds,
|
||||
assumedEvictionErrorLevel = aeel,
|
||||
assumedVersionScheme = avs,
|
||||
|
||||
@@ -46,6 +46,7 @@ private[sbt] object LibraryManagement {
|
||||
transitiveUpdates: Seq[UpdateReport],
|
||||
uwConfig: UnresolvedWarningConfiguration,
|
||||
evictionLevel: Level.Value,
|
||||
evictionWarningOptions: EvictionWarningOptions,
|
||||
versionSchemeOverrides: Seq[ModuleID],
|
||||
assumedEvictionErrorLevel: Level.Value,
|
||||
assumedVersionScheme: String,
|
||||
@@ -74,29 +75,20 @@ private[sbt] object LibraryManagement {
|
||||
val report1 = transform(report)
|
||||
|
||||
// Warn of any eviction and compatibility warnings
|
||||
val evictionErrorCompile = EvictionError(
|
||||
val evictionError = EvictionError(
|
||||
report1,
|
||||
module,
|
||||
versionSchemeOverrides,
|
||||
assumedVersionScheme,
|
||||
assumedVersionSchemeJava,
|
||||
assumedEvictionErrorLevel,
|
||||
Configurations.Compile,
|
||||
)
|
||||
val evictionErrorTest = EvictionError(
|
||||
report1,
|
||||
module,
|
||||
versionSchemeOverrides,
|
||||
assumedVersionScheme,
|
||||
assumedVersionSchemeJava,
|
||||
assumedEvictionErrorLevel,
|
||||
Configurations.Test,
|
||||
evictionWarningOptions,
|
||||
)
|
||||
def extraLines = List(
|
||||
"",
|
||||
"this can be overridden using libraryDependencySchemes or evictionErrorLevel"
|
||||
)
|
||||
def errorLinesFor(evictionError: EvictionError): Seq[String] =
|
||||
val errorLines: Seq[String] =
|
||||
(if (
|
||||
evictionError.incompatibleEvictions.isEmpty
|
||||
|| evictionLevel != Level.Error
|
||||
@@ -107,20 +99,13 @@ private[sbt] object LibraryManagement {
|
||||
|| assumedEvictionErrorLevel != Level.Error
|
||||
) Nil
|
||||
else evictionError.toAssumedLines)
|
||||
val errorLines: Seq[String] =
|
||||
errorLinesFor(evictionErrorCompile) ++ errorLinesFor(evictionErrorTest)
|
||||
if (errorLines.nonEmpty) sys.error((errorLines ++ extraLines).mkString(System.lineSeparator))
|
||||
else {
|
||||
if (evictionErrorCompile.incompatibleEvictions.isEmpty) ()
|
||||
else evictionErrorCompile.lines.foreach(log.log(evictionLevel, _: String))
|
||||
if (evictionErrorCompile.assumedIncompatibleEvictions.isEmpty) ()
|
||||
if (evictionError.incompatibleEvictions.isEmpty) ()
|
||||
else evictionError.lines.foreach(log.log(evictionLevel, _: String))
|
||||
if (evictionError.assumedIncompatibleEvictions.isEmpty) ()
|
||||
else
|
||||
evictionErrorCompile.toAssumedLines.foreach(log.log(assumedEvictionErrorLevel, _: String))
|
||||
|
||||
if (evictionErrorTest.incompatibleEvictions.isEmpty) ()
|
||||
else evictionErrorTest.lines.foreach(log.log(evictionLevel, _: String))
|
||||
if (evictionErrorTest.assumedIncompatibleEvictions.isEmpty) ()
|
||||
else evictionErrorTest.toAssumedLines.foreach(log.log(assumedEvictionErrorLevel, _: String))
|
||||
evictionError.toAssumedLines.foreach(log.log(assumedEvictionErrorLevel, _: String))
|
||||
}
|
||||
CompatibilityWarning.run(compatWarning, module, mavenStyle, log)
|
||||
val report2 = transformDetails(report1, includeCallers, includeDetails)
|
||||
@@ -408,6 +393,7 @@ private[sbt] object LibraryManagement {
|
||||
transitiveUpdates = tu,
|
||||
uwConfig = uwConfig,
|
||||
evictionLevel = Level.Debug,
|
||||
evictionWarningOptions = EvictionWarningOptions.full,
|
||||
versionSchemeOverrides = Nil,
|
||||
assumedEvictionErrorLevel = Level.Debug,
|
||||
assumedVersionScheme = VersionScheme.Always,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// https://github.com/sbt/sbt/issues/8410
|
||||
scalaVersion := "3.3.4"
|
||||
scalaVersion := "3.3.7"
|
||||
libraryDependencies ++= Seq(
|
||||
"org.typelevel" %% "weaver-cats" % "0.8.4" % Test,
|
||||
"com.siriusxm" %% "snapshot4s-weaver" % "0.1.5" % Test,
|
||||
"org.typelevel" %% "weaver-cats" % "0.11.1" % Test,
|
||||
"com.siriusxm" %% "snapshot4s-weaver" % "0.2.2" % Test,
|
||||
)
|
||||
|
||||
@@ -1 +1,9 @@
|
||||
# Update should fail as test dependencies have version conflicts
|
||||
-> update
|
||||
# Update should succeed if the error level is reduced to Warn
|
||||
> set evictionErrorLevel := Level.Warn
|
||||
> update
|
||||
# Update should succeed if eviction options are less strict
|
||||
> set evictionErrorLevel := Level.Error
|
||||
> set update / evictionWarningOptions := EvictionWarningOptions.summary
|
||||
> update
|
||||
|
||||
Reference in New Issue
Block a user