[2.x] fix: Restore bincompat for ScriptedRun methods (#8654)

In PR #8621, I added a new `keepTempDirectory` parameter to `ScriptedRun.run()` and `invoke()` methods. To suppress MiMa warnings, I added `mimaBinaryIssueFilters` for:
- `DirectMissingMethodProblem("sbt.ScriptedRun.run")`
- `DirectMissingMethodProblem("sbt.ScriptedRun.invoke")`
- `DirectMissingMethodProblem` for various internal `RunV1`, `RunV2`, `RunInParallelV1`, `RunInParallelV2` classes

However, this broke binary compatibility, which prevents sbt 1.x from calling sbt 2.x for cross-building (building sbt 2.x plugins using sbt 1.x).
This commit is contained in:
bitloi 2026-01-29 11:07:44 -05:00 committed by GitHub
parent 81c3d7d6c6
commit 627c484cd8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 56 additions and 17 deletions

View File

@ -724,14 +724,8 @@ lazy val mainProj = (project in file("main"))
mimaBinaryIssueFilters ++= Vector(
exclude[DirectMissingMethodProblem]("sbt.internal.ConsoleProject.*"),
exclude[DirectMissingMethodProblem]("sbt.coursierint.LMCoursier.coursierConfiguration"),
exclude[DirectMissingMethodProblem]("sbt.ScriptedRun.run"),
exclude[DirectMissingMethodProblem]("sbt.ScriptedRun.invoke"),
exclude[ReversedMissingMethodProblem]("sbt.ScriptedRun.invoke"),
exclude[DirectMissingMethodProblem]("sbt.ScriptedRun#RunInParallelV1.invoke"),
exclude[DirectMissingMethodProblem]("sbt.ScriptedRun#RunInParallelV2.invoke"),
exclude[DirectMissingMethodProblem]("sbt.ScriptedRun#RunV1.invoke"),
exclude[DirectMissingMethodProblem]("sbt.ScriptedRun#RunV2.invoke"),
exclude[IncompatibleMethTypeProblem]("sbt.internal.Compiler.scalaInstanceTask"),
exclude[ReversedMissingMethodProblem]("sbt.ScriptedRun.invoke"),
),
)
.dependsOn(lmCore, lmIvy, lmCoursierShadedPublishing)

View File

@ -10,9 +10,31 @@ package sbt
import java.io.File
import java.lang.reflect.Method
import scala.annotation.unused
sealed trait ScriptedRun {
final def run(
resourceBaseDirectory: File,
bufferLog: Boolean,
tests: Seq[String],
launcherJar: File,
javaCommand: String,
launchOpts: Seq[String],
prescripted: java.util.List[File],
instances: Int,
): Unit = {
run(
resourceBaseDirectory,
bufferLog,
tests,
launcherJar,
javaCommand,
launchOpts,
prescripted,
instances,
keepTempDirectory = false,
)
}
final def run(
resourceBaseDirectory: File,
bufferLog: Boolean,
@ -40,6 +62,29 @@ sealed trait ScriptedRun {
} catch { case e: java.lang.reflect.InvocationTargetException => throw e.getCause }
}
protected def invoke(
resourceBaseDirectory: File,
bufferLog: java.lang.Boolean,
tests: Array[String],
launcherJar: File,
javaCommand: String,
launchOpts: Array[String],
prescripted: java.util.List[File],
instances: java.lang.Integer,
): AnyRef = {
invoke(
resourceBaseDirectory,
bufferLog,
tests,
launcherJar,
javaCommand,
launchOpts,
prescripted,
instances,
keepTempDirectory = false,
)
}
protected def invoke(
resourceBaseDirectory: File,
bufferLog: java.lang.Boolean,
@ -115,11 +160,11 @@ object ScriptedRun {
bufferLog: java.lang.Boolean,
tests: Array[String],
launcherJar: File,
@unused javaCommand: String,
javaCommand: String,
launchOpts: Array[String],
prescripted: java.util.List[File],
@unused instances: java.lang.Integer,
@unused keepTempDirectory: java.lang.Boolean,
instances: java.lang.Integer,
keepTempDirectory: java.lang.Boolean,
): AnyRef =
run.invoke(
scriptedTests,
@ -138,11 +183,11 @@ object ScriptedRun {
bufferLog: java.lang.Boolean,
tests: Array[String],
launcherJar: File,
@unused javaCommand: String,
javaCommand: String,
launchOpts: Array[String],
prescripted: java.util.List[File],
instances: Integer,
@unused keepTempDirectory: java.lang.Boolean,
keepTempDirectory: java.lang.Boolean,
): AnyRef =
runInParallel.invoke(
scriptedTests,
@ -165,8 +210,8 @@ object ScriptedRun {
javaCommand: String,
launchOpts: Array[String],
prescripted: java.util.List[File],
@unused instances: java.lang.Integer,
@unused keepTempDirectory: java.lang.Boolean,
instances: java.lang.Integer,
keepTempDirectory: java.lang.Boolean,
): AnyRef =
run.invoke(
scriptedTests,
@ -190,7 +235,7 @@ object ScriptedRun {
launchOpts: Array[String],
prescripted: java.util.List[File],
instances: Integer,
@unused keepTempDirectory: java.lang.Boolean,
keepTempDirectory: java.lang.Boolean,
): AnyRef =
runInParallel.invoke(
scriptedTests,
@ -214,7 +259,7 @@ object ScriptedRun {
javaCommand: String,
launchOpts: Array[String],
prescripted: java.util.List[File],
@unused instances: java.lang.Integer,
instances: java.lang.Integer,
keepTempDirectory: java.lang.Boolean,
): AnyRef =
run.invoke(