diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-02-05 12:46:26 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-02-05 12:46:26 +1000 |
commit | b51fe3d4d01405a0bcfc586af337736cfe4e0478 (patch) | |
tree | 97dfdd4fa832c44574806cc2e85a8994e7a0eeeb /build.sbt | |
parent | 42525ec8d072cdd79d3916c09baa063b34a71f25 (diff) | |
download | scala-b51fe3d4d01405a0bcfc586af337736cfe4e0478.tar.gz scala-b51fe3d4d01405a0bcfc586af337736cfe4e0478.tar.bz2 scala-b51fe3d4d01405a0bcfc586af337736cfe4e0478.zip |
Convenient aliases for the SBT build
The idea here is to avoid the need for switching
between the SBT shell and Bash.
- Add aliases for partest, scala{,c,p,doc}
- Change working directory for these forked processes
to the root project base directory, rather than the
subprojects base directory. This lets us use relative
paths to files in a more familar way.
- Don't log the output of forked processes with the
`[info] ` prefix, rather pass it through directly
to stdout.
Demo:
```
> partest --terse test/files/pos/t6231.scala
[info] Packaging /Users/jason/code/scala2/build-sbt/pack/lib/scala-partest-javaagent.jar ...
[info] Done packaging.
Selected 1 tests drawn from specified tests
.
[info] Passed: Total 1, Failed 0, Errors 0, Passed 1
[success] Total time: 3 s, completed 05/02/2016 12:44:19 PM
> scala sandbox/test.scala
[info] Running scala.tools.nsc.MainGenericRunner -usejavacp sandbox/test.scala
Hello, World!
[success] Total time: 4 s, completed 05/02/2016 12:45:08 PM
> scalac sandbox/test.scala
[info] Running scala.tools.nsc.Main -usejavacp sandbox/test.scala
[success] Total time: 3 s, completed 05/02/2016 12:45:15 PM
> scala Test
[info] Running scala.tools.nsc.MainGenericRunner -usejavacp Test
Hello, World!
[success] Total time: 1 s, completed 05/02/2016 12:45:20 PM
> scala
[info] Running scala.tools.nsc.MainGenericRunner -usejavacp
Welcome to Scala 2.11.8-20160204-090931-42525ec (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_71).
Type in expressions for evaluation. Or try :help.
scala> 1.to
to toBinaryString toByte toChar toDegrees toDouble toFloat toHexString toInt toLong toOctalString toRadians toShort toString
scala> 1.toString
res0: String = 1
scala> :quit
[success] Total time: 8 s, completed 05/02/2016 12:45:48 PM
>
```
Diffstat (limited to 'build.sbt')
-rw-r--r-- | build.sbt | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -200,7 +200,18 @@ lazy val commonSettings = clearSourceAndResourceDirectories ++ publishSettings + }, // Remove auto-generated manifest attributes packageOptions in Compile in packageBin := Seq.empty, - packageOptions in Compile in packageSrc := Seq.empty + packageOptions in Compile in packageSrc := Seq.empty, + + // Lets us CTRL-C partest without exiting SBT entirely + cancelable in Global := true, + // When we fork subprocesses, use the base directory as the working directory. + // This enables `sbt> partest test/files/run/t1.scala` or `sbt> scalac sandbox/test.scala` + baseDirectory in Compile := (baseDirectory in ThisBuild).value, + baseDirectory in Test := (baseDirectory in ThisBuild).value, + + // Don't log process output (e.g. of forked `compiler/runMain ...Main`), just pass it + // directly to stdout + outputStrategy in run := Some(StdoutOutput) ) /** Extra post-processing for the published POM files. These are needed to create POMs that @@ -418,7 +429,6 @@ lazy val repl = configureAsSubproject(project) .settings( connectInput in run := true, publishArtifact := false, - outputStrategy in run := Some(StdoutOutput), run <<= (run in Compile).partialInput(" -usejavacp") // Automatically add this so that `repl/run` works without additional arguments. ) .dependsOn(compiler, interactive) @@ -465,7 +475,8 @@ lazy val replJlineEmbedded = Project("repl-jline-embedded", file(".") / "target" val outdir = (classDirectory in Compile).value JarJar(inputs, outdir, config) }), - publishArtifact := false + publishArtifact := false, + connectInput in run := true ) .dependsOn(replJline) @@ -819,3 +830,10 @@ def generateServiceProviderResources(services: (String, String)*): Setting[_] = }.taskValue buildDirectory in ThisBuild := (baseDirectory in ThisBuild).value / "build-sbt" + +// TODO custom argument parsers for these to autocomplete compiler options and paths +addCommandAlias("scalac", "compiler/compile:runMain scala.tools.nsc.Main -usejavacp") +addCommandAlias("scala", "repl-jline-embedded/compile:runMain scala.tools.nsc.MainGenericRunner -usejavacp") +addCommandAlias("scaladoc", "scaladoc/compile:runMain scala.tools.nsc.ScalaDoc -usejavacp") +addCommandAlias("scalap", "scalap/compile:runMain scala.tools.scalap.Main -usejavacp") +addCommandAlias("partest", "test/it:testOnly --") |