This works around the name conflict between sbt.test package and sbt.Keys.test.
1. sbt.test package is renamed to sbt.scriptedtest. This allows 1.0 plugins and builds to use `test` to mean `Keys.test`.
2. To keep binary compatibility for sbt 0.13 scripted, I am adding `sbt.test.ScriptedRunner` and `sbt.test.ScriptedTests` in `scripted-plugin` artifact.
3. Another affected user is Giter8 plugin that uses ScriptedPlugin. Since the intereactions are limited to `sbt.ScriptedPlugin.*`, we should be fine here. - https://github.com/foundweekends/giter8/blob/v0.11.0-M2/plugin/src/main/scala-sbt-1.0/giter8/SBTCompat.scala
Fixes#3538
This brings in `sbt.ScriptedPlugin` as `sbt.plugins.ScriptedPlugin` into sbt mothership.
In addition, `sbt.plugins.SbtPlugin` is added that enables the scripted plugin and `sbtPlugin := true`.
This allows plugin authors to bring in scripted plugin by writing:
```scala
lazy val root = (project in file("."))
.enablePlugins(SbtPlugin)
```
The change to enable batched and parallel execution for scripted was
done only for the scripted-sbt project. This pull request enables it for
scripted-plugin, so that all sbt plugins in 1.x. can benefit from it.
By default, it configures a number of parallel instances of 1 and batch
execution is disabled. Users can change the number of parallel sbt hosts
running scripted tests via the `scriptedParallelInstances` setting.
In some plugins scripted tests', batch execution can cause issues
because the first time `>` commands are executed they assume sbt starts
up. This error can be fixed by doing `reload` before running the `>`
command.
Note that the current scripted plugin does not allow parallel execution
in non-batched mode.
Tested pos/neg compilation of a simple hello world file, running said
file & a simple uTest test suite.
Uses things already downloaded in ~/.ivy2/cache, & shares ~/.sbt/boot
for the compiler-bridge component.
This is what it looks like now! 🎉
> sbtOn /s/t-sbtOn
[...]
[info] Running (fork) sbt.RunFromSourceMain /s/t-sbtOn
Listening for transport dt_socket at address: 5005
[warn] sbt version mismatch, current: 1.0.3, in build.properties: "1.1.0", use 'reboot' to use the new value.
[info] Loading settings from idea.sbt,global-plugins.sbt ...
[info] Loading global plugins from /Users/dnw/.dotfiles/.sbt/1.0/plugins
[info] Updating ProjectRef(uri("file:/Users/dnw/.sbt/1.0/plugins/"), "global-plugins")...
[info] Done updating.
[info] Loading settings from plugins.sbt ...
[info] Loading project definition from /s/t-sbtOn/project
[info] Updating ProjectRef(uri("file:/s/t-sbtOn/project/"), "t-sbton-build")...
[info] Done updating.
[info] Loading settings from build.sbt ...
[info] Set current project to t (in build file:/s/t-sbtOn/)
[info] sbt server started at local:///Users/dnw/.sbt/1.0/server/2c27eaf4c750902a3a41/sock
> show baseDirectory
[info] /s/t-sbtOn
> exit
[info] shutting down server
[success] Total time: 34 s, completed 16-Jan-2018 14:37:32
> Exception in thread "Thread-17" java.io.IOException: Stream closed
at java.lang.ProcessBuilder$NullOutputStream.write(ProcessBuilder.java:433)
at java.io.OutputStream.write(OutputStream.java:116)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at java.io.FilterOutputStream.close(FilterOutputStream.java:158)
at scala.sys.process.BasicIO$.$anonfun$input$1(BasicIO.scala:200)
at scala.sys.process.BasicIO$.$anonfun$input$1$adapted(BasicIO.scala:198)
at scala.sys.process.ProcessBuilderImpl$Simple.$anonfun$run$2(ProcessBuilderImpl.scala:75)
at scala.sys.process.ProcessImpl$Spawn$$anon$1.run(ProcessImpl.scala:23)
> show {.}/baseDirectory
[...]
[info] ThisBuild / baseDirectory
[info] /d/sbt
Apparently an empty comment line, meaning a single '#' on a line,
cannot be fed to scripted, which will complain with an odd error
message.
This commit tweaks the comments in the tests/fork-parallel file
so that there are no empty comment lines.
Fixes#3821
Initially I missed why #3821 was failing.
Looking at it again, the error message reads:
```
Caused by: java.lang.IllegalArgumentException: Interface (NGWin32NamedPipeLibrary) of library=kernel32 does not extend Library
at com.sun.jna.Native.loadLibrary(Native.java:566)
at sbt.internal.NGWin32NamedPipeLibrary.<clinit>(NGWin32NamedPipeLibrary.java:38)
... 7 more
```
Inside `Native.loadLibrary`, it requires the "library" interface to extend `com.sun.jna.Library`, which this adds.
There are just too many instances in which sbt's code relies on
the `lastModified`/`setLastModified` semantics, so instead of moving
to `get`/`setModifiedTime`, we use new IO calls that offer the new
timestamp precision, but retain the old semantics.
Previously I was seeing the error upon the first scripted test. I thought it was because Main was somehow not early enough. It might just be because scripted technically runs as part of the build.
Ref sbt/io#110