Skip to content

Commit cdcbca1

Browse files
committed
Factor sbt dotr/repl common init code
1 parent 09769f6 commit cdcbca1

File tree

1 file changed

+17
-28
lines changed

1 file changed

+17
-28
lines changed

project/Build.scala

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -521,34 +521,9 @@ object Build {
521521
s"""$java -classpath .:$dottyLib:$scalaLib ${args.mkString(" ")}""".!
522522
}
523523
},
524-
run := Def.inputTaskDyn {
525-
val dottyLib = packageAll.value("dotty-library")
526-
val args: Seq[String] = spaceDelimited("<arg>").parsed
527-
528-
val fullArgs = args.span(_ != "-classpath") match {
529-
case (beforeCp, "-classpath" :: cp :: rest) => beforeCp ++ List("-classpath", cp + ":" + dottyLib) ++ rest
530-
case (beforeCp, _) => beforeCp ++ List("-classpath", dottyLib)
531-
}
532-
533-
(runMain in Compile).toTask(
534-
s" dotty.tools.dotc.Main " + fullArgs.mkString(" ")
535-
)
536-
}.evaluated,
537-
dotc := run.evaluated,
538-
539-
repl := Def.inputTaskDyn {
540-
val dottyLib = packageAll.value("dotty-library")
541-
val args: Seq[String] = spaceDelimited("<arg>").parsed
542-
543-
val fullArgs = args.span(_ != "-classpath") match {
544-
case (beforeCp, "-classpath" :: cp :: rest) => beforeCp ++ List("-classpath", cp + ":" + dottyLib) ++ rest
545-
case (beforeCp, _) => beforeCp ++ List("-classpath", dottyLib)
546-
}
547-
548-
(runMain in Compile).toTask(
549-
s" dotty.tools.repl.Main " + fullArgs.mkString(" ")
550-
)
551-
}.evaluated,
524+
run := dotc.evaluated,
525+
dotc := dotDynTask("dotty.tools.dotc.Main").evaluated,
526+
repl := dotDynTask("dotty.tools.repl.Main").evaluated,
552527

553528
// enable verbose exception messages for JUnit
554529
testOptions in Test += Tests.Argument(
@@ -642,6 +617,20 @@ object Build {
642617
}
643618
)
644619

620+
def dotDynTask(main: String) = Def.inputTaskDyn {
621+
val dottyLib = packageAll.value("dotty-library")
622+
val args: Seq[String] = spaceDelimited("<arg>").parsed
623+
624+
val fullArgs = main +: {
625+
args.span(_ != "-classpath") match {
626+
case (beforeCp, "-classpath" :: cp :: rest) => beforeCp ++ List("-classpath", cp + ":" + dottyLib) ++ rest
627+
case (beforeCp, _) => beforeCp ++ List("-classpath", dottyLib)
628+
}
629+
}
630+
631+
(runMain in Compile).toTask(fullArgs.mkString(" ", " ", ""))
632+
}
633+
645634
lazy val nonBootstrapedDottyCompilerSettings = commonDottyCompilerSettings ++ Seq(
646635
// Disable scaladoc generation, it's way too slow and we'll replace it
647636
// by dottydoc anyway. We still publish an empty -javadoc.jar to make

0 commit comments

Comments
 (0)