Commit Graph

1755 Commits

Author SHA1 Message Date
jvican 0cc3cfb364
Synchronize with changes to Zinc logger API
https://github.com/sbt/zinc/pull/325
2017-07-14 14:32:53 +02:00
Guillaume Martres cfc8a85fdf Use the new Zinc main class detection
See https://github.com/sbt/zinc/pull/287 for details.
2017-07-10 23:15:08 +02:00
Dale Wijnand 9494967e05
Upgrade util/lm/zinc & config build for util modules
Welcome back home!
2017-07-07 12:11:59 +01:00
Eugene Yokota efa3b1d340
Bump to latest io, scalajson, sjsonnew, contraband, util, lm, zinc 2017-07-06 11:05:24 +01:00
Martin Duhem 0daca42c29 Adapt to use the new `WatchService`
This commit adapts `Watched` so that it supports the new `WatchService`
infrastructure introduced in sbt/io. The goal of this infrastructure is
to provide and API for and several implementations of services that
monitor changes to the file system.

The service to use to monitor the file system can be configured with the
key `watchService`.
2017-07-02 00:28:04 -04:00
eugene yokota 25d393bd8b Merge pull request #3281 from dwijnand/no-eval
Get rid of Eval
2017-06-28 16:32:31 -04:00
eugene yokota 249c1299a4 Merge pull request #3291 from dwijnand/import-tuple-enrichments
Move the tuple enrichments to sbt.TupleSyntax
2017-06-27 15:17:39 -04:00
eugene yokota 9d8bba31f8 Merge pull request #3293 from dwijnand/scala212FromSbtVersion1xx
Use Scala 2.12 for all sbt 1.x, not just 1.0.x
2017-06-27 15:15:06 -04:00
Dale Wijnand 27615b8fa8
Use Scala 2.12 for all sbt 1.x, not just 1.0.x 2017-06-27 14:13:16 +01:00
Dale Wijnand 0fe0de5fb3
Move the tuple enrichments into sbt.TupleSyntax
This undeprecates the syntax, but at the same times moves it out of
implicit scope, therefore requiring a 'import TupleSyntax._' to opt-in
to the old syntax.
2017-06-27 12:42:46 +01:00
Dale Wijnand 1193a48542
Get rid of Eval 2017-06-21 13:16:36 +01:00
Dale Wijnand 68b47a9dd1
Finish getting rid of delegates 2017-06-20 16:27:15 +01:00
Dale Wijnand 1247431a71
Format Eval-related code 2017-06-20 16:22:32 +01:00
Dale Wijnand 53f1e2a4da
Fixes due to universal equality and the introduction of the Exec wrapper 2017-06-20 14:03:56 +01:00
Dale Wijnand 73b45f6d30
Cleanup code paths related to "last" 2017-06-20 14:03:56 +01:00
Eugene Yokota f81598c6e9 Fixes test content logger dropping out, or displaying twice
Fixes #3117
2017-06-20 03:04:53 -04:00
kenji yoshida 260f6ee740 fix typo (#3246) 2017-06-04 00:28:22 +02:00
Eugene Yokota 03c9b648fb Adjust to Zinc and lm changes 2017-05-30 00:59:43 -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
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
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
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
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
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 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 2692bec21d
Reformat sbt source (minor changes) 2017-05-24 11:17:45 +02: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
eugene yokota d3ff3fb63a migrate PluginTrigger and ProjectOrigin to Contraband (#3191)
and move TestFramework to a non case class.
2017-05-13 13:01:51 +01:00
Eugene Yokota 3724277704 migrate ForkOptions to Contraband 2017-05-12 05:22:08 -04:00
eugene yokota b1a1d03009 Merge pull request #3180 from eed3si9n/wip/zero2
[sbt 1.0] Rename scope component Global to Zero (`in Global` stays the same)
2017-05-10 16:48:40 -04:00
jvican 9d260f68c7
Use `ConsoleReporter` if no reporter is found
This change is necessary in the cases where we have global
initialization issues that have no position, like:

```
[info] [error] scala.reflect.internal.MissingRequirementError: object scala in compiler mirror not found.
```

Before, it was failing with a `sys.error` exception. Now we will report
these issues with a console reporter that is not meant to be
thread-safe.
2017-05-10 21:40:01 +02:00
Eugene Yokota 4182249526 Add InteractionService from sbt-core-next
Fixes sbt/sbt#3167
2017-05-08 21:54:58 -04:00
Eugene Yokota 2082f37e2a Rename Global as scope component to Zero
Fixes #3178

While working on the Scopes and Scope Delegation document, I noticed that the term Global in sbt is used for two different meaning.

1. Universal fallback scope component `*`
2. An alias for GlobalScope

This disambiguates the two by renaming ScopeAxis instance to Zero.
Since this is mostly internal to sbt code, the impact to the user should be minimal.
2017-05-08 11:41:48 -04:00
eugene yokota 6cd3cd2323 Merge pull request #3149 from scalacenter/clean-update
Clean up `update` in `Defaults`
2017-05-05 11:03:18 -04:00
jvican 1252db6b4a
Address Eugene's feedback 2017-05-04 13:33:21 +02:00
jvican 818b8c85ae
Bump util to X11 and rename `SbtExclusionRule` 2017-05-03 12:42:16 +02:00
jvican e7b8cbfe01
Move `cachedUpdate` to new `DependencyResolver`
The `cachedUpdate` implementation does not need to be in `Defaults`
since it's not using any of the tasks/settings defined there, that's
`updateTask`'s job.

This commit moves the utilities required by `updateTask` to the
`sbt.internal.librarymanagement` namespace.
2017-04-28 10:31:45 +02:00
jvican 1c961e8814
Move `AltLibraryManagementCodec` to internal
This is an implementation detail that should not be exposed in `Defaults`.

It is therefore moved to `librarymanagement.internal`.
2017-04-28 10:31:33 +02:00
jvican 8fd40e56df
Ease `updateTask` and `cachedUpdate` maintenance
This commit does some changes to the implementation with the purpose of
making this code more readable. I find that this rewrite was necessary
as I was implementing the dependency lock file.
2017-04-27 15:14:42 +02:00
Eugene Yokota da046791e0 Apply Scalafmt formatting 2017-04-21 04:48:31 -04:00
Eugene Yokota 1ec7e8d975 format: off / format: on 2017-04-21 03:11:48 -04:00
jvican 5c48b11d3f Simplify and document `load`
This commit has two goals:

* Simplify the `load` API endpoints, removing the unused ones to shorten
  the surface of the API.
* Add documentation to the main `load` methods.
2017-04-21 01:09:06 -04:00
jvican d2a51d5085 Indent timing logs
Sbt has a feature to show timed logs for every operation at startup.
However, its output is cluttered and users cannot read how much time
single methods consume nor if they call other methods.

This commit improves the status quo by adding indentation.
2017-04-21 01:09:06 -04:00
jvican 9175193df3 Remove unused `pluginDefinitionLoader` methods
This commit reduces the complexity around `loadPluginDefinition` et al.
`pluginDefinitionLoader` is not used anywhere in sbt, so the extra
definitions are removed.

Both the implementation of `loadPluginDefinition` and
`pluginDefinitionLoader` are reduced to a bare minimum where the
components at hand (definition classpath, dependency classpath) are
properly defined.

Documentation to the three methods has been added.
2017-04-21 01:09:06 -04:00
jvican 90782b1cd0 Fix implementation of `LoadBuildConfiguration`
It mainly does three things:

* Clean up the implementation, removing unused values like
  `globalPluginDefs`.
* Make the implementation more readable.
* And the big one: Remove the creation of a classloader that we were
  instantiating but whose value we were throwing away. This has an impact
  in performance, but I'm yet to benchmark how much it is.
2017-04-21 01:09:06 -04:00
jvican 2f61114108
Avoid the use of `synchronized` while parsing
Previous commit used `synchronized` to ensure that the global reporter
was not reporting errors from other parsing sessions. Theoretically,
though, sbt could invoke parsing in parallel, so it's better to ensure
we remove the `synchronized` block, which could also be preventing some
JVM optimizations.

The following commit solves the issue by introducing a reporter id.

A reporter id is a unique identifier that is mapped to a reporter. Every
parsing session gets its own identifier, which then is reused for
recursive parsing. Error reports between recursive parses cannot collide
because the reporter is cleaned in `parse`.
2017-04-18 20:30:05 +02:00
jvican f482a6cf0d
Reuse the same global instance for parsing
The previous implementation was instantiating a toolbox to parse every
time it parsed a sbt file (and even recursively!!!).

This is inefficient and translates to instantiating a `ReflectGlobal`
every time we want to parse something.

This commit takes another approach:

1. It removes the dependency on `ReflectGlobal`.
2. It reuses the same `Global` and `Run` instances for parsing.

This is an efficient as it can get without doing a whole overhaul of it.
I think that in the future we may want to reimplement it to avoid the
recursive parsing to work around Scalac's bug.
2017-04-18 20:30:05 +02:00