Add Test configuration to default evictionWarningOptions

This commit is contained in:
zainab-ali
2026-04-17 11:00:47 +01:00
parent 0507d11440
commit 6d806c723a
6 changed files with 19 additions and 16 deletions
+3
View File
@@ -1234,6 +1234,9 @@ lazy val lmCore = (project in file("lm-core"))
ProblemFilters.exclude[DirectMissingMethodProblem](
"sbt.librarymanagement.EvictionError.processEvictions*"
),
ProblemFilters.exclude[IncompatibleMethTypeProblem](
"sbt.librarymanagement.EvictionWarning.buildEvictions"
),
ProblemFilters.exclude[DirectMissingMethodProblem](
"sbt.librarymanagement.EvictionError.<init>$*"
),
@@ -30,7 +30,7 @@ object EvictionError {
assumedVersionScheme,
assumedVersionSchemeJava,
assumedEvictionErrorLevel,
EvictionWarningOptions.full,
EvictionWarningOptions.default.configurations,
)
}
@@ -41,12 +41,11 @@ object EvictionError {
assumedVersionScheme: String,
assumedVersionSchemeJava: String,
assumedEvictionErrorLevel: Level.Value,
options: EvictionWarningOptions,
configurations: Seq[ConfigRef],
): EvictionError = {
val evictions = EvictionWarning.buildEvictions(options, report)
val evictions = EvictionWarning.buildEvictions(configurations, report)
processEvictions(
module,
options,
evictions,
schemes,
assumedVersionScheme,
@@ -57,7 +56,6 @@ object EvictionError {
private[sbt] def processEvictions(
module: ModuleDescriptor,
options: EvictionWarningOptions,
reports: Seq[OrganizationArtifactReport],
schemes: Seq[ModuleID],
assumedVersionScheme: String,
@@ -73,8 +71,8 @@ object EvictionError {
detail.name,
winner,
evicteds,
true,
options.showCallers
includesDirect = true,
showCallers = true
)
}
val incompatibleEvictions: mutable.ListBuffer[(EvictionPair, String)] = mutable.ListBuffer()
@@ -195,7 +193,7 @@ final class EvictionError private[sbt] (
case _ => " is evicted for all versions"
}
val title = s"\t* ${a.organization}:${a.name}$winnerRev"
val lines = title :: (if (a.showCallers) callers.reverse else Nil) ::: List("")
val lines = title :: callers.reverse ::: List("")
out ++= lines
})
out.toList
@@ -86,7 +86,7 @@ object EvictionWarningOptions {
)
def summary: EvictionWarningOptions =
new EvictionWarningOptions(
Vector(Compile),
Vector(Compile, Test),
warnScalaVersionEviction = false,
warnDirectEvictions = false,
warnTransitiveEvictions = false,
@@ -269,17 +269,17 @@ object EvictionWarning {
options: EvictionWarningOptions,
report: UpdateReport
): EvictionWarning = {
val evictions = buildEvictions(options, report)
val evictions = buildEvictions(options.configurations, report)
processEvictions(module, options, evictions)
}
private[sbt] def buildEvictions(
options: EvictionWarningOptions,
configurations: Seq[ConfigRef],
report: UpdateReport
): Seq[OrganizationArtifactReport] = {
val buffer: mutable.ListBuffer[OrganizationArtifactReport] = mutable.ListBuffer()
val confs = report.configurations filter { x =>
options.configurations.contains[ConfigRef](x.configuration)
configurations.contains[ConfigRef](x.configuration)
}
confs flatMap { confReport =>
confReport.details map { detail =>
+3 -1
View File
@@ -2985,7 +2985,7 @@ object Classpaths {
Defaults.globalDefaults(
Seq(
conflictWarning :== ConflictWarning.default("global"),
evictionWarningOptions := EvictionWarningOptions.full,
evictionWarningOptions := EvictionWarningOptions.default,
compatibilityWarningOptions :== CompatibilityWarningOptions.default,
homepage :== None,
startYear :== None,
@@ -3405,6 +3405,8 @@ 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
@@ -82,7 +82,7 @@ private[sbt] object LibraryManagement {
assumedVersionScheme,
assumedVersionSchemeJava,
assumedEvictionErrorLevel,
evictionWarningOptions,
evictionWarningOptions.configurations,
)
def extraLines = List(
"",
@@ -393,7 +393,7 @@ private[sbt] object LibraryManagement {
transitiveUpdates = tu,
uwConfig = uwConfig,
evictionLevel = Level.Debug,
evictionWarningOptions = EvictionWarningOptions.full,
evictionWarningOptions = EvictionWarningOptions.default,
versionSchemeOverrides = Nil,
assumedEvictionErrorLevel = Level.Debug,
assumedVersionScheme = VersionScheme.Always,
@@ -5,5 +5,5 @@
> update
# Update should succeed if eviction options are less strict
> set evictionErrorLevel := Level.Error
> set update / evictionWarningOptions := EvictionWarningOptions.summary
> set update / evictionWarningOptions := EvictionWarningOptions.default.withConfigurations(Vector(Compile))
> update