Commit Graph

363 Commits

Author SHA1 Message Date
Charles O'Farrell 67a3eca698 Use hedgehog in ParseKey, Delegates, and ParserSpec test 2019-09-30 01:52:57 -04:00
Ethan Atkins 8fd10bfb5f 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-09-27 13:23:42 -07:00
Ethan Atkins 231d7966d0 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-18 19:26:11 -07:00
Ethan Atkins 46eaa564d5 Add 1.3.0 to mima 2019-09-18 19:12:48 -07:00
Ethan Atkins a82e7892ab Bump sbt version 2019-09-05 11:46:23 -07:00
Ethan Atkins 58b3d970d0 Merge remote-tracking branch 'origin/1.3.x' into 1.3.x-merge 2019-09-05 11:44:24 -07:00
Eugene Yokota 665eb8f870 sbt 1.3.0 2019-09-04 01:24:08 -04:00
Ethan Atkins 4e1074d175 Use turbo in sbt build 2019-09-01 19:20:27 -07:00
Ethan Atkins c8c8eb2ade Delete unnecessary flat classloader strategy setting 2019-09-01 19:17:50 -07:00
Ethan Atkins 9896f77012 Fix typo 2019-07-29 12:45:22 -07:00
Ethan Atkins 893f120dee Don't rewrite RunFromSource.classpath every time
In the sbt project, we often spuriously re-doc a number of projects that
haven't changed because we modify a file in the resource path.
2019-07-29 12:44:20 -07:00
Ethan Atkins a5db9e86d7 Rename typesafe release resolver in sbt build
I was still seeing a number of warnings in the sbt project itself in
spite of 9bb88cd342. This made those go
away.
2019-07-09 14:29:44 -07:00
Ethan Atkins 32c2afaf2d Revert "revert doc"
It was only a matter of time before this erroneously got merged in.

This reverts commit 05aab1035a.
2019-06-04 16:45:16 -07:00
eugene yokota e31fd3f082
Merge pull request #4765 from eatkins/watch-docs
Watch docs
2019-06-03 22:36:46 -04:00
Ethan Atkins 05aab1035a revert doc 2019-06-03 17:35:01 -07:00
Ethan Atkins ce6484f4b4 Set java source and target levels
Since sbt must run on jdk8, we should be setting the javac source and
target levels.
2019-06-03 17:26:14 -07:00
eugene yokota 0994b7c104
Merge pull request #4740 from dwijnand/remove-unused-Task-mapTask
Remove unused Task#mapTask
2019-05-29 17:12:50 -04:00
Dale Wijnand 5036f339f8
Remove unused Task#mapTask 2019-05-29 14:43:42 +01:00
Ethan Atkins 8765710a88 Set mainProj/Test/classLoaderLayeringStrategy
The TestDependencies strategy doesn't work as of 1.3.0-RC1 because some
of the tests need to access resources. The ScalaLibrary strategy is
broken in 1.3.0-RC1. That leaves Flat. I tested that with 1.3.0-SNAPSHOT
off the latest master, that the AllLibraryJars strategy works fine, but
I need this change now to get travis to work.
2019-05-28 11:45:09 -07:00
Ethan Atkins e6d2b32902 Add scripted watchTriggers
This allows the scripted test files to trigger a continuous scripted
build.
2019-05-28 09:53:35 -07:00
Eugene Yokota 08c49358c7 Reduce concurrency of scalafmtCheck
Ref scalameta/scalafmt#1399
2019-05-17 14:51:07 -04:00
Ethan Atkins e5b54a59ea Manage shutdown hooks
I discovered that some registered shutdown hooks would crash due to
67df72ab01 because they would try to load
classes from the closed classloader. To fix this, I add a internal
shutdown hooks mechanism that can be managed by sbt. Any unevaluated
shutdown hooks will be run when the sbt main method exits. This means
that they will be run when the user calls reboot. I think that is
reasonable.
2019-05-13 17:38:56 -07:00
Eugene Yokota 3f5a872001 lm-coursier 1.1.0-M14-2 2019-05-13 13:59:58 -04:00
Eugene Yokota b4ea530036 reduce the example size to 1000 2019-05-11 04:52:42 -04:00
Eugene Yokota a0aa828238 format build.sbt 2019-05-11 03:42:06 -04:00
Eugene Yokota b96925bbda run 10000 examples to reduce flakiness 2019-05-11 03:41:41 -04:00
Ethan Atkins 02e78bd31d Add scalaXml to testingProj dependencies
This also seemed to be missing once the sbt metabuild classpath stopped
leaking into the compiler clAdd scalaXml to testingProj dependencies

