sbt, the interactive build tool
Go to file
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
.github/ISSUE_TEMPLATE Auto-label bug reports & delete old issue template 2019-06-04 08:01:18 +01:00
core-macros/src/main/scala/sbt/internal/util/appmacro Add support for managed task inputs 2019-05-02 14:33:29 -07:00
internal Bump scalafmt 2019-07-18 12:40:21 -07:00
launch Adds sbt.boot.lock sysprop to opt-out 2018-02-08 13:02:39 +00:00
licenses move remaining pieces of sbt subproject to sbt_pending and fix notices 2010-09-21 21:55:50 -04:00
main Fix incremental task evaluation semantics 2019-08-09 12:18:22 -07:00
main-actions/src Fix java.util.zip.ZipException: duplicate entry 2019-07-23 01:28:32 -04:00
main-command/src Merge branch 'develop' into parser-fix 2019-07-29 21:57:44 -07:00
main-settings/src Fix incremental task evaluation semantics 2019-08-09 12:18:22 -07:00
notes Revert "don't require publishTo specified if publishArtifact is `false`" 2019-08-08 00:36:36 -04:00
project Fix divide by zero 2019-08-08 16:06:13 -07:00
protocol/src/main apply formatting 2019-04-20 03:23:54 -04:00
run quote run argument if it contains a whitespace 2019-06-24 19:32:55 -04:00
sbt/src Fix incremental task evaluation semantics 2019-08-09 12:18:22 -07:00
scripted-plugin/src/main/scala/sbt -Xfatal-warnings in most subprojects 2018-09-18 11:47:55 -04:00
scripted-sbt-old/src/main/scala/sbt/test Update header 2018-09-14 04:53:36 -04:00
scripted-sbt-redux Relax strict commands 2019-07-16 15:17:21 -07:00
src/main/conscript 1.2.0 2018-07-30 00:56:36 -04:00
tasks Don't automatically die on OOM: metaspace 2019-05-28 09:53:36 -07:00
tasks-standard Add support for in memory cache store 2019-07-11 17:45:16 -07:00
testing Bump scalafmt 2019-07-18 12:40:21 -07:00
vscode-sbt-scala fix typo 2019-06-06 08:05:16 +03:00
zinc-lm-integration/src Add new ClassLoaderCache implementation 2019-05-28 09:53:35 -07:00
.appveyor.yml Add coursier cache to CI 2019-08-01 11:57:29 -07:00
.gitattributes remove gittatributes, assume core.autocrlf=false 2018-06-26 17:38:05 +03:00
.gitignore adding a fatjar release (aka sbt-big) to the build 2018-11-07 08:37:49 +00:00
.java-version Configure JVM 1.8 in .java-version 2016-10-07 08:48:23 -05:00
.mailmap Add mailmap 2019-06-11 09:30:14 +02:00
.sbtopts Use .sbtopts to increase the RAM 2018-06-25 19:40:15 -04:00
.scalafmt.conf Bump scalafmt 2019-07-18 12:40:21 -07:00
.travis.yml Add coursier cache to CI 2019-08-01 11:57:29 -07:00
CONTRIBUTING.md Split some of the developing related docs to DEVELOPING.md 2019-07-15 12:39:41 -04:00
DEVELOPING.md Minor clarification of logging message 2019-07-19 06:01:15 -05:00
LICENSE Apache License 2.0 2018-09-14 03:38:58 -04:00
NOTICE Apache License 2.0 2018-09-14 03:38:58 -04:00
PROFILING.md fix typo 2018-07-08 22:18:57 +09:00
README.md fix typo 2019-06-06 08:05:16 +03:00
SUPPORT.md Split support into SUPPORT.md 2018-04-25 14:55:09 +01:00
build.sbt Fix typo 2019-07-29 12:45:22 -07:00
reset.sh 1.0.3-SNAPSHOT 2017-09-16 15:52:58 -04:00
sbt-allsources.sh Bump underlying modules to latest 2017-03-23 12:41:24 -04:00
server.md setting query is "sbt/setting" 2017-10-03 01:45:06 -04:00

README.md

Build Status Latest version Gitter Chat

sbt

sbt is a build tool for Scala, Java, and more.

For general documentation, see http://www.scala-sbt.org/.

sbt 1.x

This is the 1.x series of sbt. The source code of sbt is split across several GitHub repositories, including this one.

  • sbt/io hosts sbt.io module.
  • sbt/util hosts a collection of internally used modules.
  • sbt/librarymanagement hosts sbt.librarymanagement module that wraps Ivy.
  • sbt/zinc hosts Zinc, an incremental compiler for Scala.
  • sbt/sbt, this repository hosts modules that implements the build tool.
  • Setup: Describes getting started with the latest binary release.
  • FAQ: Explains how to get help and more.
  • sbt/sbt-zero-seven: hosts sbt 0.7.7 and earlier versions

Issues and Pull Requests

Please read CONTRIBUTING carefully before opening a GitHub Issue.

The short version: try searching or asking on StackOverflow.

license

See LICENSE.