Commit Graph

7533 Commits

Author SHA1 Message Date
Ethan Atkins 22982a7cfd Make all test and run classloaders parallel capable
A number of users were reporting issues with deadlocking when using
1.3.2: https://github.com/sbt/sbt/issues/5116. This seems to be because
most of the sbt created classloaders were not actually parallel capable.
In order for a classloader to be registered as a parallel capable, ALL
of the parent classes except for object in the class hierarchy must be
registered as a parallel capable:
https://docs.oracle.com/javase/8/docs/api/java/lang/ClassLoader.html#registerAsParallelCapable--.
If a classloader is not registered as parallel capable, then a global
lock will be used internally for classloading and this can lead to deadlock.

It is impossible to register a scala 2 classloader as parallel capable
so I ported all of the classloaders to java.

This commit updates the java-serialization scripted test. Prior to the
port, the new version of the test would more or less always deadlock.
After this change, I haven't been able to reproduce a deadlock.

This had no significant performance impact when I reran
https://github.com/eatkins/scala-build-watch-performance
2019-10-03 11:19:39 -07:00
eugene yokota f6991357f1
Merge pull request #5130 from eatkins/1.3.x-scalarun-classloader-close-backport
[1.3.x] Close classloader in ScalaRun.run
2019-09-24 21:04:33 -04:00
eugene yokota b6e1178f9b
Merge pull request #5129 from eatkins/1.3.x-progress-improvements-backport
[1.3.x] progress improvements backport
2019-09-24 18:36:59 -04:00
Ethan Atkins c9ca0ac03e Close classloader in ScalaRun.run
It is necessary to close the run classloader in order to reuse the
dependency layer in the next run. If the loader needs to survive past
the main method, as is the case with `run` and `runMain`, then the
runWithLoader api should be used instead.

This mostly restores the behavior of classloader closing to 1.3.0 for
the tasks that use ScalaRun except for `run` and `runMain`. But unlike
1.3.0, if the classloader is closed it can still spawn a zombie
classloader.

Fixes #5124.
2019-09-24 15:31:45 -07:00
Ethan Atkins 05372760c2 Filter out dummy tasks from progress
I don't think that dummy tasks really make sense for task progress
because they are evaluated outside of the normal task evaluation. This
came up because I was seeing streams-manager in supershell which didn't
seem useful.
2019-09-24 13:35:15 -07:00
Ethan Atkins 09c63e0804 Limit TaskProgress threads
I noticed some flickering in super shell progress lines and realized
that it was because there were multiple progress threads running
concurrently. This is problematic because each thread has a completely
different state so if each thread has an active task, the display will
flicker between the two tasks. I think this is caused primarily by
dynamic tasks. At least the example where I was seeing it was caused by
a dynamic task.
2019-09-24 13:35:08 -07:00
eugene yokota 3ba6fecc15
Merge pull request #5111 from eatkins/1.3.x-meta-build-backport
[1.3.x] meta build backport
2019-09-21 17:36:25 -04:00
Ethan Atkins bff3b354f6 Fix checkbuild sources for projects with meta-meta-build
If a project had a meta-meta build (project/project), the build sources
in the project directory were ignored. This was because the projectGlobs
method did not correctly handle recursion. It inadvertently
discarded the accumulator globs and only returned the most recently
generated globs. This commit fixes that and adds a regression test to
the nio/reload scripted test.
2019-09-21 12:26:57 -07:00
eugene yokota 3ca185fe30
Merge pull request #5106 from eed3si9n/wip/1.3.1
[1.3.x] clear banner + bump IO
2019-09-19 21:19:48 -04:00
Eugene Yokota 634a11ab4d io 1.3.1 2019-09-19 18:10:47 -04:00
Eugene Yokota 13a047dafe clear banner 2019-09-19 18:09:57 -04:00
eugene yokota 613e5b61cf
Merge pull request #5101 from eed3si9n/bport/meta_resolvers
[1.3.x] add includePluginResolvers
2019-09-19 14:25:42 -04:00
eugene yokota 581dad2505
Merge pull request #5103 from eed3si9n/bport/appveyor
[1.3.x] Drop Visual Studio 2015 testing
2019-09-19 13:43:45 -04:00
Eugene Yokota be9ff19a91 Drop Visual Studio 2015 testing 2019-09-19 13:41:36 -04:00
eugene yokota 52f0646c4f
Merge pull request #5100 from eatkins/1.3.x-stream-locks-backport
[1.3.x] stream locks backport
2019-09-19 13:37:56 -04:00
Eugene Yokota e40b53272f add includePluginResolvers
Fixes #5070

This adds a new setting called `includePluginResolvers` (default `false`).
When set to `true`, it the project will include resolvers from the metabuild.

