Commit Graph

40 Commits

Author SHA1 Message Date
Eugene Yokota b965277edc fix: Fixes set command
**Problem**
Once set command fails, the error state carries over to the next.

**Solution**
Create a fresh driver with a fresh reporter.
2025-08-28 23:47:07 -04:00
Martin Duhem da0fa5388e
Support annotated definitions in build.sbt
Previously, sbt would fail to load build.sbt files when they included
annotated definitions because the parser would not correctly recognize
those definitions as such. In sbt 1.x, this used to be fine, because
there was little use for annotations in build.sbt.

Starting with sbt 2, whether caching should be enabled for a task key
can be controlled via annotations on the task key definition. Because
these can appear in build.sbt, support for annotations in build.sbt
becomes more important.

This patch enhances parsing of build.sbt by keeping the parsed trees
around so that the AST can be used to determine whether a given line
represents a setting or a definition, rather than relying on string
matching.
2025-08-11 10:33:22 +02:00
Martin Duhem 79dbcd2ff4
Support minus sign in project names
Previously, sbt would crash when attempting to load a build where
projects had minus signs (`-`) in their name.

For instance, when trying to load a project defined like this:

    lazy val `my-project` = project

After compilation, this definition looks somewhat like this

    val my$minusproject$lzy1 = ...

sbt was attempting to retrieve the original definition (without the $lzy
suffix) by taking the mangled name up to the first `$`. Unfortunately,
this approach does not work when the name includes special characters
like a minus sign, because these will be prefixed with `$` as well. In
the current example, sbt would then try to find the member named `my`,
fail, and crash.

