Commit Graph

5624 Commits

Author SHA1 Message Date
Bardur Arantsson 5beb336dfb Add gitter badge to README 2017-06-02 20:16:26 +02:00
Bardur Arantsson 260d70f436 Update README.md
Remove link to long-dead mailing list.
2017-06-02 19:22:52 +02:00
Dale Wijnand 50ed5ee8fe Link Johannes 2017-05-31 17:48:48 +02:00
eugene yokota 65f5ec5986 Merge pull request #3236 from eed3si9n/wip/notes
sbt 1.0.0-M6 notes
2017-05-31 17:43:02 +02:00
Eugene Yokota adb92f6bd9 sbt 1.0.0-M6 notes 2017-05-31 03:56:00 -04:00
eugene yokota d631d7e918 Merge pull request #3224 from eed3si9n/fport/3155
[fport] ScalaTest nested suites reported in JUnit XML reports as  "(It is not a test)"
2017-05-30 10:37:42 -04:00
Eugene Yokota d952dbb7ba Fix build to publish M6 2017-05-30 02:44:13 -04:00
eugene yokota 6e1e6ea384 Merge pull request #3228 from eed3si9n/wip/bump3
Adjust to Zinc and lm changes
2017-05-30 01:49:59 -04:00
Eugene Yokota 03c9b648fb Adjust to Zinc and lm changes 2017-05-30 00:59:43 -04:00
eugene yokota 3b92421d66 Merge pull request #3233 from eed3si9n/wip/cachedupdate
Fix cached update task
2017-05-29 18:27:41 -04:00
Eugene Yokota 3690ff193c Fix cached update task
Fixes sbt/sbt#3226

