Commit Graph

8890 Commits

Author SHA1 Message Date
Ethan Atkins ad59e71b1a Add util headers
None of the util files had headers.
2019-12-08 10:29:22 -08:00
Ethan Atkins 45a2cd5985 Add util tests to the jdk8 build
The existing .travis.yml in the util project runs:
mimaReportBinaryIssues
scalafmtCheckAll
whitesourceCheckPolicies
test

The first three are already handled by the first build in the matrix. I
add the util tests to the first jdk11 build and the jdk8 build.
2019-12-08 10:28:31 -08:00
Ethan Atkins 8bfae66b9d Update build.sbt to handle util projects
As part of re-integrating util into the sbt main project, I had to
update the build.sbt and a few dependencies (like the contraband plugin).
2019-12-08 10:28:31 -08:00
Ethan Atkins 6a32bd0c72 Optimize build.sbt imports 2019-12-08 10:28:14 -08:00
Ethan Atkins 4d1bd18296 Merge remote-tracking branch 'util-integration/develop' into util-integration 2019-12-07 17:49:46 -08:00
Ethan Atkins 8518c4b4fd Place scalatest framework jar in its own classloader
Closing the ManagedClassLoader generated by test can cause nonlocal
effects because the jdk shares some JarFile resources across multiple
URLClassLoaders. As a result, if one classloader is trying to load a
resource and the classloader is closed, it might cause the resource
loading to fail (see https://github.com/sbt/sbt/issues/5262). This can
be fixed by moving the scalatest framework jar (and its dependencies)
into an additional classloader layer that sits between the scala library
loader and the rest of the test dependencies.

In addition to adding the new layer, I reworked the
ReverseLookupClassLoader to use its dependent classloader to find
resources that may below it in the classloading hierarchy rather than
constructing an entirely new classloader for resources.

After this change, I was able to run test in the repro project:
https://github.com/rjmac/sbt-5262 1000 times with no failures. Note that
the repro is sensitive to the jdk used. I could not reproduce with jdk11
but I could typically induce a failure within 20 or so runs with jdk8.

I benchmarked this change with
https://github.com/eatkins/scala-build-watch-performance and performance
was roughly the same as 1.3.4 with turbo mode and about 200-250ms faster
in non-turbo mode (which can be explained by the time to load the
scalatest classes).
2019-12-06 11:41:44 -08:00
eugene yokota 4adb56ae9d
Merge pull request #5271 from smarter/mkIvyConfiguration-precise-type
Give a more precise type to mkIvyConfiguration
2019-12-05 14:32:46 -05:00
Guillaume Martres 437950266f Give a more precise type to mkIvyConfiguration
This makes it possible to do mkIvyConfiguration.value.withXXX(...) for
all the methods in InlineIvyConfiguration. (I need this to remove
inter-project resolvers when fetching dotty from sbt-dotty to avoid
accidentally fetching a local project in the build of dotty itself).
2019-12-05 18:14:56 +01:00
eugene yokota 47985e33ae
Merge pull request #5267 from eatkins/zombie-concurrency
Make ZombieClassLoader thread safe
2019-12-04 18:57:50 -05:00
Ethan Atkins 1438b79378 Make ZombieClassLoader thread safe
The previous implementation of ZombieClassLoader was not thread safe.
This caused problems because it is possible for the ManagedClassLoader
in test to leak into the coursier thread pool if the test uses bouncy
castle apis. Unfortunately, these apis seem to in some cases assign
static variables using the Thread context class loader. Because the
bouncycastle apis are implemented by the jdk, they are found in the
system classloader and thus the static references leak out of the test
context.

I had a local repro of https://github.com/sbt/sbt/issues/5249 that is
fixed by this change.
2019-12-03 18:53:40 -08:00
eugene yokota e5e462f2c2
Merge pull request #5265 from eatkins/cross-input-tasks
Fix cross command (+) for input tasks in subprojects with provided input
2019-12-03 21:42:18 -05:00
Ethan Atkins 53788ba356 Support input tasks in cross (+) command 2019-12-03 10:47:15 -08:00
Ethan Atkins 0cbbee4418 Don't import fields from local variables
I found it hard to reason about where certain local variables, like
currentRef, were coming from. I also changed 'x' to 'extracted' in a few
places for clarity as well.
2019-12-03 10:45:52 -08:00
eugene yokota 3fc9513ec5
Merge pull request #5259 from eatkins/background-jobs
Background jobs
2019-12-02 15:55:15 -05:00
Ethan Atkins abb3f61ff1
Merge branch 'develop' into background-jobs 2019-12-02 08:58:24 -08:00
Ethan Atkins 21f09e6025
Merge pull request #5260 from eatkins/state-transform
Improve StateTransform
2019-12-02 08:51:18 -08:00
Ethan Atkins 1a7d6a84f5
Merge branch 'develop' into state-transform 2019-12-02 08:03:46 -08:00
eugene yokota 56af617908
Merge pull request #5258 from eatkins/lint
Make minor improvements to project setting linting
2019-11-30 23:29:26 -05:00
eugene yokota bb938e761d
Merge pull request #5256 from eatkins/scalafmt
Bump scalafmt and run on metabuild
2019-11-30 23:27:52 -05:00
eugene yokota 9a3b7cfc3f
Merge pull request #5257 from eatkins/bump-sbt
Bump sbt version
2019-11-30 23:26:37 -05:00
Ethan Atkins 9e02d31fcf
Merge pull request #5255 from eatkins/scripted-exceptions
Don't print stack trace for pending tests
2019-11-30 18:10:45 -08:00
Ethan Atkins 8d67593cf5
Merge branch 'develop' into scripted-exceptions 2019-11-30 15:51:53 -08:00
Ethan Atkins 73a196798f Move background job service directory location
Rather than putting the background job temporary files in whatever
java.io.tmpdir points to, this commit moves the files into a
subdirectory of target in the project root directory.

To make the directory configurable via settings, I had to move the
declaration of the bgJobService setting later in the project
initialization process. I don't think this should matter because
background jobs shouldn't be created until after the project has loaded
all of its settings..
2019-11-30 15:20:00 -08:00
Ethan Atkins 73edc8d4ff Use anonymous function instead of Runnable 2019-11-30 15:20:00 -08:00
Ethan Atkins 7426ae520c Fix background job shutdown
When a user calls sbt exit and there is an active background job, sbt
may not exit cleanly. This was primarily because the
background job service shutdown method depended on the
StandardMain.executionContext which was closed before the background job
service was shutdown. This was fixable by reordering the resource
closing in StandardMain.runManaged.
2019-11-30 15:20:00 -08:00
Ethan Atkins 8d26bc73b4 Shutdown background job on error
When running a main method, if the user inputs ctrl+c then the `run`
task will exit but the main method is not interrupted so it continues
running even once sbt has returned to the shell. If the main method is a
webserver, this prevents run from ever starting again on a fixed port.
To fix this, we can modify the waitForTry method to stop the job if an
exception is thrown (ctrl+c leads to an interrupted exception being
thrown by waitFor).

I rework the BackgroundJobService so that the default implementation of
waitForTry is now usable and no longer needs to be overridden. The side
effect of this change is that waitFor may now throw an exception. Within
sbt, waitFor was only used in one place and I reworked it to use
waitForTry instead. This could theoretically break a downstream user who
relied on waitFor not throwing an exception but I suspect that there
aren't many users of this api, if any at all.
2019-11-30 15:20:00 -08:00
Ethan Atkins a83c280db1 Improve StateTransform
The StateTransform class introduced in
9cdeb7120e did not cleanly integrate with
logic for transforming the state using the `transformState` task
attribute. For one thing, the state transform was only applied if the
root node returned StateTransform but no transformation would occur if a
task had a dependency that returned StateTransform. Moreover, the
transformation would override all other transformations that may have
occurred during task evaluation.

This commit updates StateTransform to act very similarly to the
transformState attribute. Instead of wrapping a `State` instance, it now
wraps a transformation function from `State => State`. This function
can be applied on top of or prior to the other transformations via the
`transformState`.

For binary compatibility with 1.3.0, I had to add the stateProxy
function as a constructor parameter in order to implement the `state`
method. The proxy function will generally throw an exception unless the
legacy api is used. To avoid that, I private[sbt]'d the legacy api so
that binary compatibility is preserved but any builds targeting > 1.4.x
will be required to use the new api.

Unfortunately I couldn't private[sbt] StateTransform.apply(state: State)
because mima interpreted it as a method type change becuase I added
StateTransform.apply(transform: State => State). This may be a mima bug
given that StateTransform.apply(state: State) would be jvm public even
when private[sbt], but I figured it was quite unlikely that any users
were using this method anyway since it was incorrectly implemented in
1.3.0 to return `state` instead of `new StateTransform(state)`.
2019-11-30 15:06:34 -08:00
Ethan Atkins 3bb847fc72 Allow lintUnusedKeys to be disabled
The linting can take a while for large projects because `Def.compiled`
scales in the number of settings. Even for small projects (i.e. scripted
tests), it takes about 50 ms on my computer. This doesn't change the
current behavior because the default value is true.
2019-11-30 15:00:38 -08:00
Ethan Atkins 805fa002a7 Only print unused setting warning if there are any 2019-11-30 15:00:38 -08:00
Ethan Atkins d7a191e277 Bump sbt version 2019-11-30 14:59:44 -08:00
Ethan Atkins bb73730c00 Run scalafmtSbt
Also add scalafmtSbtCheck to travis.
2019-11-30 14:57:57 -08:00
Ethan Atkins 094d730b06 Bump scalafmt 2019-11-30 14:57:20 -08:00
eugene yokota 181bfe8a46
Merge pull request #5254 from dwijnand/cleanup/Transform
Cleanup project/Transform.scala
2019-11-30 17:47:39 -05:00
Ethan Atkins a708cac2a3 Don't print stack trace for pending tests
This can be very noisy, especially for tests that are marked pending
because they fail to load the build. These induce a lengthy and largely
unhelpful "Reload for batch scripted failed..." error message.
2019-11-30 13:53:47 -08:00
eugene yokota 5377fb98df
Merge pull request #5251 from steinybot/fix/5250-console-project-scala-2-13
Fix consoleProject for scala 2.13
2019-11-29 23:02:12 -05:00
Dale Wijnand 02e26465f7 Cleanup project/Transform.scala 2019-11-28 21:25:49 +00:00
Jason Pickens 71bc3876d9
Scope compiler bridge to consoleProject 2019-11-28 20:29:31 +13:00
Jason Pickens 8c3245d569
Add test to reproduce consoleProject bug 2019-11-28 20:14:49 +13:00
eugene yokota 964f7867b3
Merge pull request #5242 from xuwei-k/update-license-url
Update license url
2019-11-23 12:03:10 -05:00
xuwei-k fc94204e8c Update license url 2019-11-23 16:09:13 +09:00
eugene yokota 4c1f7a7548
Merge pull request #5240 from eed3si9n/wip/bumpcoursier
lm-coursier-shaded 2.0.0-RC5-2
2019-11-22 15:45:59 -05:00
Eugene Yokota 8f82014e31 mima 2019-11-22 14:37:07 -05:00
Eugene Yokota 0e3f94ea53 lm-coursier-shaded 2.0.0-RC5-2
Fixes #5132
Fixes #4706
Fixes #4688
2019-11-22 14:00:48 -05:00
eugene yokota b18140c14b
Merge pull request #5182 from eed3si9n/wip/nolub
apply -Yno-lub
2019-11-22 11:01:54 -05:00
eugene yokota c45e991c6b
Merge pull request #5229 from eed3si9n/wip/addPluginSbtFile
addPluginSbtFile command fixes
2019-11-21 17:02:02 -05:00
eugene yokota 9b9e168fb4
Merge pull request #5235 from fthomas/fix/5234
Include description and homepage in ivy.xml files
2019-11-20 21:44:13 +02:00
Frank S. Thomas 16860b5273 Include description and homepage in ivy.xml files
This PR includes the values of the `description` and `homepage`
settings into the `ivy.xml` files generated by the `makeIvyXml`
task. It restores the behaviour of sbt 1.2.8 and if `useCoursier`
is set to `false`.

Two things are changed in this PR:
 * `IvyXml.content` now adds the `homepage` attribute to the
   `description` element if `project.info.homePage` is not empty.
 * `CoursierInputsTasks.coursierProject0` now fills the previous
   empty `CProject.info` field with the description and homepage.

Closes: #5234
2019-11-16 20:18:42 +01:00
Eugene Yokota 033601c393 addPluginSbtFile command fixes
Ref #4211
Fixes #4395
Fixes #4600

This is a reimplementation of `--addPluginSbtFile`. #4211 implemented the command to load extra `*.sbt` files as part of the global plugin subproject. That had the unwanted side effects of not working when `.sbt/1.0/plugins` directory does not exist. This changes the strategy to load the `*.sbt` files as part of the meta build.

```
$ sbt -Dsbt.global.base=/tmp/hello/global --addPluginSbtFile=/tmp/plugins/plugin.sbt
[info] Loading settings for project hello-build from plugin.sbt ...
[info] Loading project definition from /private/tmp/hello/project
sbt:hello> plugins
In file:/private/tmp/hello/
	sbt.plugins.IvyPlugin: enabled in root
	sbt.plugins.JvmPlugin: enabled in root
	sbt.plugins.CorePlugin: enabled in root
	sbt.ScriptedPlugin
	sbt.plugins.SbtPlugin
	sbt.plugins.SemanticdbPlugin: enabled in root
	sbt.plugins.JUnitXmlReportPlugin: enabled in root
	sbt.plugins.Giter8TemplatePlugin: enabled in root
	sbtvimquit.VimquitPlugin: enabled in root
```
2019-11-10 20:03:09 -05:00
eugene yokota 08c7fd1b8f
Merge pull request #5225 from samvel1024/develop
Sleep the current thread when we need to retry background job shutdown
2019-11-06 10:33:51 -05:00
Samvel Abrahamyan ff75a21d4f Sleep the current thread when we need to retry background job shutdown 2019-11-05 14:54:55 +01:00