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