sbt, the interactive build tool
Go to file
jvican 2b12721a68
Add fully-fledged macro check for value inside if
`.value` inside the if of a regular task is unsafe. The wrapping task
will always execute the value, no matter what the if predicate yields.

This commit adds the infrastructure to lint code for every sbt DSL
macro. It also adds example of neg tests that check that the DSL checks
are in place.

The sbt checks yield error for this specific case because we may want to
explore changing this behaviour in the future. The solutions to this are
straightforward and explained in the error message, that looks like
this:

```
EXPECTED: The evaluation of `fooNeg` happens always inside a regular task.

PROBLEM: `fooNeg` is inside the if expression of a regular task.
  Regular tasks always evaluate task inside the bodies of if expressions.

SOLUTION:
  1. If you only want to evaluate it when the if predicate is true, use a dynamic task.
  2. Otherwise, make the static evaluation explicit by evaluating `fooNeg` outside the if expression.
```

Aside from those solutions, this commit also adds a way to disable any
DSL check by using the new `sbt.unchecked` annotation. This annotation,
similar to `scala.annotation.unchecked` disables compiler output. In our
case, it will disable any task dsl check, making it silent.

Examples of positive checks have also been added.

There have been only two places in `Defaults.scala` where this check has
made compilation fail.

The first one is inside `allDependencies`. To ensure that we still have
static dependencies for `allDependencies`, I have hoisted up the value
invocation outside the if expression. We may want to explore adding a
dynamic task in the future, though. We are doing unnecessary work there.

The second one is inside `update` and is not important because it's not
exposed to the user. We use a `taskDyn`.
2017-05-25 15:33:00 +02:00
core-macros/src/main/scala/sbt/internal/util/appmacro Add fully-fledged macro check for value inside if 2017-05-25 15:33:00 +02:00
launch Add three slashes (u3) for file URI 2017-04-12 03:34:11 -04:00
licenses
main Add fully-fledged macro check for value inside if 2017-05-25 15:33:00 +02:00
main-actions/src update TestFramework 2017-05-19 00:16:19 -04:00
main-command/src/main Apply Scalafmt formatting 2017-04-21 04:48:31 -04:00
main-settings/src Add fully-fledged macro check for value inside if 2017-05-25 15:33:00 +02:00
notes Better toError migration notes [ci skip] 2017-05-16 10:21:14 +01:00
project Add fully-fledged macro check for value inside if 2017-05-25 15:33:00 +02:00
protocol/src/main Apply Scalafmt formatting 2017-04-21 04:48:31 -04:00
run migrate ForkOptions to Contraband 2017-05-12 05:22:08 -04:00
sbt/src Add fully-fledged macro check for value inside if 2017-05-25 15:33:00 +02:00
scripted migrate PluginTrigger and ProjectOrigin to Contraband (#3191) 2017-05-13 13:01:51 +01:00
src/main/conscript sbt 1.0 nightly 2017-01-16 11:43:37 -05:00
tasks Apply Scalafmt formatting 2017-04-21 04:48:31 -04:00
tasks-standard Apply Scalafmt formatting 2017-04-21 04:48:31 -04:00
testing update TestFramework 2017-05-19 00:16:19 -04:00
.gitattributes Added .gitattributes file. 2013-04-25 00:06:51 +08:00
.gitignore Reorganize test structure for `mainSettings` 2017-05-24 11:27:04 +02:00
.java-version Configure JVM 1.8 in .java-version 2016-10-07 08:48:23 -05:00
.scalafmt.conf format: off / format: on 2017-04-21 03:11:48 -04:00
.travis.yml Replace previous scalafmt plugin by neo-scalafmt 2017-05-24 11:15:22 +02:00
CONTRIBUTING.md update "Testing sbt plugins" url 2017-03-21 16:49:36 +09:00
ISSUE_TEMPLATE.md Add "Clean history" to contributing with links 2016-02-19 13:21:11 +00:00
LICENSE Update CONTRIBUTING.md 2014-04-14 12:16:06 -04:00
NOTICE Update CONTRIBUTING.md 2014-04-14 12:16:06 -04:00
PULL_REQUEST_TEMPLATE.md Add "Clean history" to contributing with links 2016-02-19 13:21:11 +00:00
README.md readme 2016-05-08 14:49:43 -04:00
build.sbt Reorganize test structure for `mainSettings` 2017-05-24 11:27:04 +02:00
reset.sh update TestFramework 2017-05-19 00:16:19 -04:00
sbt-allsources.sh Bump underlying modules to latest 2017-03-23 12:41:24 -04:00
server.md Update to Contraband 2017-01-06 11:27:06 -05:00

README.md

sbt

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

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

sbt 1.0.x

This is the 1.0.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 and sbt-dev.

license

See LICENSE.