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