This also seemed to be missing once the sbt metabuild classpath stopped
leaking into the compiler clAdd scalaXml to testingProj dependencies

This also seemed to be missing once the sbt metabuild classpath stopped
leaking into the compiler clAdd scalaXml to testingProj dependencies

This also seemed to be missing once the sbt metabuild classpath stopped
leaking into the compiler classpath.
2019-05-08 19:34:01 -07:00
Ethan Atkins 0d8f0816bc Add launcher interface dependency
Previously the zincLmIntegrationProj would compile if the meta build classpath
leaked into the compilation classpath. I found that the project would
not compile a clean build running an sbt built off of origin/develop.
2019-05-08 18:29:58 -07:00
Ethan Atkins 507346f3f6 Simplify file management settings
I decided that there were too many settings related to the file
management that did similar things and had similar names but did
slightly different things. To improve this, I introduce the ChangedFiles
class to sbt.nio.file and switch to having just two task for file input
and output retrieval: all(Input|Output)Files and
changed(Input|Output)Files. If, for example, changedInputFiles returns
None that means that either the task has not yet been run or there were
no changes. If there have been any changes, then it will return
Some(changes) and the user can extract the relevant changes that they
are interested in.

The code may be slightly more verbose in a few places, but I think it's
worth it for the conceptual clarity.
2019-05-02 14:36:08 -07:00
Ethan Atkins 72df8f674c Add support for managed task inputs
In my recent changes to watch, I have been moving towards a world in
which sbt manages the file inputs and outputs at the task level. The
main idea is that we want to enable a user to specify the inputs and
outputs of a task and have sbt able to track those inputs across
multiple task evaluations. Sbt should be able to automatically trigger a
build when the inputs change and it also should be able to avoid task
evaluation if non of the inputs have changed.

The former case of having sbt automatically watch the file inputs of a
task has been present since watch was refactored. In this commit, I
make it possible for the user to retrieve the lists of new, modified and
deleted files. The user can then avoid task evaluation if none of the
inputs have changed.

To implement this, I inject a number of new settings during project
load if the fileInputs setting is defined for a task. The injected
settings are:

allPathsAndAttributes -- this retrieves all of the paths described by
  the fileInputs for the task along with their attributes
fileStamps -- this retrieves all of the file stamps for the files
  returned by allPathsAndAttributes

Using these two injected tasks, I also inject a number of derived tasks,
such as allFiles, which returns all of the regular files returned by
allPathsAndAttributes and changedFiles, which returns all of the regular
files that have been modified since the last run.

Using these injected settings, the user is able to write tasks that
avoid evaluation if the inputs haven't changed.

