Commit Graph

7419 Commits

Author SHA1 Message Date
Ethan Atkins dbd4fb115b
Merge pull request #4953 from eatkins/scripted-fixes
Scripted fixes
2019-08-15 19:04:06 -07:00
Ethan Atkins 4c6df99b6a Run scripted watch tests with launcher on windows
The sbt-coursier plugin now uses a shaded jansi and it seems to cause
problems with scripted tests if they aren't run using the launcher. On
my vm, all of the watch tests succeeded after this change and they all
crashed the jvm before.
2019-08-15 17:33:48 -07:00
Ethan Atkins e621ebe678 Ensure correct scripted plugin implementation exists
When running the scripted tests on my vm, I noticed that one of the
watch tests warned that the InstrumentScripted.scala file had changed
after the project had initialized. The test then hung and I had to kill
it. To try and prevent this from happening, I moved the creation of the
plugin file to right before the call to ";reload;setUpScripted".
2019-08-15 17:33:48 -07:00
eugene yokota 3b0171a50a
Merge pull request #4949 from eatkins/changed-binaries
Update ExternalHooks to look up changed binaries
2019-08-15 15:24:24 -04:00
Ethan Atkins 9c7acdb713 Force invalidate dependency changes
After adding the automatic lookup to external hooks for missing binary
jars, the scripted test dependency-management/invalidate-internal
started failing. This was because the previous analysis contained a jar
dependency that still existed on disk but was no longer a part of the
dependency classpath. Fundamentally the problem is that the zinc
compile analysis is not tightly coupled with the sbt build state.

