Skip to content

Commit 39c59a0

Browse files
committed
Fix sbt dotr with -classpath
1 parent ca8943a commit 39c59a0

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

project/Build.scala

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ object Build {
501501

502502
// Override run to be able to run compiled classfiles
503503
dotr := {
504-
val args: Seq[String] = spaceDelimited("<arg>").parsed
504+
val args: List[String] = spaceDelimited("<arg>").parsed.toList
505505
val java: String = Process("which" :: "java" :: Nil).!!
506506
val attList = (dependencyClasspath in Runtime).value
507507
val _ = packageAll.value
@@ -518,7 +518,8 @@ object Build {
518518
println("Couldn't find scala-library on classpath, please run using script in bin dir instead")
519519
} else {
520520
val dottyLib = packageAll.value("dotty-library")
521-
s"$java -classpath .:$dottyLib:$scalaLib ${args.mkString(" ")}".!
521+
val fullArgs = insertClasspathInArgs(args, s".:$dottyLib:$scalaLib")
522+
s"$java ${fullArgs.mkString(" ")}".!
522523
}
523524
},
524525
run := dotc.evaluated,
@@ -634,15 +635,17 @@ object Build {
634635
if (tasty && !args.contains("-Yretain-trees")) List("-Yretain-trees")
635636
else Nil
636637

637-
val fullArgs = main :: extraArgs ::: {
638-
val (beforeCp, fromCp) = args.span(_ != "-classpath")
639-
val classpath = fromCp.drop(1).headOption.fold(dottyLib)(_ + ":" + dottyLib)
640-
beforeCp ::: "-classpath" :: classpath :: fromCp.drop(2)
641-
}
638+
val fullArgs = main :: extraArgs ::: insertClasspathInArgs(args, dottyLib)
642639

643640
(runMain in Compile).toTask(fullArgs.mkString(" ", " ", ""))
644641
}
645642

643+
def insertClasspathInArgs(args: List[String], cp: String): List[String] = {
644+
val (beforeCp, fromCp) = args.span(_ != "-classpath")
645+
val classpath = fromCp.drop(1).headOption.fold(cp)(_ + ":" + cp)
646+
beforeCp ::: "-classpath" :: classpath :: fromCp.drop(2)
647+
}
648+
646649
lazy val nonBootstrapedDottyCompilerSettings = commonDottyCompilerSettings ++ Seq(
647650
// Disable scaladoc generation, it's way too slow and we'll replace it
648651
// by dottydoc anyway. We still publish an empty -javadoc.jar to make

0 commit comments

Comments
 (0)