foo / fileInputs += baseDirectory.value.toGlob / ** / "*.scala"
foo := {
  foo.previous match {
    case Some(p) if (foo / changedFiles).value.isEmpty => p
    case _ => fooImpl((foo / allFiles).value
  }
}

To make this whole mechanism work, I add a private task key:
val fileAttributeMap = taskKey[java.util.HashMap[Path, Stamp]]("...")
This keeps track of the stamps for all of the files that are managed by
sbt. The fileStamps task will first look for the stamp in the attribute
map and, only if it is not present, it will update the cache. This
allows us to ensure that a given file will only be stamped once per task
evaluation run no matter how the file inputs are specified. Moreover, in
a continuous build, I'm able to reuse the attribute map which can
significantly reduce latency because the default file stamping
implementation used by zinc is fairly expensive (it can take anywhere
between 300-1500ms to stamp 5000 8kb source files on my mac).

I also renamed some of the watch related keys to be a bit more clear.
2019-05-02 14:33:29 -07:00
Eugene Yokota f5444f7715 Merge branch 'develop' into pr/4617 2019-04-28 17:22:54 -04:00
Eugene Yokota f354a626c7 use lm-coursier-shaded
This uses lm-coursier-shaded, and follows along the changes in https://github.com/coursier/sbt-coursier/pull/58.
2019-04-26 17:33:14 -04:00
Eugene Yokota 38f94a6e31 Coursier dependency resolution integration
This adds dependency to LM implemented using Coursier.
I had to copy paste a bunch of code from sbt-coursier-shared to break the dependency to sbt.

`Global / useCoursier := false` or `-Dsbt.coursier=false` be used to opt-out of using Coursier for the dependency resolution.
2019-04-26 12:25:52 -04:00
Dale Wijnand e978357e47
In-source zinc's LM integration code 2019-04-25 11:57:37 +01:00
Ethan Atkins cd744b2c35 Print consistent version
Java has dropped the leading "1." from the specification version in
later versions. No one really refers to java 1.8, so it makes sense to
strip the "1." from the suggested version.
2019-03-23 09:33:18 -07:00
Ethan Atkins 4e66b492e5 Singularize java version in welcome banner 2019-03-23 09:16:33 -07:00
Eugene Yokota db45b456ef switch to official sbt-scalafmt 2019-03-22 17:47:48 -04:00
Ethan Atkins 7675007e00 Add Ethan Atkins to developer list 2019-03-22 12:38:53 -07:00
Ethan Atkins 798145e81e Add sbt io to the sbt project
Without this, the sbt io version is used by the compiler which means
that apis added in later versions of io are not available. I don't
understand why the transitive dependency on io is not used, but this
fixes the issue.
2019-03-22 09:32:36 -07:00
Eugene Yokota b98b5dffa6 use tag when available 2019-03-22 02:28:14 -04:00
xuwei-k db4f3484a2 add scalacOptions for scaladoc 2019-03-22 02:24:37 -04:00
Eugene Yokota 86abe3ed60 open up ExecuteProgress, and adds a few keys
Fixes #4461

This opens up ExecuteProgress API that's been around under private[sbt].
Since the state passing mechanism hasn't been used, I got rid of it.

The build user can configure the build using two keys Boolean `taskProgress` and `State => Seq[TaskProgress]` `progressReports`. `useSuperShell` is lightweight key on/off switch for the super shell that can be used as follows:

```scala
Global / SettingKey[Boolean]("useSuperShell") := false
```
2019-03-19 00:42:46 -04:00
Eugene Yokota cd1d2e0994 Util 1.3.0-M5 2019-03-08 19:18:53 -05:00
Eugene Yokota 68d0da379e add Mima exclusion 2019-01-04 09:55:28 -05:00
Eugene Yokota 67e590d940 define whitesourceOnPush
whitesourceOnPush calls whitesourceCheckPolicies and whitesourceUpdate on push.
Since Travis CI secrets are not available during PR from a fork, there's no point in calling these during the PR validation.
2018-12-13 19:31:56 -05:00
Ethan Atkins 01b2e86a54 Fix Def cannot be used inside a taskDyn #3110
The illegalReference check did not actually validate whether the illegal
reference actually referred to an M[_] (which is pretty much always
Initialize[_]]). The means by which this failure was induces were fairly
obscure and go through multiple levels of macro transformations that I
attempt to explain in the comment in IllegalReferenceSpec.

Fixes #3110
2018-12-11 21:49:42 -08:00
Eugene Yokota d58b302a97 Fix prompt for task progress 2018-11-16 23:05:51 -08:00
andrea 39493f7869 adding a fatjar release (aka sbt-big) to the build 2018-11-07 08:37:49 +00:00
Andrea Peruffo e4c9fbad79
Merge branch 'develop' into configurableLibraryManagement 2018-10-11 18:59:38 +01:00
andrea 34e0fc159c [sbt-server] LSP completions support 2018-10-11 13:34:40 +01:00
Andrea Peruffo cd69a112bd
Merge branch 'develop' into configurableLibraryManagement 2018-10-10 17:43:50 +01:00
Ethan Atkins d31fae59f7 Add global file repository task
Every time that the compile task is run, there are potentially a large
number of iops that must occur in order for sbt to generate the source
file list as well as for zinc to check which files have changed since
the last build. This can lead to a noticeable delay between when a build
is started (either manually or by triggered execution) and when
compilation actually begins. To reduce this latency, I am adding a
global view of the file system that will be stored in
BasicKeys.globalFileTreeView.

To make this work, I introduce the StampedFile trait, which augments the
java.io.File class with a stamp method that returns the zinc stamp for
the file. For source files, this will be a hash of the file, while for
binaries, it is just the last modified time. In order to gain access to
the sbt.internal.inc.Stamper class, I had to append addSbtZinc to the
commandProj configurations.

This view may or may not use an in-memory cache of the file system tree
to return the results. Because there is always the risk of the cache
getting out of sync with the actual file system, I both make it optional
to use a cache and provide a mechanism for flushing the cache. Moreover,
the in-memory cache implementation in sbt.io, which is backed by a
swoval FileTreeRepository, has the property that touching a monitored
directory invalidates the entire directory within the cache, so the
flush command isn't even strictly needed in general.