This allows the build user to declare a resolver in one place (`project/plugins.sbt`) that gets applied to both the metabuild as well as all the subprojects. The scenario comes up when someone distributes a software on their own repo. Ref #4103
2019-09-19 13:13:43 -04:00
eugene yokota 43e8eced71
Merge pull request #5099 from eatkins/1.3.x-zombie-classloaders-backport
[1.3.x] zombie classloaders backport
2019-09-19 13:10:10 -04:00
Ethan Atkins 84f9148bce Add per file stream locks
We have seen failures in scripted to create the output file for streams
and it has also been reported in https://github.com/sbt/sbt/issues/5067.
I believe this may caused by the same stream output being initialized by
multiple tasks. To fix this, I add locking on a per-file basis. There
was (and is) additional synchronization on the Streams _instance_, but
the per-file locks are stored in the Streams companion object so the
locking should be honored no matter which Streams instance calls make.

I also skip the call to IO.touch if the file already exists. I believe
that this is the common case and since IO.touch was being called with
setModified = false, it should be fine to skip the touch when the file
exists.

Prior to this change, I was able to induce the issue in #5067 in roughly
1/50 of calls to `scripted actions/cross-multiproject`. I wasn't able to
reproduce after this change.
2019-09-19 08:43:03 -07:00
Ethan Atkins fb0888dada Make allowZombieClassLoaders public
For forward binary compatibility in the 1.3.x series, this key needed to
be private[sbt], but we can make it public in 1.4.x.
2019-09-19 08:38:59 -07:00
Ethan Atkins 8674e18981 Add the ability to resurrect closed classloaders
There have been a number of complaints about the new classloader closing
behavior. It is too aggressive about closing classloaders after test and
run. This commit softens the behavior by allowing a classloader to be
resurrected after close by creating a new zombie classloader that has
the same urls as the original classloader. After this commit, we always
close the classloaders when we are done, but they can still leak
file descriptors if a zombie is created.

To configure the behavior, I add the allowZombieClassLoaders key. If it
is false (which is default), we will warn but still allow them. If it
is true, then we silence the warning. In a later version of sbt, we can
change the semantics to be strict.

I verified after this change that I could add a shutdown hook in `run`
and it would be evaluated so long as I set `bgCopyClasspath := false`.
Otherwise the needed jars were deleted before the hooks could run.

Bonus: delete unused ResourceLoaderImpl class
2019-09-19 08:38:50 -07:00
Ethan Atkins bc373d5f26 Add 1.3.0 to mima 2019-09-19 08:38:46 -07:00
eugene yokota 2d4cc650f5
Merge pull request #5090 from eatkins/1.3.x-build-sources-backport
[1.3.x] build sources backport
2019-09-17 14:08:13 -04:00
Ethan Atkins 4df049ed0c Monitor meta build sources
We want to recursively monitor the project meta build, but we also want
to avoid listing directories that don't exist. To compromise, I rework
the buildSourceFileInputs to add the nested project directories if they
exist. Because the fileInputs are a setting, this means that adding a
new project directory and *.sbt or *.scala will not immediately trigger
a rebuild, but in most common cases, it will. I added a scripted test
for this.
2019-09-17 09:38:58 -07:00
Ethan Atkins 6aa6fcede3 Monitor project build sources
In sbt 1.3.0, we only monitor build sources in the root project
directory and the root project meta build directory. This commit adds
these inputs for each project.

Fixes https://github.com/sbt/sbt/issues/5061.
2019-09-17 09:38:54 -07:00
Ethan Atkins 204351990c
Merge pull request #5087 from eatkins/1.3.x-supershell-blacklist
[1.3.x] Add consoleQuick and state to skipReportTasks
2019-09-16 18:40:06 -07:00
Ethan Atkins 577070c79f Improve formatting in Continuous 2019-09-15 11:44:11 -07:00
Ethan Atkins 041904f9b6 Skip state in task progress
In the `watch` input task, which is an alternative to `~`, with super
shell, there would be a solitary progress line for `state` in between
builds.
2019-09-15 11:44:11 -07:00
Ethan Atkins f8c40ea5b3 Add consoleQuick to skipReportTasks
This was an oversight that caused consoleQuick to not work with
supershell. We should probably try to figure out a way to allow custom
tasks to black list themselves from super shell reporting.
2019-09-15 11:42:03 -07:00
Ethan Atkins 8a161069dd
Merge pull request #5082 from eatkins/classloader-backport
[1.3.x] Classloader backport
2019-09-14 20:33:13 -07:00
Ethan Atkins 7c03c7f530 Manage classloader in BackgroundJobService
In https://github.com/sbt/sbt/issues/5075 we realized that sbt 1.3.0
introduces a regression where it closes the classloader used to invoke
the main method for in process run before all of its non-daemon threads
have terminated. To fix this and still close the classloader, I add a
method, runInBackgroundWithLoader that provides the background job
services with an optional classloader that it can close after the job
completes.