To fix this, we can cache the dependency classpath file stamps in the
same way that we cache the input file stamps in external hooks and
manually diff them at the sbt level. We then force updates regardless of
the difference between the zinc state and the sbt state.
2019-08-15 11:31:24 -07:00
Ethan Atkins 32a6d0d5d7 Update ExternalHooks to look up changed binaries
It was reported that in community builds, sometimes there was
spurious over-compilation due to invalidation of the scala library jar
(https://github.com/sbt/sbt/issues/4948). The reason for this was that
the external hooks prefills the managed cache with all of the time
stamps for the project dependencies but was not looking up any jars that
weren't in the cache. I suspect I did this because I didn't realize that
zinc also includes its own classpath in the binaries which is not
a part of the dependencyClasspath. The fix is to just add the jar to the
cache if it doesn't already exist by switching to getOrElseUpdate from
get.

I followed the steps in #4948 and published a version of sbt locally
with this change and the spurious re-builds stopped.
2019-08-15 10:34:05 -07:00
eugene yokota c124bc1dcd
Merge pull request #4927 from eatkins/file-report
File report
2019-08-09 22:06:19 -04:00
Ethan Atkins 7c483909af Invalidate unmanagedFileStampCache in allOutputFiles
In the code formatting use case, the formatting task may modify the
source files in place. If the formatting task uses the nio
inputFileStamps, then it would fill the in-memory cache of source paths
to file stamps. This would cause compile to see the pre-formatted
stamps. To fix this, we can invalidate the file cache entries for the
outputs of a task. This will cause the side-effect of some extra io
because the hashes may be computed three times: once for the format
inputs, once for the format outputs and once for the compile inputs. I
think most users would understand that adding auto-formatting would
potentially slowdown compilation.

To really prove this out, I implemented a poor man's scalafmt plugin in
a scripted test. It is fully incremental. Even in the case when some
files cannot be formatted it will update all of the files that can be
formatted and not re-format them until they change.
2019-08-09 13:18:29 -07:00
Ethan Atkins 3f026972d5 Bump io to 1.3.0-M15
This fixes a bug with IO.delete on windows.
2019-08-09 12:18:22 -07:00
Ethan Atkins 440a4e2b51 Bump io version to 1.3.0-M14
This adds the PathFilter apis.
2019-08-09 12:18:22 -07:00
Ethan Atkins 6d482eb166 Set scope for fileTreeView
It makes sense to add a scope for the `fileTreeView` key where it is
available. At the moment, there is only one `fileTreeView`
implementation but, if that changes down the road, these tasks will
automatically inherit the correct view.
2019-08-09 12:18:22 -07:00
Ethan Atkins 6700d5f77a Add nio path filter settings
It makes sense for the new glob/nio based apis that we provide first
class support for filtering the results. Because it isn't possible to
scope a task within a task within a task, i.e.
`compile / fileInputs / includePathFilter`, I had to add four new
filter settings of type `PathFilter`:

fileInputIncludeFilter :== AllPassFilter.toNio,
fileInputExcludeFilter :== DirectoryFilter.toNio || HiddenFileFilter,
fileOutputIncludeFilter :== AllPassFilter.toNio,
fileOutputExcludeFilter :== NothingFilter.toNio,

Before I was effectively hard-coding the filter: RegularFileFilter &&
!HiddenFileFilter in the inputFileStamps and allInputFiles tasks. These
remain the defaults, as seen in the fileInputExcludeFilter definition
above, but can be overridden by the user.

It makes sense to exclude directories and hidden files for the input
files, but it doesn't necessarily make sense to apply any output filters
by default. For symmetry, it makes sense to have them, but they are
unlikely to be used often.

Apart from adding and defining the default values for these keys, the
only other changes I had to make was to remove the hard-coded filters
from the allInputFiles and inputFileStamps tasks and also add the
filtering to the allOutputFiles task. Because we don't automatically
calculate the FileAttributes for the output files, I added logic for
bypassing the path filter application if the PathFilter is effectively
AllPass, which is the case for the default values because:
AllPassFilter.toNio == AllPass
NothingFilter.toNio == NoPass
AllPass && !NoPass == AllPass && AllPass == AllPass
2019-08-09 12:18:22 -07:00
Ethan Atkins 8ce2578060 Introduce FileChanges
Prior to this commit, change tracking in sbt 1.3.0 was done via the
changed(Input|Output)Files tasks which were tasks returning
Option[ChangedFiles]. The ChangedFiles case class was defined in io as

case class ChangedFiles(created: Seq[Path], deleted: Seq[Path], updated: Seq[Path])

When no changes were found, or if there were no previous stamps, the
changed(Input|Output)Files tasks returned None. This made it impossible
to tell whether nothing had changed or if it was the first time.
Moreover, the api was awkward as it required pattern matching or folding
the result into a default value.

To address these limitations, I introduce the FileChanges class. It can
be generated regardless of whether or not previous file stamps were
available. The changes contains all of the created, deleted, modified
and unmodified files so that the user can directly call these methods
without having to pattern match.
2019-08-09 12:18:22 -07:00
Ethan Atkins 8e9efbeaac Add extension methods for input and output files
It is tedious to write (foo / allInputFiles).value so I added simple
extension method macros that expand `foo.inputFiles` to
(foo / allInputFiles).value and `foo.outputFiles` to
`(foo / allOutputFiles).value`.
2019-08-09 12:18:22 -07:00
Ethan Atkins f126206231 Fix incremental task evaluation semantics
While writing documentation for the new file management/incremental
task evaluation features, I realized that incremental task evaluation
did not have the correct semantics. The problem was that calls to
`.previous` are not scoped within the current task. By this, I mean that
say there are tasks foo and bar and that the defintion of bar looks like

bar := {
    val current = foo.value
    foo.previous match {
        case Some(v) if v == current => // value hasn't changed
        case _ => process(current)
    }
}

The problem is that foo.previous is stored in
effectively (foo / streams).value.cacheDirectory / "previous". This
means that it is completely decoupled from foo. Now, suppose that the
user runs something like:
> set foo := 1
> bar // processes the value 1
> set foo := 2
> foo
> bar // does not process the new value 2 because foo was called, which updates the previous value

This is not an unrealistic scenario and is, in fact, common if the
incremental task evaluation is changed across multiple processing steps.
For example, in the make-clone scripted test, the linkLib task processes
the outputs of the compileLib task. If compileLib is invoked separately
from linkLib, then when we next call linkLib, it might not do anything
even if there was recompilation of objects because the objects hadn't
changed since the last time we called compileLib.

To fix this, I generalizedthe previous cache so that it can be keyed on
two tasks, one is the task whose value is being stored (foo in the
example above) and the other is the task in which the stored task value
is retrieved (bar in the example above). When the two tasks are the
same, the behavior is the same as before.

Currently the previous value for foo might be stored somewhere like:

base_directory/target/streams/_global/_global/foo/previous

Now, if foo is stored with respect to bar, it might be stored in

base_directory/target/streams/_global/_global/bar/previous-dependencies/_global/_gloal/foo/previous

By storing the files this way, it is easy to remove all of the previous
values for the dependencies of a task.

In addition to changing how the files are stored on disk, we have to store
the references in memory differently. A given task can now have multiple
previous references (if, say, two tasks bar and baz both depend on the
previous value). When we complete the results, we first have to collect
all of the successful tasks. Then for each successful task, we find all
of its references. For each of the references, we only complete the
value if the scope in which the task value is used is successful.

In the actual implemenation in Previous.scala, there are a number places
where we have to cast to ScopedKey[Task[Any]]. This is due to
limitations of ScopedKey and Task being type invariant. These casts are
all safe because we never try to get the value of anything, we only use
the portion of the apis of these types that are independent of the value
type. Structural typing where ScopedKey[Task[_]] gets inferred to
ScopedKey[Task[x]] forSome x is a big part of why we have problems with
type inference.
2019-08-09 12:18:22 -07:00
Ethan Atkins d18cb83b3c Switch from Vector to List in Settings
Using List instead of vector makes the code a bit more readable. We
don't need indexed access into the data structure so its unlikely that
Vector was providing any performance benefit.
2019-08-09 12:18:22 -07:00
Ethan Atkins fdeb6be667 Add scaladoc to FileStamp
As part of a documentation push, I noticed that these were undocumented
and that there were some public apis in FileStamp that I intended to be
private[sbt].
2019-08-09 12:18:22 -07:00
Ethan Atkins fb15065438 Move implicit FileStamp JsonFormats into object
I realized it was probably not ideal to have these implicit JsonFormats
defined directly in the FileStamp object because they might
inadvertently be brought into scope with a wildcard import.
2019-08-09 12:18:22 -07:00
Ethan Atkins 2990e08c5d Set make-clone c compile options for all platforms
I realized that it didn't make sense to specify these just for linux
even though they work fine with the version of gcc that runs on my mac.
I also ran scalafmt on this file.
2019-08-09 12:18:22 -07:00
Ethan Atkins 9cd88070ae Fix typo in allOutputFiles description 2019-08-09 12:18:22 -07:00
Ethan Atkins a7715e90a4 Rename cacheStoreFactory attribute
It references a CacheStoreFactoryFactory so it should have been named
accordingly.
2019-08-09 12:18:22 -07:00
eugene yokota 6865f32eae
Merge pull request #4934 from eed3si9n/wip/publishTo
Revert "don't require publishTo specified if publishArtifact is `false`"
2019-08-09 09:24:31 -04:00
Ethan Atkins 5b5f239962
Merge pull request #4937 from eatkins/miscellaneous-fixups
Miscellaneous fixups
2019-08-08 21:47:33 -07:00
Ethan Atkins 9a1d874c37 Fix divide by zero 2019-08-08 16:06:13 -07:00
Ethan Atkins 14f7177619 Fix implicit numeric widening warning 2019-08-08 16:06:13 -07:00
Ethan Atkins 68a966178a
Merge pull request #4936 from eatkins/2.12.9-revert
2.12.9 revert
2019-08-08 13:36:32 -07:00
Ethan Atkins d86afb5745 Revert "Merge pull request #4930 from eatkins/2.12.9"
This reverts commit 053b72005d, reversing
changes made to d6b8e0388c.
2019-08-08 11:09:29 -07:00
Ethan Atkins f1538f76ce Revert "Merge pull request #4933 from eatkins/paradise"
This reverts commit 294a1c181e, reversing
changes made to 8365e4b189.
2019-08-08 11:08:06 -07:00
Eugene Yokota ec6cf15f12 Revert "don't require publishTo specified if publishArtifact is `false`"
This reverts commit 4668faff7c.
Ref https://github.com/sbt/sbt/pull/3760
Ref https://github.com/sbt/sbt/pull/4931
2019-08-08 00:36:36 -04:00
eugene yokota 294a1c181e
Merge pull request #4933 from eatkins/paradise
Bump source-dependencies/macro-annotation to 2.12.9
2019-08-06 18:17:38 -04:00
Ethan Atkins 0fc43cc95b Bump source-dependencies/macro-annotation to 2.12.9 2019-08-06 12:47:08 -07:00
eugene yokota 8365e4b189
Merge pull request #4926 from eatkins/auto-reload-fix
Improve auto-reload
2019-08-05 19:04:50 -04:00
eugene yokota 053b72005d
Merge pull request #4930 from eatkins/2.12.9
Bump default scala version to 2.12.9
2019-08-05 19:04:13 -04:00
Ethan Atkins 86cb74bb96 Downgrade to 2.12.8 for project/semanticdb scripted test
Semanticdb hasn't been published for 2.12.9 yet.
2019-08-05 14:25:59 -07:00
Ethan Atkins 416cc653b6 Downgrade to 2.12.8 for source-dependencies/macro-annotation
The macro paradise library isn't published for 2.12.9 (yet).
2019-08-05 14:25:59 -07:00
Ethan Atkins 2a99f86b87 Fix dependency-management/sources for 2.12.9
An additional jar is required.
2019-08-05 14:25:54 -07:00
Ethan Atkins 9e165b01d9 Use https in scala url 2019-08-05 14:00:26 -07:00
Ethan Atkins c34de173ea Upgrade classloader-cache/resources libarary to 2.12.9 2019-08-05 13:59:17 -07:00
Ethan Atkins b26ce819ca Bump default scala version to 2.12.9
I automatically generated with:

git grep "2.12.8" | \
  cut -d ':' -f1 | uniq | xargs perl -p -i -e "s/2.12.8/2.12.9/"
2019-08-05 13:12:28 -07:00
Ethan Atkins aa62386f4d Improve auto-reload
I noticed that sometimes if I changed a build source and then ran reload
in the shell, I'd still see a warning about build sources having
changed. We can eliminate this behavior by resetting the
hasCheckedMetaBuild state attribute to false and skipping the
checkBuildSources step if the current command is 'reload'. We also now
skip checking the build source step if the command is exit or reboot.
2019-08-05 07:42:24 -07:00
eugene yokota d6b8e0388c
Merge pull request #4928 from eed3si9n/wip/ivy-settings-b
Remove ivy-settings-b scripted test
2019-08-05 01:26:48 -04:00
Eugene Yokota 54b6e1fc08 Remove ivy-settings-b scripted test 2019-08-05 00:24:44 -04:00
eugene yokota b0368cf320
Merge pull request #4924 from eed3si9n/wip/launcher
launcher 1.1.1
2019-08-02 17:31:29 -04:00
Eugene Yokota 1df9020249 launcher 1.1.1 2019-08-02 15:56:59 -04:00
eugene yokota f0b54ca3a0
Merge pull request #4910 from eatkins/coursier-cache
Add coursier cache to CI
2019-08-01 16:21:19 -04:00
Ethan Atkins 4cee23043a Bump scalafmt
The latest version may fix some issues with concurrent builds running
scalafmt: https://github.com/scalameta/scalafmt/issues/1399.
2019-08-01 11:57:29 -07:00
Ethan Atkins ec281d8a14 Add coursier cache to CI
These locations are taken from https://get-coursier.io/docs/cache.
2019-08-01 11:57:29 -07:00
eugene yokota 96d6e0d52a
Merge pull request #4899 from eatkins/watch-symlink-scripted
Add scripted test for symlink source monitoring
2019-07-30 17:39:27 -04:00
eugene yokota 20f46370ca
Merge pull request #4908 from eatkins/incremental-consistency
Override zinc compile analysis for source changes
2019-07-30 17:38:35 -04:00
Ethan Atkins 411c9fa8c7
Merge pull request #4904 from eatkins/parser-fix
Parser fix
2019-07-29 23:11:33 -07:00