[2.x] fix: trim whitespace from sbt.version in build.properties (#8524)

When sbt.version in build.properties has trailing whitespace,
sbt incorrectly reports a version mismatch even after reboot.

This fix trims the property value in all places where sbt.version
is read from build.properties:
- Main.scala (version mismatch warning)
- MainLoop.scala (clean command version detection)
- ScriptedTests.scala (test compatibility check)

Fixes #8103
This commit is contained in:
Satoshi Dev 2026-01-13 18:13:47 -08:00 committed by GitHub
parent eb81ff9000
commit 43e0428bed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 3 deletions

View File

@ -933,7 +933,7 @@ object BuiltinCommands {
val sbtVersionBuildOpt = if (buildProps.exists) {
val buildProperties = new Properties()
IO.load(buildProperties, buildProps)
Option(buildProperties.getProperty(sbtVersionProperty))
Option(buildProperties.getProperty(sbtVersionProperty)).map(_.trim)
} else None
val sbtVersionOpt = sbtVersionSystemOpt.orElse(sbtVersionBuildOpt)

View File

@ -99,7 +99,7 @@ private[sbt] object MainLoop:
val sbtVersionOpt = if (buildProps.exists) {
val buildProperties = new Properties()
IO.load(buildProperties, buildProps)
Option(buildProperties.getProperty("sbt.version"))
Option(buildProperties.getProperty("sbt.version")).map(_.trim)
} else None
val sbtVersion = sbtVersionOpt.getOrElse(appId.version)
val currentArtDirs = defaultBoot * "*" / appId.groupID / appId.name / sbtVersion

View File

@ -676,7 +676,7 @@ class ScriptedRunner {
IO.load(buildProperties, buildPropertiesFile)
Option(buildProperties.getProperty("sbt.version")) match {
Option(buildProperties.getProperty("sbt.version")).map(_.trim) match {
case Some(version) => binarySbtVersion(version) == binarySbtVersion(sbtVersion)
case None => true
}