This cleanly merges and works with 1.3.x as well.
2019-09-14 18:53:03 -07:00
Ethan Atkins 8605fd5b9b Add scripted test for closing classloaders
https://github.com/sbt/sbt/issues/5075 reports that sbt 1.3.0 has a
regression for in process run. In sbt 1.3.0, we close the classloader
that invokes the main method before all of the daemon threads complete.
This adds a scripted test that fails due to this regression.
2019-09-14 18:53:03 -07:00
eugene yokota 28590b76ad
Merge pull request #5077 from eed3si9n/bport/2.12.10
[1.3.x] lm-coursier-shaded 2.0.0-RC3-4 + Scala 2.12.10
2019-09-13 11:44:37 -04:00
xuwei-k 58b0484d80 avoid deprecated /: and :\
use foldLeft and foldRight

https://github.com/scala/scala/blob/v2.13.0/src/library/scala/collection/IterableOnce.scala#L682-L686
2019-09-12 20:53:41 -04:00
Eugene Yokota 02f23b313b Scala 2.12.10 2019-09-12 19:00:37 -04:00
Eugene Yokota 087469c75f lm-coursier-shaded 2.0.0-RC3-4 2019-09-12 19:00:19 -04:00
eugene yokota 011be19445
Merge pull request #5064 from eed3si9n/bport/bugs
[1.3.x] backport some fixes
2019-09-10 11:00:02 -04:00
Ethan Atkins b88be07459 Update deprecation warnings for api changes
During refactoring, these warnings got out of date. I also added
scaladoc to the watchTriggeredMessage key.

Ref: https://github.com/sbt/sbt/issues/5051.
2019-09-10 09:28:38 -04:00
Dmitrii Naumenko 419486e4a5 remove duplicates from allJars when creating ScalaInstance #5052 (#5053)
Fixes #5052
2019-09-10 09:28:11 -04:00
Yusuke Yamada 358011ada6 Set swoval.tmpdir with absolute path via globalBasePath (#5048)
Fixes https://github.com/sbt/sbt/issues/5047

When setting swoval.tmpdir via globalBase, changed to set globalBase as absolute path.

`com.swoval.runtime.NativeLoader.loadPackaged` uses `java.lang.System.load`.
It requires absolute path, so we should set `swoval.tmpdir` with absolute path.
2019-09-10 09:27:36 -04:00
eugene yokota 7cd29cda7b
Merge pull request #5029 from eed3si9n/wip/1.3.0
sbt 1.3.0
2019-09-04 13:28:48 -04:00
Eugene Yokota 665eb8f870 sbt 1.3.0 2019-09-04 01:24:08 -04:00
eugene yokota fbfceb5ded
Merge pull request #5028 from eed3si9n/wip/bump
bump io, lm, and zinc to 1.3.0
2019-09-04 00:36:21 -04:00
Eugene Yokota fa3a09368e bump io, lm, and zinc to 1.3.0 2019-09-03 23:51:13 -04:00
eugene yokota be1163b672
Merge pull request #5025 from eatkins/supershell-appender
Improve supershell appender management
2019-09-03 19:25:09 -04:00
Ethan Atkins 7c31e03d27 Improve supershell appender management
To avoid reliance on jvm global variables, we need to share the super
shell state with each of the console appenders that write to the console
out. We only set the progress state for the console appenders for the
screen. This prevents messages that are below the global logging level
from modifying the progress state without preventing them from being
written to other appenders.

The ability to set the ProgressState for each of the console appenders
is added in a companion util PR.

I verified that the test output of io/test was correctly written to the
streams after this change (there were no progress lines in the output).
2019-09-03 15:22:34 -07:00
eugene yokota 4f2ffe9b36
Merge pull request #5018 from eatkins/output-file-stamp-cache
Use managedFileStampCache for dependency classpath
2019-09-02 23:17:27 -04:00
eugene yokota 26293640c6
Merge pull request #5022 from eatkins/supershell-no-color
Allow supershell in no color mode
2019-09-02 23:15:52 -04:00
eugene yokota 903571cc62
Merge pull request #5023 from eatkins/supershell-test-names
Name test tasks with the test name
2019-09-02 20:13:50 -04:00
Ethan Atkins b996675c93 Name test tasks with the test name
Ref https://github.com/sbt/sbt/issues/4911. This names each parallel
test task with the name of the task so that supershell can display it.
It only applies for parallel tests. When run sequentially, supershell
will still display executeTests.
2019-09-02 14:58:49 -07:00
Ethan Atkins 19ead4144d
Merge pull request #5014 from eatkins/fail-on-exception
Display only valid pages in scripted completions
2019-09-02 11:41:21 -07:00