One of the checks that the cached update task performs is called `depsUpdated`, which checks if the subproject dependencies have been thawed out of cache of now.
For this to function correctly, when we thaw the `UpdateReport` from JSON, we need to mark the report as cached. This was done subtley in sbt 0.13 for sbinary (https://github.com/sbt/sbt-zero-thirteen/blob/v0.13.15/main/actions/src/main/scala/sbt/CacheIvy.scala#L66-L67).
2017-05-29 17:14:52 -04:00
eugene yokota 13ec092be3 Merge pull request #3225 from scalacenter/improvements-dsl-checks
[sbt 1.0] Add missing .value DSL check and other improvements
2017-05-29 13:55:21 -04:00
jvican c85fb95851
Remove unnecessary infra for .value DSL check 2017-05-28 18:36:14 +02:00
jvican 6a31251a01
Add tests that check `sbtUnchecked` is respected 2017-05-28 18:31:45 +02:00
jvican b017eaee39
Support DSL detection for nested ifs and anons
Before, we were not preserving the value `insideXXX`. This commit makes
sure that we handle much more complex scenarios and we report them
successfully. Have a look at the tests.
2017-05-28 18:31:44 +02:00
jvican ded281b5c2
Add missing .value DSL check
The missing .value analysis is dumb on purpose because it's expensive.

Detecting valid use cases of idents whose type is an sbt key is
difficult and dangerous because we may miss some corner cases. Instead,
we report on the easiest cases in which we are certain that the user
does not want to have a stale key reference. Those are idents in the rhs
of val definitions with `_` as name and idents in statement position
inside blocks.

In the future, we can cover all val definitions no matter what their
name is. Unfortunately, doing so will come at the cost of speed: we have
to run the unused name analysis in `TypeDiagnostics` and expose it from
the power context in `ContextUtil`.

This is good enough for now. If users express interest in having a
smarter analysis, we can always consider trying the unused name
analysis. I am not sure how slow it will be -- hopefully it won't be
that much.
2017-05-28 18:08:58 +02:00
eugene yokota 9fc9304638 Merge pull request #3223 from eed3si9n/fport/3153
[fport] Remove the "hit [ENTER] to switch to interactive mode" feature
2017-05-27 01:12:15 -04:00
eugene yokota 4d3b910a19 Merge pull request #3221 from eed3si9n/fport/3133
[fport] Port sbt-cross-building's ^ and ^^ commands
2017-05-27 01:12:00 -04:00
James Koch fe72a6e11d Issue #3154 - ScalaTest nested suites reported in JUnit XML reports as "(It is not a test)". 2017-05-27 00:18:40 -04:00
eugene yokota acf4a5ffc2 Merge pull request #3220 from eed3si9n/fport/3135
[fport] Fix += interference with sbt-buildinfo
2017-05-27 00:15:32 -04:00
Eugene Yokota 0e979b4a3a Port sbt-cross-building's ^ and ^^ commands
This ports sbt-cross-building's cross (`^`) and switch (`^^`) commands.
Instead of making it a plugin, the default settings are now changed
to use `sbtVersion in pluginCrossBuild` for the sbt dependency.
2017-05-27 00:15:03 -04:00
eugene yokota fd129efc9d Merge pull request #3222 from eed3si9n/fport/3147
[fport] Notify users about shell only if compile is present
2017-05-26 23:37:36 -04:00
eugene yokota ba1fe56fbd Merge pull request #3219 from eed3si9n/fport/3134
[fport] Ignore ZipException in cache
2017-05-26 22:34:59 -04:00
Dale Wijnand e4be5f4a09 Remove the "hit [ENTER] to switch to interactive mode" feature
In sbt 0.13.15, in addition to notifying the user about the existence of
sbt's shell, a feature was added to allow the user to switch to sbt's
shell - a more pro-active approach to just displaying a message.

Unfortunately sbt is often unintentionally invoked in shell scripts in
"interactive mode" when no interaction is expected by, for exmaple,
invoking `sbt package` instead of `sbt package < /dev/null`. In that
case hitting [ENTER] would silently trigger sbt to run its shell,
easily wrecking the script. In addition to that I was unhappy with the
implementation as it created a tight coupling between sbt's command
processing abstraction to sbt's shell command.

If you want to stay in sbt's shell after running a task like `package`
then invoke sbt like so:

    sbt package shell

Fixes #3091
2017-05-26 21:42:41 -04:00
Dale Wijnand b54c0ff059 Notify users about shell only if compile is present
This is a change in strategy.

The motivation is the need to find a good balance between:

  + informing the uninformed that would benefit from this information, &
  + not spamming the already informed

Making it dependent on "compile" being present in remainingCommands will
probably make it trigger for, for example, Maven users who are used to
running "mvn compile" and always run "sbt compile", and who therefore
are unneccesarily suffering terribly slow compile speeds by starting up
the jvm and sbt every time.

Fixes #3091
Fixes #3097
2017-05-26 21:33:49 -04:00
Eugene Yokota bfc2d85d54 Fix += interference with sbt-buildinfo
The macro pattern match was too general. This makes it tighter.

Fixes #3132
2017-05-26 21:04:33 -04:00
eugene yokota bb16c7b068 Merge pull request #3218 from eed3si9n/wip/restligeist
Fix restligeist macro
2017-05-26 21:03:06 -04:00
Eugene Yokota cfbff070e0 Ignore ZipException in cache
Fixes #3050
2017-05-26 21:02:41 -04:00
Eugene Yokota 5dc46e3cf2 fix restligeist macro
Fixes sbt/sbt#3157

Before:

    PgpSettings.scala:99: exception during macro expansion:
    [error] java.lang.RuntimeException: Unexpected macro application tree (class scala.reflect.internal.Trees$Apply): PgpKeys.pgpStaticContext.<<=(sbt.this.Scoped.t2ToApp2[sbt.File, sbt.File](scala.Tuple2.apply[sbt.SettingKey[sbt.File], sbt.SettingKey[sbt.File]](PgpKeys.pgpPublicRing, PgpKeys.pgpSecretRing)).apply[com.jsuereth.pgp.cli.PgpStaticContext]({
    [error]   ((publicKeyRingFile: sbt.File, secretKeyRingFile: sbt.File) => SbtPgpStaticContext.apply(publicKeyRingFile, secretKeyRingFile))

After:

    build.sbt:18: error: `<<=` operator is removed. Use `key := { x.value }` or `key ~= (old => { newValue })`.
    See http://www.scala-sbt.org/1.0/docs/Migrating-from-sbt-012x.html
        publishLocal <<= foo // publishLocal.dependsOn(foo)
                     ^
    [error] sbt.compiler.EvalException: Type error in expression
2017-05-26 01:03:26 -04:00
Eugene Yokota 06c5ef4208 fix build 2017-05-26 00:59:49 -04:00
eugene yokota 239280f137 Merge pull request #3216 from scalacenter/macro-usability-improvements
Add first round of DSL checks to sbt
2017-05-25 14:30:40 -04:00
jvican bd59f64727
Rename `sbt.unchecked` to `sbt.sbtUnchecked`
As per Eugene's suggestion.
2017-05-25 19:05:27 +02:00
jvican 7b8e8cadf4
Execute macro tests in Travis 2017-05-25 18:39:24 +02:00
jvican ca3acc4e52
Improve if check and prohibit value inside anon
This commit does the following things:

* Removes the boolean from the instance context passes to the linter.
* Prohibits the use of value inside anonymous functions.
* Improves the previous check of `value` inside if.

The improvements have occurred thanks to the fix of an oversight in the
traverser. As a result, several implementation of tasks have been
rewritten because of new compilation failures by both checks.

Note that the new check that prohibits the use of value inside anonymous
functions ignores all the functions whose parameters have been
synthesized by scalac (that can happen in a number of different
scenarios, like for comprehensions). Other scripted tests have also been
fixed.

Running `.value` inside an anonymous function yields the following
error:

```
[error] /data/rw/code/scala/sbt/main-settings/src/test/scala/sbt/std/TaskPosSpec.scala:50:24: The evaluation of `foo` inside an anonymous function is prohibited.
[error]
[error] Problem: Task invocations inside anonymous functions are evaluated independently of whether the anonymous function is invoked or not.
[error]
[error] Solution:
[error]   1. Make `foo` evaluation explicit outside of the function body if you don't care about its evaluation.
[error]   2. Use a dynamic task to evaluate `foo` and pass that value as a parameter to an anonymous function.
[error]
[error]       val anon = () => foo.value + " "
[error]                        ^
```
2017-05-25 17:21:29 +02:00
jvican 41dce9e568
Make sure that macro linter doesn't fail spuriously 2017-05-25 15:33:06 +02:00
jvican 8de2bfe461
Fix error message 2017-05-25 15:33:06 +02:00
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
jvican b4299e7f34
Add check of task invocation inside `if`
This commit adds the first version of the checker that will tell users
if they are doing something wrong.

The first version warns any user that write `.value` inside an if
expression.

As the test integration is not yet working correctly and messages are
swallowed, we have to println to get info from the test.
2017-05-24 17:27:18 +02:00
jvican 5b7180cfa7
Reorganize test structure for `mainSettings` 2017-05-24 11:27:04 +02:00
jvican 2692bec21d
Reformat sbt source (minor changes) 2017-05-24 11:17:45 +02:00
jvican fd4bf0e635
Replace previous scalafmt plugin by neo-scalafmt
The previous scalafmt plugin had two problems:

* Caching with Coursier did not work correctly
* It failed after the upgrade to 1.0 in my computer (from a clean fork):

```
[error] (testingProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$
[error] (runProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$
[error] (taskProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$
[error] (stdTaskProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$
[error] (actionsProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$
[error] (protocolProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$
[error] (commandProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$
[error] (mainSettingsProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$
[error] (mainProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$
[error] (sbtProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$
[error] (scriptedPluginProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$
[error] (scriptedSbtProj/compile:scalafmtInc) java.lang.NoClassDefFoundError: Could not initialize class scala.meta.package$
[error] Total time: 19 s, completed May 24, 2017 10:44:56 AM
```

This commit replaces the previous scalafmt integration by the one
created by Lucidsoftware, big shoutout! (/cc @pauldraper)

https://github.com/lucidsoftware/neo-sbt-scalafmt
2017-05-24 11:15:22 +02:00
jvican e846f72ff3
Tell neg test suite the classpath via sbt 2017-05-24 10:27:51 +02:00
jvican 03daae49e2
Add test util to check neg macro tests 2017-05-24 10:21:52 +02:00
eugene yokota 88b2e84559 Merge pull request #3211 from scalacenter/move-sbt-util-second-attempt
Move `util-appmacro` to sbt as `core-macros`
2017-05-23 22:05:23 -04:00
jvican 10c737ae20
Move to `core-macros` and depend on it 2017-05-24 00:16:26 +02:00
jvican d2f019a47a
Reformat all util-appmacro 2017-05-24 00:16:23 +02:00
jvican ed38fcd695
Move `util-appmacro` to sbt as `core-macros`
This commit moves everything behind the old util-appmacro over to
sbt/sbt.

appmacro has been renamed as core-macros. It is indeed the project
that defines the main logic to manipulate macros, and defines interfaces
that are then implemented by main-settings. Because of this strong
relationship between these two modules, I find that they have to stay
together and be able to be modified in one commit. I've realised this
while hacking on the macro changes for the usability of sbt.

The reason for this change is because the logic of this module is really
tight to the implementation of sbt and, I would even say, essentially
define the sbt DSL.
2017-05-24 00:16:21 +02:00
jvican db88e89c42
Merge HEAD, branch 'move-util-2' of ../sbt-util into move-sbt-util-second-attempt 2017-05-24 00:13:52 +02:00
Dale Wijnand 5e585e50da Merge pull request #3200 from eed3si9n/wip/testlog2
Fixes content log not showing up on test task
2017-05-19 07:55:24 +01:00
Eugene Yokota 2b5637270a update TestFramework
- update reset.sh for debugging
- use Vector around TestFramework
- unbind existing appdenders from newLog
- register string codec for TestStringEvent
2017-05-19 00:16:19 -04:00