Commit Graph

312 Commits

Author SHA1 Message Date
João Ferreira fe045bfa12 remove unused comment 2024-10-09 11:04:47 +01:00
João Ferreira 3eb2d66b0f reenable some tests 2024-10-09 09:57:08 +01:00
xuwei-k cfb9ffea95 remove deprecated `[this]` qualifier
https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
2024-10-03 21:16:48 +09:00
Adrien Piquerez 31710c0879 Reduce allocation of Action.Mapped
For a tuple (t1, t2, ..., tn) of tasks we instantiate a unique Mapped instead of many
Mapped(t1, Mapped(t2, Mapped(...))
2024-10-02 15:54:20 +02:00
Adrien Piquerez e3449fff02 Reduce instances of Init.Apply 2024-10-02 11:05:37 +02:00
adpi2 a4ef38c5da
Merge pull request #7708 from adpi2/2.x-fix-7706
[2.x] Fix loading of `ScalaJSPlugin` in `ProjectMatrix`
2024-09-30 15:06:34 +02:00
Adrien Piquerez be04ad552d Use projectMatrix caller to resolve plugins 2024-09-30 14:01:46 +02:00
Adrien Piquerez 56416901cf Add back `dependsOn` on inputTask 2024-09-30 14:00:08 +02:00
Eugene Yokota 5684a842c3 refactor: Remove sbt 0.13 `in` methods
**Problem**
See https://www.scala-sbt.org/1.x/docs/Migrating-from-sbt-013x.html#Migrating+to+slash+syntax

We should remove `scalacOptions in (Compile, console)` notation. This was deprecated in https://eed3si9n.com/sbt-1.5.0.

**Solution**
This renames `in` to `rescope` for internal usage, and ports the usages to slash.
2024-09-28 19:19:58 -04:00
Adrien Piquerez eda3a87e76 Resolve conflict between BuildSyntax.dependsOn and Scoped.dependsOn 2024-09-25 16:43:45 +02:00
Adrien Piquerez 860f462f2f Add dependsOn on Initialize[Task[A]] 2024-09-25 15:32:04 +02:00
Adrien Piquerez f08f272d23 [2.x] Fix scripted cache tests 2024-09-18 10:28:11 +02:00
Adrien Piquerez b59856bcba Merge sbt-projectmatrix 2024-09-17 17:02:30 +02:00
xuwei-k 7279f659e0 Update .scalafmt.conf. re-format 2024-09-07 16:37:49 +09:00
Eugene Yokota eb9a507419 Refactor Def.declareOutputDirectory to return vf 2024-08-18 12:57:29 -04:00
Eugene Yokota 987ab5f214 Add Def.declareOutputDirectory function 2024-08-18 12:57:29 -04:00
Eugene Yokota c81d269ed2 Merge branch '1.10.x' into wip/merge-1.10.x 2024-05-07 04:39:25 -04:00
Adrien Piquerez 2e439cab1e [2.x] report cache errors
Report a cache error if the output file of a task is not cacheable
2024-04-24 10:41:56 +02:00
Adrien Piquerez 7c51ba2f64 Revert "Use fileConverter in cacheStore" 2024-04-17 09:30:44 +02:00
Eugene Yokota 86cf7c3a0c Remote caching support
This implements Bazel-compat remote caching support via a plugin.
2024-04-11 13:55:29 +02:00
Adrien Piquerez ab1aa6d001 Fix todos in actions/compile-clean 2024-04-09 15:33:22 +02:00
Adrien Piquerez 85fcb014f0 Fix data race to remote cache on classpath analyses
The attributed classpath should point to the existing analysis file in the target folder to avoid data racing to the remote cache.
2024-04-08 16:34:18 +02:00
Adrien Piquerez 654d35d1ba Fix triggeredBy and runBefore 2024-04-02 17:47:48 +02:00
Adrien Piquerez 0005705eb6 Fix += on sourceGenerators 2024-03-27 14:41:24 +01:00
Adrien Piquerez b5afcf8a0c Fix server completion tests 2024-03-19 17:06:09 +01:00
Adrien Piquerez 12e9267e1e Remove more unused 2024-03-05 15:25:25 +01:00
Adrien Piquerez c15a4031a9 Fix or mute warnings 2024-03-05 10:39:00 +01:00
Adrien Piquerez 144b86e32e fix tag of InputTask 2024-02-12 15:28:57 +01:00
Adrien Piquerez 739dedb017 Remove usage of Manifest in Structure.scala 2024-02-12 15:22:09 +01:00
adpi2 64be877549
Merge pull request #7491 from adpi2/misc-cleanup
[2.x] Miscellaneous cleanup
2024-02-08 17:42:35 +01:00
Eugene Yokota 63ba90d198 Migrate postfix ops
**Problem**
There are a few places in the code that's using postfix ops.

**Solution**
This rewrites the expressions to use normal dot notaiton.
2024-02-07 11:40:45 -05:00
eugene yokota ecca26175e
[sbt 2.x] remote cache (#7464)
For the details about this PR, please see the blog post https://eed3si9n.com/sbt-remote-cache/.

* Add cache basics
* Refactor Attributed to use StringAttributeMap, which is Map[StringAttributeKey, String]
* Implement disk cache
* Rename Package to Pkg
* Virtualize packageBin
* Use HashedVirtualFileRef for packageBin
* Virtualize compile task
2024-02-07 10:34:06 -05:00
Adrien Piquerez ea4b38d1b1 Shorten fake task macro impl 2024-02-07 12:13:35 +01:00
Adrien Piquerez 7ac3cd321d Remove the unused ~> 2024-02-07 11:12:43 +01:00
Adrien Piquerez 10fc5da8b6 remove Composite and replace it with type lambda 2024-02-07 10:58:05 +01:00
Adrien Piquerez a15fb91c5c Remove AList 2023-12-13 14:01:57 +01:00
Adrien Piquerez 7ea0506736 Introduce TaskId to reduce abstraction around Execute 2023-11-28 14:26:52 +01:00
Eugene Yokota bde26f6c51 Communicate narrowing by adding case 2023-11-25 20:50:34 -05:00
Eugene Yokota e87e1d6e0d Update to Scalafmt 3.7.14 2023-11-25 01:08:17 -05:00
Julien Richard-Foy 72bfb3f45a Transfer copyright to Scala Center 2023-06-20 16:39:07 +02:00
Eugene Yokota f98c4fff3b Update modules 2023-04-30 00:56:11 -04:00
Eugene Yokota dbaa34bdac Interpret bare settings are common settings
See https://eed3si9n.com/simplifying-sbt-with-common-settings/

Problem
-------
The behavior of bare settings is confusing in a multi-project build.
This is partly due to the fact that to use `ThisBuild` scoping
the build user needs to be aware of the task implementation,
and know if the task is already defined at project level.

Solution
--------
This changes the interpretation of the baresettings to be common
settings, which works similar to the way `ThisBuild` behaves in sbt 1.x,
but since this would be a simple append at project-level, it should
work for any tasks or settings.
2023-03-11 17:02:07 -05:00
Eugene Yokota 84a5fcb035 Use extension method to encode the syntax 2023-01-18 00:50:30 -05:00
Eugene Yokota 2642ba30cc Fix InputKey 2023-01-15 23:50:30 -05:00
Eugene Yokota 193b47b49b Fix taskDyn 2023-01-15 23:50:30 -05:00
Eugene Yokota 9f5525c989 inline parameter removes let binding 2023-01-15 23:50:29 -05:00
Eugene Yokota fbc98ed72e Use ClassTag instead of Manifest 2023-01-15 23:50:29 -05:00
Eugene Yokota cba7a0efc3 Refactor to build mainProj 2023-01-15 23:48:11 -05:00
Eugene Yokota 100f1ac09c Use flatMapTask instead of taskDyn 2023-01-15 23:47:41 -05:00
Eugene Yokota e9490e203b Use Type to compare types instead of TypeRepr 2023-01-15 23:45:35 -05:00
Eugene Yokota 0ee7d11afe Migrate updateTask via tuple syntax 2023-01-15 23:45:35 -05:00
Eugene Yokota 0c6eb093ac Rename tuple syntax to use mapN 2023-01-15 23:45:35 -05:00
Eugene Yokota fe0de6ca30 Fix input task macro 2023-01-15 23:45:35 -05:00
Eugene Yokota d802c2ba04 valStart to change synthetic variable names 2023-01-15 23:45:35 -05:00
Eugene Yokota 73c7236c2c Refactor to use Type instead of TypeRepr 2023-01-15 23:45:35 -05:00
Eugene Yokota 61d4fe2d30 Implement input task helper Def.input 2023-01-15 23:45:35 -05:00
Eugene Yokota cec131f6ed Fix conditional task 2023-01-15 23:45:34 -05:00
Eugene Yokota 81a05430bd Split buildfile parsing to a subproject 2023-01-15 23:45:30 -05:00
Eugene Yokota 66fa46a912 Fix InputTask macro 2023-01-15 23:44:28 -05:00
Eugene Yokota c7fa4937ef Bump to Scala 3.1.3 2023-01-15 23:44:25 -05:00
Eugene Yokota f3dd2dff36 Starting input task 2023-01-15 23:43:59 -05:00
Eugene Yokota b715917d95 Inline append macros 2023-01-15 23:43:59 -05:00
Eugene Yokota a1e50f8a2e Append macros 2023-01-15 23:43:59 -05:00
Eugene Yokota 9c1e8abb91 transform can be an inline 2023-01-15 23:43:59 -05:00
Eugene Yokota 37f6ee6184 Setting macro 2023-01-15 23:43:59 -05:00
Eugene Yokota 6662dbad26 InputWrapper can be inline method 2023-01-15 23:43:59 -05:00
Eugene Yokota 340721c4a1 KeyMacro 2023-01-15 23:43:57 -05:00
David Gregory dd497063e5
Add Remove instances for Set and Map 2022-03-30 19:03:14 +01:00
eugene yokota b3aae681bf
Merge pull request #6711 from xuwei-k/fix-scala-2-13-warn
fix Scala 2.13 warnings
2021-11-14 21:53:57 -05:00
xuwei-k 535b15b83e fix Scala 2.13 warnings 2021-11-14 22:59:34 +09:00
xuwei-k aa8b1141f8 Update scalatest 2021-11-14 22:03:59 +09:00
Eugene Yokota 695261a068 Migrate most of the internal usage of in 2021-02-22 00:09:36 -05:00
Eugene Yokota 833024b1d9 `in` is no longer in
Ref https://github.com/sbt/sbt/pull/6309

This deprecates the sbt 0.13 style `key in (Compile, intask)` syntax.
2021-02-21 23:38:56 -05:00
Eugene Yokota 8f5759e48d Cross build to Scala 2.13 2021-01-10 20:24:05 -05:00
Eugene Yokota a6d03c819c Backtick the unicode letters in method 2021-01-10 14:21:50 -05:00
Ethan Atkins 78620cd902 Manage ansi codes and color codes separately
The ConsoleAppender formatEnabledInEnv field was being used both as an
indicator that ansi codes were supported and that color codes are
enabled. There are cases in which general ansi codes are not supported
but color codes are and these use cases need to be handled separately.
To make things more explicit, this commit adds isColorEnabled and
isAnsiSupported to the Terminal companion object so that we can be more
specific about what the requirements are (general ansi escape codes or
just colors). There are a few cases in ConsoleAppender itself where
formatEnabledInEnv was used to set flags for both color and ansi codes.
When that is the case, we use Terminal.isAnsiSupported because when that
is true, colors should at least work but there are terminals that
support color but not general ansi escape codes.
2020-10-21 08:01:12 -07:00
Eugene Yokota c85e5b8bc0 Upgrade scala version to 2.12.12
This introduces `Def.unit(...)` to workaround the pure expression does nothing warning.
2020-08-11 23:33:12 -04:00
Eugene Yokota 002f97cae7 Build pipelining
Ref https://github.com/sbt/zinc/pull/744

This implements `ThisBuild / usePipelining`, which configures subproject pipelining available from Zinc 1.4.0.

The basic idea is to start subproject compilation as soon as pickle JARs (early output) becomes available. This is in part enabled by Scala compiler's new flags `-Ypickle-java` and `-Ypickle-write`.

The other part of magic is the use of `Def.promise`:

```
earlyOutputPing := Def.promise[Boolean],
```

This notifies `compileEarly` task, which to the rest of the tasks would look like a normal task but in fact it is promise-blocked. In other words, without calling full `compile` task together, `compileEarly` will never return, forever waiting for the `earlyOutputPing`.
2020-08-06 02:31:01 -04:00
Ethan Atkins ba345dd797 Add multi-client ui to server
This commit makes it possible for the sbt server to render the same ui
to multiple clients. The network client ui should look nearly identical
to the console ui except for the log messages about the experimental
client.

The way that it works is that it associates a ui thread with each
terminal. Whenever a command starts or completes, callbacks are invoked
on the various channels to update their ui state. For example, if there
are two clients and one of them runs compile, then the prompt is changed
from AskUser to Running for the terminal that initiated the command
while the other client remains in the AskUser state. Whenever the client
changes uses ui states, the existing thread is terminated if it is
running and a new thread is begun.

The UITask formalizes this process. It is based on the AskUser class
from older versions of sbt. In fact, there is an AskUserTask which is
very similar. It uses jline to read input from the terminal (which could
be a network terminal). When it gets a line, it submits it to the
CommandExchange and exits. Once the next command is run (which may or
may not be the command it submitted), the ui state will be reset.

The debug, info, warn and error commands should work with the multi
client ui. When run, they set the log level globally, not just for the
client that set the level.
2020-06-24 19:40:17 -07:00
Eugene Yokota 9821b83048 Forward type to the conditional tasks to fix Seq[Nothing]
Fixes https://github.com/sbt/sbt/issues/5625
2020-06-17 18:08:59 -04:00
eugene yokota 2b557851ca
Merge pull request #5041 from jsoref/https
Https
2020-06-14 17:34:58 -04:00
eugene yokota 975e3db43e
Merge pull request #5558 from eed3si9n/wip/selective
Selective functor
2020-06-10 17:39:13 -04:00
Eugene Yokota b78e4f0919 implement Def.promise
This adds `Def.promise` a facility that wraps `scala.concurrent.Promise`. Project layer, there's an implicit for task-that-returns-promise (`Def.Initialize[Task[PromiseWrap[A]]]`) that would inject `await` method, which returns a task. This is a special task that is tagged with `Tags.Sentinel` so that it will bypass the concurrent restrictions. Since there's no CPU- or IO-bound work, this should be ok.

The purpose of this promise for long-running task to communicate with another task midway.
2020-06-10 15:16:25 -04:00
Eugene Yokota b43f663b0e Automatic conversion to Def.taskIf
When `Def.task`, `:=`, `+=` etc contains `if` and only `if` expression automatically treat it as a conditional task even if the else clause contains `.value`.
2020-05-19 15:02:57 -04:00
Eugene Yokota 45e8426d27 def taskIf[A](a: A): Initialize[Task[A]]
Make `Def.taskIf` accept pure `A` type, as opposed to `Def.task { ... }`.
2020-05-17 23:44:35 -04:00
Eugene Yokota c6f62293f1 Def.taskIf macro
Def.taskIf accepts an if-expression or a block ending in an if-expression.
2020-05-17 23:36:04 -04:00
Eugene Yokota 2feecf8a1f Selective functor
This implements Selective functor for `Either[A, B]` "task" (`Initialize[Task[Either[A, B]]]`).
The selective functor allows an encoding of if-expression:

```
  def ifS[A](
      x: Def.Initialize[Task[Boolean]]
  )(t: Def.Initialize[Task[A]])(e: Def.Initialize[Task[A]]): Def.Initialize[Task[A]]
```

The benefit of this approach is that task dependencies are still visible to inspect command.
2020-05-17 23:36:04 -04:00
eugene yokota 0b12862caf
Merge pull request #5439 from dwijnand/introduce-Taskable
Introduce Taskable & toTaskable
2020-02-28 10:43:16 -05:00
eugene yokota 9c384dca15
Merge pull request #5435 from dwijnand/tweak-Def.displayRelative
Tweak Def.displayRelative
2020-02-28 09:57:04 -05:00
Dale Wijnand 23702b6432 Add toTaskable to Init/+Task, for tuple syntax 2020-02-17 12:22:53 +00:00
Dale Wijnand 722022ae97 Add conversions from Init/+Task to Taskable 2020-02-17 12:22:53 +00:00
Dale Wijnand fdfdd1ca47 Extract Taskable from ScopedTaskable 2020-02-17 12:22:53 +00:00
Dale Wijnand 2608f8ade6 Document parts of AList & components of TupleSyntax
Also, extract the AList.SplitK type lambda helper for call-site reuse.
2020-02-17 07:15:37 +00:00
Dale Wijnand c5b684984c Tweak Def.displayRelative
My driving use case was LocalProject: it should display the same as a
fully resolved ProjectRef.  Similarly ThisBuild should display as such.
2020-02-15 17:17:03 +00:00
Dale Wijnand 4635af182a Add some tests around Def.displayRelative2 2020-02-15 17:17:03 +00:00
Ethan Atkins ae4d3aecb8 Explicitly set scripted and server test classpath
This commit makes it so that the scalaVersion, sbtVersion and classpath
are always passed in as parameters to any method that creates an sbt
server -- either for scripted or for the sbt server tests. By making
that change, I was able to change the implementation of scripted in the
sbt project to use publishLocalBin instead of publishLocal. This makes
the scripted tests start much faster (doc alone can easily take 30
second) with messing with the build to exclude slow tasks from
publishLocal.

As part of this change, I removed the test dependency on scriptedSbtRedux for
sbtProj and instead had scriptedSbtRedux depend on sbtProj. This allowed
me to remove some messy LocalProject logic in the resourceGenerators for
scriptedSbtReduxProj. I also had to remove a number of imports in the
scriptedSbtReduxProj because the definitions available in the sbt
package object became available.

I also removed the dependency on sbt-buildinfo and instead pass the
values from the build into test classes using scalatest properties. I
ran into a number of minor issues with the build info plugin, namely
that I couldn't get fullClasspathAsJars to reliably run as a BuildInfo
key. It also is somewhat more clear to me to just rely on the built in
scalatest functionality. The big drawback is that the scalatest
properties can only be strings, but that restriction isn't really a
problem here (strangely the TestData structure has a field configMap
which is effectively Map[String, Any] but Any is actually always String
given how the TestData is created as part of framework initialization.

Since scripted no longer publishes, scriptedUnpublished is now
effectively an alias for scripted.

To get publishLocalBin working, I had to copy private code from
IvyXml.scala into PublishBinPlugin. Once we publish a new version of
sbt, we can remove the copied code and invoke IvyXml.makeIvyXmlBefore
directly.
2020-01-19 09:04:26 -08:00
Eugene Yokota 54b3405f42 apply -Yno-lub
To demonstrate [-Yno-lub](http://eed3si9n.com/stricter-scala-with-ynolub), this shows the code changes that removes lubing (Not all subprojects are done).

After I made the changes, I switched the Scala back to normal 2.12.10.
2019-10-13 23:46:23 -04:00
Josh Soref c9d5cbe808 https://www.scala-sbt.org 2019-09-05 14:11:13 -04:00
Ethan Atkins 09f4fcf94b Add test case and scaladoc 2019-08-19 11:49:09 -07:00
Ethan Atkins 8fbf1907ce Allow custom show for a scope
I am writing a plugin that uses mangled task keys that are very hard to
read. It is helpful to be able to override the show config for these
scopes so that they look reasonable in supershell and in error
reporting.
2019-08-19 11:23:43 -07:00