From 43e0428bed9ba427b05e5ac801259c281fed8b61 Mon Sep 17 00:00:00 2001 From: Satoshi Dev <162055292+0xsatoshi99@users.noreply.github.com> Date: Tue, 13 Jan 2026 18:13:47 -0800 Subject: [PATCH] [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 --- main/src/main/scala/sbt/Main.scala | 2 +- main/src/main/scala/sbt/MainLoop.scala | 2 +- .../src/main/scala/sbt/scriptedtest/ScriptedTests.scala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main/src/main/scala/sbt/Main.scala b/main/src/main/scala/sbt/Main.scala index fce02ce41..eca59bd5d 100644 --- a/main/src/main/scala/sbt/Main.scala +++ b/main/src/main/scala/sbt/Main.scala @@ -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) diff --git a/main/src/main/scala/sbt/MainLoop.scala b/main/src/main/scala/sbt/MainLoop.scala index d0a0f4f5d..a41aedb1f 100644 --- a/main/src/main/scala/sbt/MainLoop.scala +++ b/main/src/main/scala/sbt/MainLoop.scala @@ -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 diff --git a/scripted-sbt/src/main/scala/sbt/scriptedtest/ScriptedTests.scala b/scripted-sbt/src/main/scala/sbt/scriptedtest/ScriptedTests.scala index 30bd860e4..d07cd626a 100644 --- a/scripted-sbt/src/main/scala/sbt/scriptedtest/ScriptedTests.scala +++ b/scripted-sbt/src/main/scala/sbt/scriptedtest/ScriptedTests.scala @@ -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 }