[2.x] refactor: Replace string Array with ju.List (#9138)

**Problem**
Scala 3 supposedly has problem with String array in structural types.

**Solution**
This works around the issue by using ju.List.
This commit is contained in:
eugene yokota 2026-04-27 00:22:30 -04:00 committed by Eugene Yokota
parent 30aded8ced
commit d59a2be85a
5 changed files with 74 additions and 62 deletions

View File

@ -524,6 +524,9 @@ lazy val scriptedSbtProj = (project in file("scripted-sbt"))
libraryDependencies ++= Seq(launcherInterface % "provided"), libraryDependencies ++= Seq(launcherInterface % "provided"),
mimaSettings, mimaSettings,
mimaBinaryIssueFilters ++= Seq( mimaBinaryIssueFilters ++= Seq(
exclude[DirectMissingMethodProblem](
"sbt.scriptedtest.ScriptedTests.runInParallel$default$10"
),
), ),
) )
.dependsOn(lmCore) .dependsOn(lmCore)

View File

@ -25,6 +25,7 @@ import sbt.io.syntax.*
import sbt.librarymanagement.* import sbt.librarymanagement.*
import sbt.librarymanagement.syntax.* import sbt.librarymanagement.syntax.*
import sbt.nio.file.{ Glob, RecursiveGlob } import sbt.nio.file.{ Glob, RecursiveGlob }
import scala.jdk.CollectionConverters.*
object ScriptedPlugin extends AutoPlugin { object ScriptedPlugin extends AutoPlugin {
@ -179,10 +180,10 @@ object ScriptedPlugin extends AutoPlugin {
scriptedRun.value.run( scriptedRun.value.run(
sbtTestDirectory.value, sbtTestDirectory.value,
scriptedBufferLog.value, scriptedBufferLog.value,
args, args.toList.asJava,
sbtLauncher.value, sbtLauncher.value,
Fork.javaCommand((scripted / javaHome).value, "java").getAbsolutePath, Fork.javaCommand((scripted / javaHome).value, "java").getAbsolutePath,
scriptedLaunchOpts.value, scriptedLaunchOpts.value.toList.asJava,
new java.util.ArrayList[File](), new java.util.ArrayList[File](),
scriptedParallelInstances.value, scriptedParallelInstances.value,
scriptedKeepTempDirectory.value, scriptedKeepTempDirectory.value,

View File

@ -12,6 +12,7 @@ import java.io.{ File, FileFilter as JFileFilter }
import java.lang.reflect.Method import java.lang.reflect.Method
import sbt.io.{ AllPassFilter, NothingFilter } import sbt.io.{ AllPassFilter, NothingFilter }
import scala.jdk.CollectionConverters.*
sealed trait ScriptedRun { sealed trait ScriptedRun {
final def run( final def run(
@ -64,13 +65,14 @@ sealed trait ScriptedRun {
} catch { case e: java.lang.reflect.InvocationTargetException => throw e.getCause } } catch { case e: java.lang.reflect.InvocationTargetException => throw e.getCause }
} }
// v4
final def run( final def run(
resourceBaseDirectory: File, resourceBaseDirectory: File,
bufferLog: Boolean, bufferLog: Boolean,
tests: Seq[String], tests: java.util.List[String],
launcherJar: File, launcherJar: File,
javaCommand: String, javaCommand: String,
launchOpts: Seq[String], launchOpts: java.util.List[String],
prescripted: java.util.List[File], prescripted: java.util.List[File],
instances: Int, instances: Int,
keepTempDirectory: Boolean, keepTempDirectory: Boolean,
@ -81,10 +83,10 @@ sealed trait ScriptedRun {
invoke( invoke(
resourceBaseDirectory, resourceBaseDirectory,
bufferLog, bufferLog,
tests.toArray, tests,
launcherJar, launcherJar,
javaCommand, javaCommand,
launchOpts.toArray, launchOpts,
prescripted, prescripted,
instances, instances,
keepTempDirectory, keepTempDirectory,
@ -130,14 +132,14 @@ sealed trait ScriptedRun {
keepTempDirectory: java.lang.Boolean, keepTempDirectory: java.lang.Boolean,
): AnyRef ): AnyRef
// Default drops filters and calls V3 invoke so V1/V2/V3 subclasses need not override. // v4. Default drops filters and calls V3 invoke so V1/V2/V3 subclasses need not override.
protected def invoke( protected def invoke(
resourceBaseDirectory: File, resourceBaseDirectory: File,
bufferLog: java.lang.Boolean, bufferLog: java.lang.Boolean,
tests: Array[String], tests: java.util.List[String],
launcherJar: File, launcherJar: File,
javaCommand: String, javaCommand: String,
launchOpts: Array[String], launchOpts: java.util.List[String],
prescripted: java.util.List[File], prescripted: java.util.List[File],
instances: java.lang.Integer, instances: java.lang.Integer,
keepTempDirectory: java.lang.Boolean, keepTempDirectory: java.lang.Boolean,
@ -147,10 +149,10 @@ sealed trait ScriptedRun {
invoke( invoke(
resourceBaseDirectory, resourceBaseDirectory,
bufferLog, bufferLog,
tests, tests.toArray(Array.empty[String]),
launcherJar, launcherJar,
javaCommand, javaCommand,
launchOpts, launchOpts.toArray(Array.empty[String]),
prescripted, prescripted,
instances, instances,
keepTempDirectory, keepTempDirectory,
@ -167,6 +169,7 @@ object ScriptedRun {
val asCls = classOf[Array[String]] val asCls = classOf[Array[String]]
val sCls = classOf[String] val sCls = classOf[String]
val lfCls = classOf[java.util.List[File]] val lfCls = classOf[java.util.List[File]]
val lsCls = classOf[java.util.List[String]]
val iCls = classOf[Int] val iCls = classOf[Int]
val ffCls = classOf[JFileFilter] val ffCls = classOf[JFileFilter]
@ -179,10 +182,10 @@ object ScriptedRun {
"runInParallel", "runInParallel",
fCls, fCls,
bCls, bCls,
asCls, lsCls,
fCls, fCls,
sCls, sCls,
asCls, lsCls,
lfCls, lfCls,
iCls, iCls,
bCls, bCls,
@ -223,10 +226,10 @@ object ScriptedRun {
"run", "run",
fCls, fCls,
bCls, bCls,
asCls, lsCls,
fCls, fCls,
sCls, sCls,
asCls, lsCls,
lfCls, lfCls,
bCls, bCls,
ffCls, ffCls,
@ -420,10 +423,10 @@ object ScriptedRun {
invoke( invoke(
resourceBaseDirectory, resourceBaseDirectory,
bufferLog, bufferLog,
tests, tests.toList.asJava,
launcherJar, launcherJar,
javaCommand, javaCommand,
launchOpts, launchOpts.toList.asJava,
prescripted, prescripted,
instances, instances,
keepTempDirectory, keepTempDirectory,
@ -434,10 +437,10 @@ object ScriptedRun {
override protected def invoke( override protected def invoke(
resourceBaseDirectory: File, resourceBaseDirectory: File,
bufferLog: java.lang.Boolean, bufferLog: java.lang.Boolean,
tests: Array[String], tests: java.util.List[String],
launcherJar: File, launcherJar: File,
javaCommand: String, javaCommand: String,
launchOpts: Array[String], launchOpts: java.util.List[String],
prescripted: java.util.List[File], prescripted: java.util.List[File],
instances: java.lang.Integer, instances: java.lang.Integer,
keepTempDirectory: java.lang.Boolean, keepTempDirectory: java.lang.Boolean,
@ -474,10 +477,10 @@ object ScriptedRun {
invoke( invoke(
resourceBaseDirectory, resourceBaseDirectory,
bufferLog, bufferLog,
tests, tests.toList.asJava,
launcherJar, launcherJar,
javaCommand, javaCommand,
launchOpts, launchOpts.toList.asJava,
prescripted, prescripted,
instances, instances,
keepTempDirectory, keepTempDirectory,
@ -488,10 +491,10 @@ object ScriptedRun {
override protected def invoke( override protected def invoke(
resourceBaseDirectory: File, resourceBaseDirectory: File,
bufferLog: java.lang.Boolean, bufferLog: java.lang.Boolean,
tests: Array[String], tests: java.util.List[String],
launcherJar: File, launcherJar: File,
javaCommand: String, javaCommand: String,
launchOpts: Array[String], launchOpts: java.util.List[String],
prescripted: java.util.List[File], prescripted: java.util.List[File],
instances: Integer, instances: Integer,
keepTempDirectory: java.lang.Boolean, keepTempDirectory: java.lang.Boolean,

View File

@ -6,6 +6,7 @@ import sbt.*
import sbt.internal.inc.ScalaInstance import sbt.internal.inc.ScalaInstance
import sbt.internal.inc.classpath.{ ClasspathUtilities, FilteredLoader } import sbt.internal.inc.classpath.{ ClasspathUtilities, FilteredLoader }
import scala.annotation.nowarn import scala.annotation.nowarn
import scala.collection.JavaConverters.*
object LocalScriptedPlugin extends AutoPlugin { object LocalScriptedPlugin extends AutoPlugin {
override def requires = plugins.JvmPlugin override def requires = plugins.JvmPlugin
@ -139,10 +140,10 @@ object Scripted {
def runInParallel( def runInParallel(
resourceBaseDirectory: File, resourceBaseDirectory: File,
bufferLog: Boolean, bufferLog: Boolean,
tests: Array[String], tests: java.util.List[String],
launcherJar: File, launcherJar: File,
javaCommand: String, javaCommand: String,
launchOpts: Array[String], launchOpts: java.util.List[String],
prescripted: java.util.List[File], prescripted: java.util.List[File],
instance: Int, instance: Int,
keepTempDirectory: Boolean, keepTempDirectory: Boolean,
@ -175,10 +176,10 @@ object Scripted {
bridge.runInParallel( bridge.runInParallel(
sourcePath, sourcePath,
bufferLog, bufferLog,
args.toArray, args.toList.asJava,
launcherJar, launcherJar,
"java", "java",
launchOpts.toArray, launchOpts.toList.asJava,
callback, callback,
instances, instances,
keepTempDirectory, keepTempDirectory,

View File

@ -505,10 +505,10 @@ class ScriptedRunner {
def run( def run(
resourceBaseDirectory: File, resourceBaseDirectory: File,
bufferLog: Boolean, bufferLog: Boolean,
tests: Array[String], tests: java.util.List[String],
launcherJar: File, launcherJar: File,
javaCommand: String, javaCommand: String,
launchOpts: Array[String], launchOpts: java.util.List[String],
prescripted: java.util.List[File], prescripted: java.util.List[File],
keepTempDirectory: Boolean, keepTempDirectory: Boolean,
includeFilter: java.io.FileFilter, includeFilter: java.io.FileFilter,
@ -518,10 +518,10 @@ class ScriptedRunner {
run( run(
resourceBaseDirectory, resourceBaseDirectory,
bufferLog, bufferLog,
tests, tests.toArray(Array.empty[String]),
logger, logger,
javaCommand, javaCommand,
launchOpts, launchOpts.toArray(Array.empty[String]),
prescripted, prescripted,
LauncherBased(launcherJar), LauncherBased(launcherJar),
Int.MaxValue, Int.MaxValue,
@ -558,6 +558,7 @@ class ScriptedRunner {
prescripted, prescripted,
LauncherBased(launcherJar), LauncherBased(launcherJar),
instance, instance,
keepTempDirectory = false,
) )
} }
@ -587,6 +588,7 @@ class ScriptedRunner {
prescripted, prescripted,
LauncherBased(launcherJar), LauncherBased(launcherJar),
instance, instance,
keepTempDirectory = false,
) )
} }
@ -620,10 +622,10 @@ class ScriptedRunner {
def runInParallel( def runInParallel(
resourceBaseDirectory: File, resourceBaseDirectory: File,
bufferLog: Boolean, bufferLog: Boolean,
tests: Array[String], tests: java.util.List[String],
launcherJar: File, launcherJar: File,
javaCommand: String, javaCommand: String,
launchOpts: Array[String], launchOpts: java.util.List[String],
prescripted: java.util.List[File], prescripted: java.util.List[File],
instance: Int, instance: Int,
keepTempDirectory: Boolean, keepTempDirectory: Boolean,
@ -670,34 +672,8 @@ class ScriptedRunner {
launchOpts, launchOpts,
prescripted, prescripted,
RunFromSourceBased(scalaVersion, sbtVersion, classpath.toSeq), RunFromSourceBased(scalaVersion, sbtVersion, classpath.toSeq),
instances
)
private[sbt] def runInParallel(
baseDir: File,
bufferLog: Boolean,
tests: Array[String],
logger: Logger,
javaCommand: String,
launchOpts: Array[String],
prescripted: java.util.List[File],
prop: RemoteSbtCreatorProp,
instances: Int,
keepTempDirectory: Boolean = false,
): Unit =
runInParallel(
baseDir,
bufferLog,
tests,
logger,
javaCommand,
launchOpts,
prescripted,
prop,
instances, instances,
keepTempDirectory, keepTempDirectory = false,
AllPassFilter,
NothingFilter,
) )
private[sbt] def runInParallel( private[sbt] def runInParallel(
@ -711,8 +687,6 @@ class ScriptedRunner {
prop: RemoteSbtCreatorProp, prop: RemoteSbtCreatorProp,
instances: Int, instances: Int,
keepTempDirectory: Boolean, keepTempDirectory: Boolean,
includeFilter: java.io.FileFilter,
excludeFilter: java.io.FileFilter,
): Unit = ): Unit =
run( run(
baseDir, baseDir,
@ -726,6 +700,36 @@ class ScriptedRunner {
instances, instances,
parallelExecution = true, parallelExecution = true,
keepTempDirectory, keepTempDirectory,
includeFilter = AllPassFilter,
excludeFilter = NothingFilter,
)
private[sbt] def runInParallel(
baseDir: File,
bufferLog: Boolean,
tests: java.util.List[String],
logger: Logger,
javaCommand: String,
launchOpts: java.util.List[String],
prescripted: java.util.List[File],
prop: RemoteSbtCreatorProp,
instances: Int,
keepTempDirectory: Boolean,
includeFilter: java.io.FileFilter,
excludeFilter: java.io.FileFilter,
): Unit =
run(
baseDir,
bufferLog,
tests.toArray(Array.empty[String]),
logger,
javaCommand,
launchOpts.toArray(Array.empty[String]),
prescripted,
prop,
instances,
parallelExecution = true,
keepTempDirectory,
includeFilter, includeFilter,
excludeFilter, excludeFilter,
) )