@@ -33,6 +33,10 @@ object DottyBuild extends Build {
33
33
// Spawns a repl with the correct classpath
34
34
lazy val repl = inputKey[Unit ](" run the REPL with correct classpath" )
35
35
36
+ // Used to compile files similar to ./bin/dotc script
37
+ lazy val dotc =
38
+ inputKey[Unit ](" run the compiler using the correct classpath, or the user supplied classpath" )
39
+
36
40
override def settings : Seq [Setting [_]] = {
37
41
super .settings ++ Seq (
38
42
scalaVersion in Global := " 2.11.5" ,
@@ -73,6 +77,7 @@ object DottyBuild extends Build {
73
77
dependsOn(`dotty-library`).
74
78
dependsOn(`dotty-interfaces`).
75
79
settings(
80
+ addCommandAlias(" dotc" , " dotty-compiler/dotc" ) ++
76
81
addCommandAlias(" repl" , " dotty-compiler/repl" ) ++
77
82
addCommandAlias(
78
83
" partest" ,
@@ -175,6 +180,22 @@ object DottyBuild extends Build {
175
180
)
176
181
}.evaluated,
177
182
183
+ // Set run baseDir to be root of project, makes dotc saner
184
+ baseDirectory in run := baseDirectory.value / " .." ,
185
+ dotc := Def .inputTaskDyn {
186
+ val dottyLib = packageAll.value(" dotty-library" )
187
+ val args : Seq [String ] = spaceDelimited(" <arg>" ).parsed
188
+
189
+ val fullArgs = args.span(_ != " -classpath" ) match {
190
+ case (beforeCp, Nil ) => beforeCp ++ (" -classpath" :: dottyLib :: Nil )
191
+ case (beforeCp, rest) => beforeCp ++ rest
192
+ }
193
+
194
+ (runMain in Compile ).toTask(
195
+ s " dotty.tools.dotc.Main " + fullArgs.mkString(" " )
196
+ )
197
+ }.evaluated,
198
+
178
199
// enable verbose exception messages for JUnit
179
200
testOptions in Test += Tests .Argument (
180
201
TestFrameworks .JUnit , " -a" , " -v" ,
@@ -242,15 +263,11 @@ object DottyBuild extends Build {
242
263
// } (Set(scalaJSIRSourcesJar)).toSeq
243
264
// }.taskValue,
244
265
245
- // Adjust classpath for running dotty
246
- mainClass in (Compile , run) := Some (" dotty.tools.dotc.Main" ),
266
+ // Spawn new JVM in run and test
247
267
fork in run := true ,
248
268
fork in Test := true ,
249
269
parallelExecution in Test := false ,
250
270
251
- // FIXME: Do something more sensible, like using the Scala bootclasspath
252
- run <<= (run in Compile ).partialInput(" -usejavacp" ),
253
-
254
271
// http://grokbase.com/t/gg/simple-build-tool/135ke5y90p/sbt-setting-jvm-boot-paramaters-for-scala
255
272
// packageAll should always be run before tests
256
273
javaOptions <++= (dependencyClasspath in Runtime , packageAll) map { (attList, _) =>
0 commit comments