Because caching is optional, the global is of a FileTreeDataView, which
doesn't specify a caching strategy. Subsequent commits will make use of
this to potentially speed up incremental compilation by caching the
Stamps of the source files so that zinc does not need to compute the
hashes itself and will allow for continuous builds to use the cache to
monitor events instead of creating a new, standalone FileEventMonitor.
2018-10-09 12:09:42 -07:00
andrea 0c11bc6add Build time configurable library management 2018-10-09 09:03:55 +01:00
Ethan Atkins 6725b39a84 Bump io to 1.3.0-M3
I had to turn off -Xfatal-warnings in commandProj because after updating
io, commandProj depends on the deprecated EventMonitor class. In #4335,
I stop using EventMonitor, but deprecate the Watched class which is both
defined and used (as an unused attribute key) in commandProj. I think we
can probably get rid of Watched in 1.4.x and certainly in a hypothetical
2.x, so hopefully we can restore -Xfatal-warnings sooner than later.

I also had to replace uses of IO.classLocationFile with
IO.classLocationPath to avoid compilation failures due to
-Xfatal-warnings.
2018-10-08 13:59:34 -07:00
Eugene Yokota c64166ea8d check PluginCross.scala consisntency 2018-10-05 13:32:40 -04:00
Eugene Yokota 0d788162ae add onLoadMessage 2018-10-05 03:04:22 -04:00
Eugene Yokota aec08f6760 1.3.0-SNAPSHOT 2018-09-25 11:25:24 -04:00
Eugene Yokota ef49a95b7d address more warnings 2018-09-18 17:45:24 -04:00
Eugene Yokota 3e1dac5161 -Xfatal-warnings in most subprojects 2018-09-18 11:47:55 -04:00
Eugene Yokota 96676e4c55 Apache License 2.0
https://discuss.lightbend.com/t/moving-sbt-and-zinc-to-the-apache-v2-license/1670
2018-09-14 03:38:58 -04:00
Eugene Yokota 0843cd6a3c sbt 1.2.3 2018-09-14 03:28:12 -04:00
Eugene Yokota 590dc5e96d Merge branch '1.2.x' into wip/merge-1.2.x 2018-08-16 16:15:15 -04:00
Kazuhiro Sera 59dbc0645e Fix the several typos detected by github.com/client9/misspell 2018-08-08 15:57:34 +09:00
Eugene Yokota 305a8de319 1.2.1-SNAPSHOT 2018-07-30 20:28:42 -04:00
Eugene Yokota 4bcfaee264 1.2.0 2018-07-30 00:56:36 -04:00
Eugene Yokota 4ecb3a3f7c Fix bimcompat breakages in complete
Fixes https://github.com/sbt/sbt/issues/4268
2018-07-15 22:28:55 -04:00
Eugene Yokota b3342118f8 Add dependencyOverrides for scripted-plugin
Fixes #4249

This introduces an override rule into the metabuild so scripted-plugin will align with the sbt version.
2018-07-10 03:13:47 -04:00
Eugene Yokota d7dc4b3e29 create scripted-sbt-redux
Fixes #4241
Fixes #4242

