Commit Graph

11930 Commits

Author SHA1 Message Date
Ethan Atkins e910a13d7f Add internalDependencyConfigurations setting
In order to walk the full dependency graph of a task, we need to know
the internal class path dependency configurations. Suppose that we have
projects a and b where b depends on *->compile in a. If we want to find
all of the inputs for b, then if we find that there is a dependency on
b/Compile/internalDependencyClasspath, then we must add a / Compile /
internalDependencyClasspath to the list of dependencies for the task.

I copied the setup of one of the other scripted tests that was
introduced to test the track-internal-dependencies feature to write a
basic scripted test for this new key and implementation.
2019-03-30 16:38:44 -07:00
Ethan Atkins 1df62b6933 Add fileInputs and watchTriggers task
This adds two new tasks: fileInputs and watchTriggers, that will be used by sbt
both to fetch files within a task as well as to create watch sources for
continuous builds. In a subsequent commit, I will add a task for a
command that will traverse the task dependency graph to find all of the
input task dependency scopes. The idea is to make it possible to easily
and accurately specify the watch sources for a task. For example, we'd
be able to write something like:

val foo = taskKey[Unit]("print text file contents")
foo / fileInputs := baseDirectory.value  **  "*.txt"
foo := {
  (foo / fileInputs).value.all.foreach(f =>
    println(s"$f:\n${new String(java.nio.Files.readAllBytes(f.toPath))}"))
}

If the user then runs `~foo`, then the task should trigger if the user
modifies any file with the "txt" extension in the project directory.
Today, the user would have to do something like:

val fooInputs = settingKey[Seq[Source]]("the input files for foo")
fooInputs := baseDirectory.value ** "*.txt"

val foo = taskKey[Unit]("print text file contents")
foo := {
  fooInputs.value.all.foreach(f =>
    println(s"$f:\n${new String(java.nio.Files.readAllBytes(f.toPath))}"))
}
watchSources ++= fooInputs.value

or even worse:

val foo = taskKey[Unit]("print text file contents")
foo := {
  (baseDirectory.value ** "*.txt").all.foreach(f =>
    println(s"$f:\n${new String(java.nio.Files.readAllBytes(f.toPath))}"))
}
watchSources ++= baseDirectory.value ** "*.txt"

which makes it possible for the watchSources and the task sources to get
out of sync.

For consistency, I also renamed the `outputs` key `fileOutputs`.
2019-03-30 16:38:44 -07:00
Ethan Atkins 6da876cbe7 Remove unneeded string interpolation 2019-03-30 16:38:44 -07:00
eugene yokota e17f8f27d2
Merge pull request #4590 from eatkins/supershell-ci
Disable supershell in CI
2019-03-30 19:21:47 -04:00
Ethan Atkins 81481a8af5 Disable supershell in CI
The supershell output is distracting in CI. I added a system property,
sbt.ci, to explicitly set whether or not sbt is running in a ci build.
It was not at all obvious to me if the BUILD_NUMBER or CI environment
variables were set on travis or appveyor.
2019-03-30 11:51:47 -07:00
eugene yokota ca5f978df4
Merge pull request #4589 from eed3si9n/wip/metabuild_fix
Exclude all sbt modules from metabuild resolution
2019-03-30 11:52:25 -04:00
Eugene Yokota 33e648473f Exclude major sbt modules from metabuild resolution
Fixes #4582

#4443 introduced a perf enhacement of exluding sbt out of the metabuild, and instead appending the list of JARs resolved by the sbt launcher to the classpath.
This strategy worked in most cases, but it seems like some plugins are explicitly depending on IO module. In those cases, old IO would come before the new IO in the classpath ordering, resulting to "Symbol X is missing from classpath" error.
This fixes the issue by excluding all modules whose organization is `org.scala-sbt`.

As an escape hatch, I am adding a new key `reresolveSbtArtifacts`, which can be used to opt out of this behavior.
2019-03-29 21:34:49 -04:00
eugene yokota 540ee83f2a
Merge pull request #4585 from eatkins/jline
Jline
2019-03-29 08:16:05 -04:00
Ethan Atkins 6b82a8d07e Don't use usingTerminal
The usingTerminal method synchronizes the JLine object which can lead to
deadlock if multiple threads call it. When we just to want to read the
attributes of the terminal, but not modify it, there doesn't seem to be
any reason to use a lock.
2019-03-28 20:37:49 -07:00
Ethan Atkins 447ab5011c Reduce latency of InputStream polling
Calling InputStream.available has low overhead so there is no need to
have such a long input latency.
2019-03-28 20:37:49 -07:00
Ethan Atkins ae85d691b8
Merge pull request #4587 from eatkins/scope-type
Rename generic parameter
2019-03-28 13:49:01 -07:00
Ethan Atkins d178f13fc0 Rename generic parameter
I was seeing a number of compiler warnings about the type parameter
Scope:
    Settings.scala:55:12: type parameter Scope defined in trait Init shadows class Scope defined in package util. You may want to rename your type parameter, or possibly remove it.