This patch fixes the issue by using the "underlying" name, which is the
name without the additional information.
2025-06-26 10:58:11 +02:00
xuwei-k 74a4abf049 add `using` if explicitly providing arguments to methods defined with `implicit` 2025-05-09 20:11:43 +09:00
Eugene Yokota 7714307329 fix: Port eval workaround for Windows 2025-05-05 15:30:38 -04:00
xuwei-k 5d660ab8b5 remove unnecessary `case`
- 3ca3633505/rules/src/main/scala/fix/RemoveParameterUntuplingCase.scala
- https://docs.scala-lang.org/scala3/reference/other-new-features/parameter-untupling.html
- https://docs.scala-lang.org/scala3/reference/other-new-features/parameter-untupling-spec.html
2025-02-22 08:48:29 +09:00
Josh Soref 613eb86447
Spelling (#8028)
* spelling: 1.x

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: a

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: aether

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: anymore

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: artifact

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: available

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: be

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: bridge

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: cannot

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: case-insensitive

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: checksum

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: class loads

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: contra

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: dependencies

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: dependency

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: dependent

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: deriveds

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: describes

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: early

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: enclosed

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: evaluation

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: excluding

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: execution

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: for

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: frequently

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: github

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: green

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: https://www

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: https

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: in-sourcing

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: include

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: incompatible

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: indefinitely

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: information

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: inputted

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: just

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: lastmodifiedtimes

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: latest

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: manifest

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: miscellaneous

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: more

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: neither

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: never

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: nonexistent

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: opted

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: outputting

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: params

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: performance

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: preceding

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: presentation

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: project

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: projects

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: protocol

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: related

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: representation

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: res

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: resolverlist

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: resolverset

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: response

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: returned

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: sbt_version

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: scalacheck

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: sentinels

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: separates

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: serves

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: should

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: significant

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: specifically

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: substitute

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: suppress

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: terminal

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: the

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: title

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: transitive

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: version

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: versions

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: want

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: wanting

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: whether

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* link: sbt Cached Resolution

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* link: Testing sbt plugins

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

---------

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2025-02-04 01:11:28 -05:00
Eugene Yokota 4a7e1097d9 fix: Fix build.sbt position
**Problem**
Compiler warnings and errors is not correct for build.sbt.

**Solution**
This adds line offset to the synthetic Scala file
so the original line position is displayed in the errors.
2025-01-20 01:35:54 -05:00
xuwei-k 13d6626564 update .scalafmt.conf. enforce new scala 3 syntax 2025-01-02 11:25:34 +09:00
Eugene Yokota 799bd65ba5 fix: Retry create directory
**Problem**
Files.createDirectories can fail.

**Solution**
Use IO version, which retries.
2024-12-29 03:18:18 -05:00
eugene yokota ebee3a86d9
[2.x] fix: concurrency control around Scala 3 compiler (#7938)
**Problem**
Early initialization thread throws ConcurrentModificationException.

**Solution**
This puts wraps it in Retry.
2024-12-10 08:30:17 -05:00
Eugene Yokota 70d7ddb258 Refactor slash syntax to mostly use methods
**Problem**
Slash syntax is currently implemented via a series of implicit
converters (Conversion), which is not nice, partly because
the behavior is difficult to follow.

**Solution**
This removes all the implicit converters and moves the slashes
into:
1. / methods under Reference for subproject scoping.
2. / methods under ScopeAxis with Reference type constraint
   for the initial Zero scoping.
3. Return RefThenConfig structure for intermediate config scoping.
4. / method under `Scoped`, which is base trait for the keys
   to implement task scoping e.g. `compile / scalacOptions`.
5. Extension methods for ConfigKey.
6. Extension methods for AttributeKey.
2024-11-25 04:54:40 -05:00
xuwei-k c5b7038f3a use `given` instead of `implicit val` 2024-11-17 17:35:23 +09:00
adpi2 4c66e5a907
Merge branch 'develop' into 2.x-fuse-info 2024-11-13 17:08:37 +01:00
Adrien Piquerez f4f185a1c1 Settings as a Map[ScopedKey[x], x]
Settings0 used to be a Map[Scope, AttributeMap], and is now a
Map[ScopedKey[x], x].
This is better because we don't need to decompose all ScopedKey[x]
into a Scope and an AttributeKey[x], for recomposing it back later,
which duplicates all ScopedKey[x]. It reduces the number of long-living
ScopedKey[x] by 8%, and the total number of instances by 1.4%.

Also it improves the performance of Settings0, which was responsible of
2.95% of the total CPU time, and is now responsible of 0.41%.
2024-11-13 12:25:31 +01:00
Adrien Piquerez 327d05e28f Remove unused Structure.taskToKey 2024-11-13 11:22:53 +01:00
Adrien Piquerez e5cedbe56b Fuse Info in Task to reduce instances 2024-11-12 17:05:20 +01:00
Eugene Yokota 56941dac04 refactor: Update Scala 3 syntax 2024-10-27 23:55:30 -04:00
Adrien Piquerez d0003bbb0f Fix Eval on Windows 2024-10-11 14:32:32 +02: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
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
Eugene Yokota c81d269ed2 Merge branch '1.10.x' into wip/merge-1.10.x 2024-05-07 04:39:25 -04:00
Adrien Piquerez 654d35d1ba Fix triggeredBy and runBefore 2024-04-02 17:47:48 +02:00
Adrien Piquerez e62984846b Re-implement BuildServerEvalReporter 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 5d0a0b7356 Uncomment EmbeddedXmlSpec 2024-03-05 10:09:22 +01:00
Adrien Piquerez 5425e066a0 Fix SbtRefactorings 2024-02-13 14:01:26 +01:00
Adrien Piquerez 739dedb017 Remove usage of Manifest in Structure.scala 2024-02-12 15:22:09 +01:00
Adrien Piquerez 013194c217 Rename to SbtParserErrorSpec 2024-02-08 13:29:15 +01:00
Adrien Piquerez 245d13575a Refactor xml test in ErrorSpec 2024-02-08 13:28:19 +01:00
Adrien Piquerez 135ab16b5c Remove outdated test in ErrorSpec 2024-02-08 13:21:04 +01:00
Adrien Piquerez 5990775a43 Fix test in ErrorSpec 2024-02-08 13:12: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
Adrien Piquerez 7ea0506736 Introduce TaskId to reduce abstraction around Execute 2023-11-28 14:26:52 +01:00
Eugene Yokota f8f8db9e58 Update to Scala 3.3.1 2023-11-25 15:50:50 -05:00
Eugene Yokota 8c2e4f936e Fix lazy val support
Problem
-------
By Typer phase it seems like lazy val is expanded out to
`def x(): Int` and synthetic `val x$lzy1`,
which results in NoSuchMethod `x$lzy1`.

Solution
--------
Assume the naming convention and grab the part before `$`.
2023-01-15 23:48:13 -05:00
Eugene Yokota 4f85c11e01 Some minor tweaks to get things moving 2023-01-15 23:48:13 -05:00
Eugene Yokota cba7a0efc3 Refactor to build mainProj 2023-01-15 23:48:11 -05:00
Eugene Yokota 81a05430bd Split buildfile parsing to a subproject 2023-01-15 23:45:30 -05:00