This introduces a new subproject named scripted-sbt-redux. The purpose of this new subproject is to workaround the 'sbt.test` package vs `Keys.test` key confusion (#4242) while maintaining the forward compatibility of 0.13.17's sbt cross testing ^^ (#4241).

The new subproject uses `sbt.scriptedtest` package name, and that's the one that will be used by the mothership.

Meanwhile "scripted-sbt" subproject will also be published for compatibility purpose.
2018-07-10 03:13:47 -04:00
Eugene Yokota 1aea46d9e4 Import SemanticSelector 2018-07-01 03:13:09 -04:00
eugene yokota b0e025915a
Merge pull request #4227 from eed3si9n/wip/thin
Implement thin client
2018-06-27 15:27:42 -04:00
Eugene Yokota 306ee82db3 Use MessageOnlyException for "Nonzero exit code" 2018-06-27 07:09:59 -04:00
Eugene Yokota 76b2ea03cd Fix mima issue 2018-06-25 22:37:22 -04:00
Eugene Yokota dc73fcfece Split server unit test on its own
Ref https://github.com/sbt/sbt/issues/4186
This is an attempt to fix the flaky server test issue.
2018-06-18 04:43:11 -04:00
Eugene Yokota 28e90ea09b Merge branch '1.1.x' into wip/merge-1.1.x 2018-04-29 14:31:30 -04:00
Dale Wijnand 3a4bc8dc0b
Dropped deprecated "compat" commands & strings
Fixes #4089
2018-04-26 14:04:05 +01:00
Eugene Yokota 334789c919 1.1.5-SNAPSHOT 2018-04-25 16:15:19 -04:00
Dale Wijnand 490f57c779
Upgrade to sbt-scalafmt 1.15 & scalafmt 1.4.0 2018-04-24 16:09:48 +01:00
OlegYch eeeb4c9ff2 Remove usage of DynamicVariable and fix memory leak, fixes https://github.com/sbt/sbt/issues/4112 2018-04-23 20:46:08 +03:00
Dale Wijnand dfff1ed928
Merge pull request #4032 from eed3si9n/wip/servertest
improve server testing
2018-04-18 07:12:53 +02:00
Eugene Yokota 1ec07c1867 Recover sbtOn 2018-04-17 23:26:29 +02:00
Dale Wijnand 54a6262f7f
Merge pull request #4041 from dwijnand/Scoped.equals
Give Scoped a default equals/hashCode implementation
2018-04-10 06:10:55 +01:00
Eugene Yokota b9eb7764f3 Zinc 1.1.5 2018-04-09 12:37:42 -04:00
Eugene Yokota 04d6a8b44c perf: optimize hash for build
This hot path was discovered by retronym using FlameGraph.
This removes intermediate creation of Array.

`filesModifiedBytes` in particular was bad as it was going through all `*.class` files, each generating an Array. This replaces that with `fileModifiedHash` that accepts `MessageDigest`.

According to the flamegraph, evalCommon footprint reduced from 4.5% to 3.6%.
Using `time sbt reload reload reload exit`, the median reduced from 41.450s to 39.467s.
2018-04-05 03:26:02 -04:00
Dale Wijnand 3692db9068
Give Scoped a default equals/hashCode implementation 2018-04-04 15:04:53 +01:00
Eugene Yokota c2837c7714 Merge branch 'wip/bumpsbt' into wip/merge-1.1.x 2018-03-27 10:16:10 -04:00
Eugene Yokota 1b77b35333 bump to 1.1.3-SNAPSHOT 2018-03-27 06:53:05 -04:00
Eugene Yokota 67e1e4a9ff improve server testing
previously I was using separate thread in a forked test to test the server, but that is not enough isolation to run multiple server tests.
This adds `RunFromSourceMain.fork(workingDirectory: File)`, which allows us to run a fresh sbt on the given working directory. Next, I've refactored the stateful client-side buffer to a class `TestServer`.
2018-03-24 12:09:41 -04:00
Dale Wijnand 00ce32f102
Cleanup CommandChannel 2018-03-20 09:17:55 +00:00
Dale Wijnand fe418c92a7
Merge pull request #4016 from dwijnand/cleanup/Watched
Make Watched use State#handleError
2018-03-20 08:54:18 +00:00
Dale Wijnand 9c0ac90ee9
Make Watched use State#handleError 2018-03-19 15:21:15 +00:00
Dale Wijnand 6ceed00f48
Cleanup NetworkChannel 2018-03-19 15:11:39 +00:00
Eugene Yokota cd9f0d2711 make sbt server extensible
Fixes #3890

Here's an example:

```scala
    Global / serverHandlers += ServerHandler({ callback =>
      import callback._
      import sjsonnew.BasicJsonProtocol._
      import sbt.internal.protocol.JsonRpcRequestMessage
      ServerIntent(
        {
          case r: JsonRpcRequestMessage if r.method == "lunar/helo" =>
            jsonRpcNotify("lunar/oleh", "")
            ()
        },
        PartialFunction.empty
      )
```
2018-03-13 23:02:45 +09:00
Dale Wijnand dd4de14593
Upgrade to contraband 0.4.0 2018-03-12 15:39:07 +00:00
eugene yokota 92c95ce290
Merge pull request #3997 from eed3si9n/wip/test-status-thread-safety
Fix race condition in non-forked, parallel tests.
2018-03-07 16:18:55 -05:00
Eugene Yokota 49b4c3a3e0 mima 2018-03-07 15:31:24 -05:00
Dale Wijnand 26014a527e
Use Def.settings (bikeshed) 2018-03-06 19:20:33 +00:00
Dale Wijnand 3791e489b2
Use Def.settings in build.sbt 2018-03-06 11:59:27 +00:00
Dale Wijnand a69c3d6e13
Format build.sbt 2018-03-06 11:59:27 +00:00
Dale Wijnand 8187a51d31
Cleanup local Scripted plugin 2018-03-06 11:54:11 +00:00
Dale Wijnand b9e3d6aa2d
Define local Scripted plugin keys in Global scope 2018-03-06 11:54:11 +00:00