I'm not sure why I wasn't seeing these before, but the fix is simple.
2019-03-28 08:31:10 -07:00
eugene yokota cdd264a5cb
Merge pull request #4580 from eed3si9n/wip/sdkman
detection of SDKMAN managed JDKs
2019-03-28 00:08:22 -04:00
Eugene Yokota 29ebd1222c improve the implementation of expandJavaHomes 2019-03-26 23:06:49 -04:00
Eugene Yokota c0cd65af92 detection of SDKMAN managed JDKs 2019-03-26 18:37:36 -04:00
Eugene Yokota 6f19f76b40 migrate to ScalaTest FunSuite 2019-03-26 18:26:52 -04:00
eugene yokota de5c0434df
Merge pull request #4576 from eed3si9n/wip/trace
output Chrome traces on -Dsbt.traces=true
2019-03-25 17:21:59 -04:00
eugene yokota b1aff41d33
Merge pull request #4577 from eed3si9n/wip/dogfood
use sbt 1.3.0-M2
2019-03-25 03:09:31 -04:00
Eugene Yokota adfb2ece1a install official sbt based on project/build.properties 2019-03-25 02:10:48 -04:00
eugene yokota f71bf47ed4
Merge pull request #4579 from eed3si9n/wip/scoping
widen scopes for classLoaderLayeringStrategy
2019-03-24 22:49:51 -04:00
Eugene Yokota a713a62d12 widen scopes for classLoaderLayeringStrategy
Fixes #4574

This defines the `classLoaderLayeringStrategy` key at `Global` and `Zero / Test` level, and uses the scope delegation to pick them out from `test`.
2019-03-24 14:49:37 -04:00
Eugene Yokota 38018eb69f use sbt 1.3.0-M2 2019-03-24 13:32:20 -04:00
eugene yokota 32c34f9305
Merge pull request #4573 from eatkins/java-version-typo
Singularize java version in welcome banner
2019-03-24 01:34:05 -04:00
Jason Zaugg 3600c97f1f WIP output Chrome trace format 2019-03-23 18:42:00 -04: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 1da0b3afd2
Merge pull request #4571 from eed3si9n/wip/bumplog4j
log4j 2.11.2
2019-03-23 10:51:38 -04:00
Eugene Yokota 7ae61567a2 log4j 2.11.2 2019-03-23 03:00:08 -04:00
eugene yokota 53efe2e9b7
Merge pull request #4570 from eed3si9n/wip/bump
Bump modules
2019-03-22 20:52:52 -04:00
Eugene Yokota db45b456ef switch to official sbt-scalafmt 2019-03-22 17:47:48 -04:00
Eugene Yokota 138c250fe2 Bump modules 2019-03-22 17:38:14 -04:00
eugene yokota 6dc1d816b7
Merge pull request #4569 from eatkins/eatkins-developer
Add Ethan Atkins to developer list
2019-03-22 16:51:40 -04:00
Ethan Atkins 7675007e00 Add Ethan Atkins to developer list 2019-03-22 12:38:53 -07:00
eugene yokota 319ecf31c6
Merge pull request #4539 from eatkins/glob-performance
Glob performance
2019-03-22 13:34:50 -04:00
Ethan Atkins f26afe6681 Return (Path, FileAttributes) instead of Stamped.File
I realized that Stamped.File was a bad interface that was really just an
implementation detail of external hooks. I updated the
GlobLister.{ all, unique } methods to return Seq[(Path, FileAttributes)]
rather than Stamped.File which is a much more natural api and one I
could see surviving the switch to nio based apis planned for
1.4.0/2.0.0. I also added a simple scripted test for glob listing. The
GlobLister.all method is implicitly tested all over the place since the
compile task uses it, but it's good to have an explicit test.
2019-03-22 09:32:36 -07:00
Ethan Atkins c3e0e117e6 Do not use caching repository by default
The caching repository does not work universally so set the default to
always poll. This is still faster than in sbt 1.2.x because of
performance improvements that I added for listing directories.
2019-03-22 09:32:36 -07:00
Ethan Atkins 467ece1ba1 Temporarily make FileTree.Repository public
This should not be exposed to users but will be for M1.
2019-03-22 09:32:36 -07:00
Ethan Atkins d231d7d9ec Rename FileCacheEntry to FileAttributes
I decided that FileCacheEntry was a bad name because the methods did not
necessarily have anything to do with caching. Moreover, because it is
exposed in a public interface, it shouldn't be in the internal package.
2019-03-22 09:32:36 -07:00
Ethan Atkins be94b25d68 Add Event trait to FileCacheEntry
Rather than exposing the FileEventMonitor.Event types, which are under
active development in the io repo, I am adding a new event trait to
FileCacheEntry. This trait doesn't expose any internal implementation
details.
2019-03-22 09:32:36 -07:00
Ethan Atkins 86200345e1 Don't expose TypedPath to users
I've decided I don't like the TypedPath interface so I'm not going to
expose it publicly.
2019-03-22 09:32:36 -07:00
Ethan Atkins 6a5f0f2af2 Make Stamped.file private[sbt] 2019-03-22 09:32:36 -07:00
Ethan Atkins fac6e0d9a0 Make file repository apis private[sbt]
I haven't fully settled on these interfaces yet so they shouldn't be publicly
exposed in the sbt api.
2019-03-22 09:32:36 -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
Ethan Atkins 1489879b80 Fix equals for FileCacheEntry
The equals method didn't work exactly the way I thought. By delegating
to the equivStamp object in sbt we can be more confident that it is
actually comparing the stamp values and not object references or
some other equals implementation.
2019-03-22 09:32:35 -07:00
Ethan Atkins 47b85b98c0 Run windows tests on visual studio 2015 and 2017
I've noticed that it's possible to write code that works on one but not
the other.
2019-03-22 09:32:35 -07:00
Ethan Atkins e3625ca8b0 Fix repository setup on windows
Windows io really doesn't handle concurrent readers and writers all that
well. Using the LegacyFileTreeRepository was problematic in windows
scripted tests because even though the repository implementation did not
use the cache in its list methods, it did persistently monitor the
directories that were registered. The monitor has to do a lot of
io on a background thread to maintain the cache. This caused io
contention that would cause IO.createDirectory to fail with an obscure
AccessDeniedException. The way to avoid this is to prevent the
background io from occurring at all.

