Commit Graph

7202 Commits

Author SHA1 Message Date
Ethan Atkins a5cefd45be Clean up nio apis
This commit refactors things so that the nio apis are located primarily
in the nio package. Because the nio keys are a first class sbt feature,
I had to add import sbt.nio._ and sbt.nio.Keys._ to the autoimports in
BuildUtil.scala
2019-05-02 14:36:06 -07:00
Ethan Atkins 4f6e38c805 Remove unneeded test
This isn't testing anything useful after the refactoring that removed
the implicit FileTree.Repository.
2019-05-02 14:33:29 -07:00
Ethan Atkins 2d1c80f916 Remove duped system in
I had some ideas for allowing the user to get a copy of system in during
a continuous build but I can't really see a good use case now so I'm
going to remove it before 1.3.0.
2019-05-02 14:33:29 -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
Ethan Atkins ba1f690bba Make Repository private[sbt]
This trait may not even survive until 1.4.0. It should definitely not be
public. I got a little overexcited about programming with higher kinded
types when I added it.
2019-05-02 14:33:02 -07:00
Ethan Atkins 41c63c1028 Remove unneeded filters 2019-05-02 14:33:02 -07:00
Ethan Atkins 51efa7bcc9 Remove pointless test
I never actually implemented this test so it wasn't really testing
anything.
2019-05-02 14:33:02 -07:00
Ethan Atkins 2deac62b00 Bump io
The newest version of io repackages a number of classes into the
sbt.nio.* packages. It also changes some of the semantics of glob
related apis. This commit updates all of the usages of the updated apis
within sbt but should have no functional difference.
2019-05-02 14:33:01 -07:00
Ethan Atkins 20b0ef786b Undeprecate WatchSource
Since the new watch implementation has yet to be widely deployed, we
should hold off on deprecating the old keys. They could still be
deprecated in a patch release or in 1.4.0.
2019-05-02 09:41:53 -07:00
eugene yokota bc21db2864
Merge pull request #4640 from eatkins/meta-space
Use global classloader cache for ScalaInstance
2019-04-30 16:43:23 -04:00
Ethan Atkins 3a6ff8afca Use global classloader cache for scala instance
I noticed in a heap dump of sbt that there were many classloaders for
the scala instance. I then realized that we were making a new
classloader for the scala library on every test run. Even worse, the
ScalaInstanceLoader instance was never closed which lead to a metaspace
leak. I moved the scala instance classloader to the global classloader
cache. Not only will these be correctly cached, they will be closed if
evicted from the cache.
2019-04-30 12:33:43 -07:00
Ethan Atkins f4a2bcd0ce Close URLClassLoaders after getting bridge
The ZincComponentCompilerSpec was fail with a metaspace related error
when run locally with a recent version of sbt on my machine. I was able
to stop these failures by closing the URLClassLoader instances used to
compile the bridge.
2019-04-30 12:24:47 -07:00
Dale Wijnand 31a3ad61c9
Miscellaneous zinc-lm-integration cleanups (#4634)
Miscellaneous zinc-lm-integration cleanups
2019-04-29 19:37:16 +01:00
eugene yokota 5443e17245
Merge pull request #4635 from eed3si9n/wip/refactor
Refactor recently added code
2019-04-29 11:46:37 -04:00
Eugene Yokota 788a864d83 Refactor some code 2019-04-29 10:33:08 -04:00
Dale Wijnand d51a5ef16e
Miscellaneous zinc-lm-integration cleanups 2019-04-29 14:40:55 +01:00
eugene yokota 1106422fb9
Merge pull request #4617 from dwijnand/zinc-lm-integration
In-source zinc's LM integration code
2019-04-28 22:19:43 -04:00
Dale Wijnand 736a1fa624
Switch back to unsuffixed 2.13 compiler bridge sources
Using the newer zinc version there now is a compiler bridge source jar
with suffix _2.13.
2019-04-28 23:41:48 +01:00
eugene yokota 33f4f5a49b
Merge pull request #4630 from eed3si9n/wip/cancelable
make Global / cancelable true by default
2019-04-28 18:17:41 -04:00
Dale Wijnand 481db003af
Zinc 1.3.0-M4
Zinc 1.3.0-M4
2019-04-28 23:06:28 +01:00
Eugene Yokota 04197db2ec formatting 2019-04-28 17:27:24 -04:00
Eugene Yokota 2e3ceb2d92 Zinc 1.3.0-M4 2019-04-28 17:27:10 -04:00
Eugene Yokota f5444f7715 Merge branch 'develop' into pr/4617 2019-04-28 17:22:54 -04:00
eugene yokota a3cebd3ade
Merge pull request #4614 from eed3si9n/wip/coursier
Coursier dependency resolution  integration
2019-04-27 15:52:57 -04:00
Eugene Yokota f999f6a62e always reresolve sbt artifacts when using Coursier
Ref #4589

This requires sbt server tests to resolve sbt off of local.
2019-04-27 14:31:13 -04:00
Eugene Yokota 96ad731e8c Use allExcludeDependencies 2019-04-26 18:06:10 -04:00
Eugene Yokota 8c0f13a24a manually expand ivy.home
Ref coursier/coursier#1124
2019-04-26 17:51:17 -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 258a8930a5 bump Scala 2.11 to 2.11.12 because we use JDK 11 2019-04-26 12:27:38 -04:00
Eugene Yokota 24db77edc5 copy some tests from coursier/sbt-coursier
Copying over sbt-coursier integration tests that do not depend on Coursier-specific things, but excercises sbt integration.
2019-04-26 12:27:38 -04:00
Eugene Yokota 7658f14762 Add maven-plugin and test-jar to classpathTypes
Ref https://github.com/sbt/sbt-native-packager/issues/1053
Ref https://github.com/coursier/coursier/issues/450
2019-04-26 12:27:38 -04:00
Eugene Yokota 464325ad1d add a simpler version of snapshot-resolution
Ivy is able to check for SNAPSHOT across different resolvers.
Coursier seems to be sticky about the resolver within the TTL (24h).
2019-04-26 12:27:38 -04:00
Eugene Yokota ca53934941 fix csrCachePath 2019-04-26 12:27:38 -04:00
Eugene Yokota 4b4359f7b1 mark dependency-management/dynamic-revision pending 2019-04-26 12:27:38 -04:00
Eugene Yokota 795601f594 mark dependency-management/url pending
Ref https://github.com/coursier/coursier/issues/1127
2019-04-26 12:27:38 -04:00
Eugene Yokota 9a666b5418 use Ivy for some tests 2019-04-26 12:27:38 -04:00
Eugene Yokota b47ed4e62a mark dependency-management/default-resolvers pending 2019-04-26 12:27:38 -04:00
Eugene Yokota 944e955d06 put sbtCp ahead of resolved JARs
Ref https://github.com/sbt/sbt/pull/4443
Ref https://github.com/coursier/coursier/issues/1128

This is a workaround for Coursier not excluding sbt modules.
2019-04-26 12:27:38 -04:00
Eugene Yokota 5614cfcbb6 Move log to outer task 2019-04-26 12:27:38 -04:00
Eugene Yokota 697b2b534a add additional resolver to help Coursier 2019-04-26 12:27:38 -04:00
Eugene Yokota e206e797fe set up specific dependencyResolution instances 2019-04-26 12:27:38 -04:00
Eugene Yokota 9b0ffde519 disable metadata-only-resolver test 2019-04-26 12:25:52 -04:00
Eugene Yokota 6a99906386 manually expand ivy.home
Ref https://github.com/coursier/coursier/issues/1124
2019-04-26 12:25:52 -04:00
Eugene Yokota 35a0ee4321 relax dependency-management/compiler-bridge-binary 2019-04-26 12:25:52 -04:00
Eugene Yokota 21782a51f0 write info.apiURL to ivy.xml
Ref https://github.com/coursier/coursier/issues/1123
2019-04-26 12:25:52 -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
eugene yokota 42bc2ea04d
Merge pull request #4631 from eatkins/previous
Allow calling TaskKey.previous in input tasks
2019-04-25 22:48:35 -04:00
Ethan Atkins 81ce14d58c Allow calling TaskKey.previous in input tasks
I discovered that it wasn't possible to call .previous in an input task.
While I understand why you can't call .previous on an InputKey, I think
it makes sense to allow calling .previous on a TaskKey within an input
task.
2019-04-25 15:58:01 -07:00
Eugene Yokota 3be8efc36e make Global / cancelable true by default
Fixes #3252
2019-04-25 12:14:37 -04:00
eugene yokota 3269eae533
Merge pull request #4606 from eed3si9n/wip/update
trim update and add updateFull
2019-04-25 12:13:22 -04:00