1
1
import sbt .Keys ._
2
2
import sbt ._
3
+ import complete .DefaultParsers ._
3
4
import java .io .{ RandomAccessFile , File }
4
5
import java .nio .channels .FileLock
5
6
import scala .reflect .io .Path
@@ -25,7 +26,12 @@ object DottyBuild extends Build {
25
26
// "-XX:+HeapDumpOnOutOfMemoryError", "-Xmx1g", "-Xss2m"
26
27
)
27
28
28
- lazy val packageAll = taskKey[Unit ](" Package everything needed to run tests" )
29
+ // Packages all subprojects to their jars
30
+ lazy val packageAll =
31
+ taskKey[Map [String , String ]](" Package everything needed to run tests" )
32
+
33
+ // Spawns a repl with the correct classpath
34
+ lazy val repl = inputKey[Unit ](" run the REPL with correct classpath" )
29
35
30
36
override def settings : Seq [Setting [_]] = {
31
37
super .settings ++ Seq (
@@ -67,6 +73,7 @@ object DottyBuild extends Build {
67
73
dependsOn(`dotty-library`).
68
74
dependsOn(`dotty-interfaces`).
69
75
settings(
76
+ addCommandAlias(" repl" , " dotty-compiler/repl" ) ++
70
77
addCommandAlias(
71
78
" partest" ,
72
79
" ;packageAll" +
@@ -150,14 +157,24 @@ object DottyBuild extends Build {
150
157
// enable improved incremental compilation algorithm
151
158
incOptions := incOptions.value.withNameHashing(true ),
152
159
153
-
160
+ // packageAll packages all and then returns a map with the abs location
154
161
packageAll := {
155
- val p1 = (packageBin in (`dotty-interfaces`, Compile )).value
156
- val p2 = (packageBin in Compile ).value
157
- val p3 = (packageBin in (`dotty-library`, Compile )).value
158
- val p4 = (packageBin in Test ).value
162
+ Map (
163
+ " dotty-interfaces" -> (packageBin in (`dotty-interfaces`, Compile )).value,
164
+ " dotty-compiler" -> (packageBin in Compile ).value,
165
+ " dotty-library" -> (packageBin in (`dotty-library`, Compile )).value,
166
+ " dotty-compiler-test" -> (packageBin in Test ).value
167
+ ) map { case (k, v) => (k, v.getAbsolutePath) }
159
168
},
160
169
170
+ repl := Def .inputTaskDyn {
171
+ val args : Seq [String ] = spaceDelimited(" <arg>" ).parsed
172
+ val dottyLib = packageAll.value(" dotty-library" )
173
+ (runMain in Compile ).toTask(
174
+ s " dotty.tools.dotc.repl.Main -classpath $dottyLib " + args.mkString(" " )
175
+ )
176
+ }.evaluated,
177
+
161
178
// enable verbose exception messages for JUnit
162
179
testOptions in Test += Tests .Argument (
163
180
TestFrameworks .JUnit , " -a" , " -v" ,
0 commit comments