I don't necessarily think this will impact most users running sbt
interactively with a cache, but it did cause scripted tests to fail. For
that reason I made the default in non-interactive/shell use cases on
windows to be a PollingFileRepository which never monitors the file
system except when we are in a watch. The LegacyFileTreeRepository works
fine on mac and linux which have a more forgiving file system.

To make this work, I had to add FileManagement.toMonitoringRepository.
There are now two kinds of repositories that cannot monitor on their
own: HybridPollingFileTreeRepository and PollingFileRepository. The
FileManagement.toMonitoringRepository makes a new repository that turns
on monitoring for those two repository types and disables the close
method on all other repositories so that closing the FileEventMonitor
does not actually close the global file repository.
2019-03-22 09:32:35 -07:00
Ethan Atkins b0c5e00c7c Reimplement clean
I ran into a couple of issues with the clean implementation. I changed
the logging to print to stdout instead of streams if enabled. I also
added a helper, Clean.deleteContents that recursively deletes all of the
contents of a directory except for those that match the exclude filter
parameter.

Using a normal logger was a bad idea because we are actually deleting
the target/streams directory when running clean.

The previous implementation worked by getting the full list of files to
delete, reverse sorting it and then deleting every element in the list.
While this can work well it many circumstances, if the directory is
still being written to during the recursive deletion, then we could miss
files that were added after we fetched all of the files. The new version
lazily lists the subdirectories as needed.
2019-03-22 09:32:35 -07:00
Ethan Atkins 16afe41cc1 Don't try to stamp files that don't exist
This was causing slowdowns in windows.
2019-03-22 09:32:35 -07:00
Ethan Atkins de3c09f99d Move clean task implementation to Clean.scala
The Defaults.scala file has a lot going on. I am trying to generally
follow the pattern of implementing the default task implementation in a
different file and just adding the appropriate declarations in
Defaults.scala.
2019-03-22 09:32:35 -07:00
Ethan Atkins 172c8e9a0b Support custom clean tasks
This rewroks the cleanTask so that it only removes a subset of the
files in the target directory. To do this, I add a new task, outputs,
that returns the glob representation of the possible output files for
the task. It must be a task because some outputs will depend on streams.
For each project, the default outputs are all of the files in
baseDirectory / target.

Long term, we could enhance the clean task to be automatically generated
in any scope (as an input task). We could then add the option for the
task scoped clean to delete all of the transitive outputs of the class.
That is beyond the scope of this commit, however.

I copied the scripted tests from #3678 and added an additional test to
make sure that the manage source directory was explicitly cleaned.
2019-03-22 09:32:35 -07:00