Commit Graph

529 Commits

Author SHA1 Message Date
Eugene Yokota 2e7d3fdf93 Support JDK 25 JEP-512/JEP-445 Main run
**Problem**
sbt currently does not support JDK 25 Main class. JDK 25 supports:
1. non-public main method
2. doesn't need Array[String] arg
3. doesn't have to be a static method

**Solution**
This updates Zinc, which supports new Main class detection.

In addition, this implements in-process run emulation support.
2025-09-28 01:51:24 -04:00
Aleksandra Zdrojowa 622994b40d use reverse topological order for configurations when resolving internal dependencies
- changes the classpath order for internal dependencies
- fix #8249
2025-09-01 16:47:44 +02:00
Eugene Yokota a18ed19cbc fix: Use JDK path, not JRE path
**Problem**
There are a few places where javaHome or java path is set,
using java.home system property. The problem is that it points to JRE,
not JDK, so it would break on Java compilation etc.

**Solution**
If the path ends with jre, go up one directory.
2025-03-03 02:31:44 -05:00
Eugene Yokota a75e847a08 refactor: Refactor response handler
**Problem**
The sbtn response handling code is relatively stragightforward,
but it's a bit messy.

**Solution**
This cleans it up a bit, similar to the style used by Unfiltered
back then (not sure how Unfiltered plans are written nowadays) by
expressing each event handling as a partial function, and composing them
together using `orElse`.
2025-02-09 18:17:02 -05:00
Eugene Yokota 55b1fdeddb fix: Fix Chrome tracing file
**Problem**
We changed the content of Chrome tracing file incorrectly
and renamed tid to tname.

**Solution**
1. This renames tname back to to tid.
2. To retain the fix to avoid Thread#getId, this calls
   either the JDK 8 way or the JDK 19 way reflectively.
2025-01-28 04:11:36 -05:00
Eugene Yokota 72c061a2a2 fix: Fixes glob in scripted
**Problem**
Absolute path handling regressed.

**Solution**
Create an absolute glob for expression starting with /.
2024-12-22 01:32:16 -05:00
Eugene Yokota d21b2d250a feat: Support glob expressions in scripted
**Problem**
It's currently not easy to write a scripted test that works on
both sbt 1.x and 2.x when you want to write exists test under target.

**Solution**
Since we can only use the file system (and not evaluate Scala version etc)
1. this implements glob expression support in `exists`, `absent`, and `delete`.
2. this also introduces `||` operator that would mean a or b.
2024-12-08 23:38:00 -05:00
Friendseeker b621db683c Remove jansi from WindowsInputStream 2024-11-07 19:15:13 -08:00
Friendseeker 828dc04808 Migrate all usages of `System.console == null` 2024-10-28 18:25:16 -07:00
Friendseeker 0e85726858 Use JNI to replace deprecated Jansi & JNA 2024-10-22 13:05:20 -07:00
kenji yoshida ee38417aff
update ErrorHandling.scala 2024-09-11 07:36:03 +09:00
Stefan Zeiger da79479ff7 Fix logging of raw strings
sbt passes raw string messages in `ConsoleAppenderFromLog4J` to `StringFormatterMessageFactory`. This is wrong because these strings are pre-formatted and should not be processed again for formatting. There is no way to pass parameters to them anyway. This causes problems when the raw strings contain characters that `StringFormatterMessageFactory` wants to interpret.

For example, when using `-Ystatistics`:

```
ERROR StatusConsoleListener Unable to format msg:   nscprofiling                : 1 spans, ()7.543ms (0.3%)
java.util.UnknownFormatConversionException: Conversion = ')'
at java.base/java.util.Formatter.checkText(Formatter.java:2732)
at java.base/java.util.Formatter.parse(Formatter.java:2718)
at java.base/java.util.Formatter.format(Formatter.java:2655)
at java.base/java.util.Formatter.format(Formatter.java:2609)
at java.base/java.lang.String.format(String.java:2938)
at org.apache.logging.log4j.message.StringFormattedMessage.formatMessage(StringFormattedMessage.java:121)
at org.apache.logging.log4j.message.StringFormattedMessage.getFormattedMessage(StringFormattedMessage.java:89)
at sbt.internal.util.Appender.$anonfun$appendMessage$1(ConsoleAppender.scala:522)
...
```
2024-05-02 18:31:23 +02:00
Matthias Kurz 2d7f087753
Add missing logger methods that take Java Supplier 2023-12-05 10:15:51 +01:00
Heikki Vesalainen c07ee8411e JLine 3.24.1 and JAnsi 2.4.0. 2023-11-01 21:25:24 +02:00
Martin Duhem f03320047e
Keep logger names in hash set
Previously, the list of logger names that have been created in a given
context with Log4J was being kept in a `Vector`. As a result, subsequent
calls to `logger` on a `Log4JLoggerContext` with the same logger name
would introduce duplicates in the list. Note that Log4J's logger
configuration would not allow duplicates, and only one configuration
object for a given logger name will exist. The duplicates in the list of
logger names are therefore unnecessary.

With this patch, the logger names will be kept in a `HashSet`.

Since the logger names are only used to remove the logger configurations
after the logger context is closed, and the logger configurations
contain no duplicates, removing duplicate logger names should not cause
any issue.
2023-09-25 17:40:12 +02:00
xuwei-k 6c032b8283 some trivial refactoring
- remove unused type params
- use `withFilter` if possible
- use `collectFirst` instead of `collect` and `headOption`
- use `length` instead of `size` if `Array` or `String`
- use `foreach` instead of `map`
2023-06-25 08:57:41 +09:00
xuwei-k 2edb4dcbb6 fix typo 2023-06-24 20:05:52 +09:00
Julien Richard-Foy 72bfb3f45a Transfer copyright to Scala Center 2023-06-20 16:39:07 +02:00
​Andrzej Ressel 4cf2b7269d Cache echoEnabled 2023-06-03 22:44:19 +02:00
Eugene Yokota 9d87f3f596 Add concrete impl for Action 2023-05-14 14:06:46 -04:00
Chris Kipp fa8dfd225d fix: get rid of the `FileChanges` abstraction
I don't believe this is actually needed. We can simplify the
`WorkspaceEdit` further and put together the mapping for `changes`
according to the LSP spec later on down the line. This will allow us to
remove the need for the `URI`, which is problematic.

closes #7252
2023-05-14 09:52:16 +02:00
eugene yokota cf6fac7692
Merge pull request #7242 from ckipp01/action
feat: add in `actions()` to `Problem`
2023-05-12 00:03:49 -04:00
Chris Kipp aeb168aa93 feat: add in `actions()` to `Problem`
This adds a new field into `xsbti.Problem` allowing for the compiler to
forward "actions" that can address diagnostics. The idea largely mimics
a very minimal `CodeAction` that can be found in the [LSP
Spec](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeAction)
in order to ensure it will work with a variety of difference clients
that use LSP, and those that don't. In the future the `WorkspaceEdit`
that was created here could also be expanded to handle more advanced
changes, aka resource operations, like creating/moving/deleting files.
For now we only focus on a small subset of these features.
2023-05-10 14:14:13 +02:00
Chris Kipp 300b770ea4 fix: deprecate misspelled diagnosticRelatedInforamation and add in a new one
Relates to https://github.com/sbt/sbt/discussions/7063
2023-05-08 13:38:15 +02:00
Eugene Yokota 51591bde5b Make new more interactive
If the terminal supports ANSI control sequence,
this displays the template list in an interactive way.
The focused template is rendered reversed,
and arrow key can be used to move the focus up/down.
2023-05-06 20:07:47 -04:00
Adrien Piquerez da4ce68142 Fix dead lock between LoggerContext and Terminal 2023-03-28 14:08:15 +02:00
Chris Kipp dadfee5846 fix: also include diagnosticCode and related info in InterfaceUtil
Looks like I missed this in https://github.com/sbt/sbt/pull/6874 and I
hit on it in Mill when I couldn't figure out why it was also empty, and
thanks to @adpi realized it was because of the `LoggedReporter` in zinc
not taking it into account. However before I can bump that this needs to
be bumped as well.

refs: https://github.com/lampepfl/dotty/issues/14904
2022-10-02 04:50:44 -04:00
Adrien Piquerez 634e8799e7 Catch ClosedChannelException in background job logger
We want the background job to stay alive even if its terminal
has been closed and we cannot write to it anymore
2022-08-05 14:45:38 +02:00
Adrien Piquerez 592086b889 Don't use ProxyTerminal in background job
If we use the ProxyTerminal in the background jobs, the logs
would be spread across different terminals, switching from active
client to active client. We want the logs to stick
to the client that started the job.
2022-08-04 16:48:13 +02:00
Adrien Piquerez 6bcda6684a Use BackgroundJobService context instead of MainLoop context
A new context is created and closed for each state of the MainLoop.
But the context of the backgroundJob must stay alive.
So we use a context that is owned by the BackgroundJobService.
It creates a new logger for each background job and cleans it when
the job stops.
2022-08-04 16:48:13 +02:00
Eugene Yokota 2462d5fbcf Fix proxyInputStream#available
proxyInputStream does not override available,
which broke sbt-site previewSite.
This fixes that.
2022-07-10 04:35:57 -04:00
eugene yokota 910ab1951f
Merge pull request #6846 from Nirvikalpa108/fix-deadlock
[1.7.x] Attempts to fix sbt#6810 - deadlock issue
2022-06-26 22:50:22 -04:00
Chris Kipp f90b09f1ee feat: update Problem to account for related information and code
This PR makes changes to the existing `xsbti.Problem` to account for an
optional diagnostic code that the compiler can return for a given
diagnostic and also related information.

Given a piece of code like:

```scala
try {}
```

You'll receive the following:

```
-- [E002] Syntax Warning: /Users/ckipp/Documents/scala-workspace/dotty-error-index/examples/002_EmptyCatchAndFinallyBlockID.scala:3:2
3 |  try {}
  |  ^^^^^^
  |  A try without catch or finally is equivalent to putting
  |  its body in a block; no exceptions are handled.
```

The `E002` here is the actual code. Right now there would be no
description.

Some diagnostics have multiple positions that they need to represent.
You can see an example of this
[here](lampepfl/dotty#14002) in Dotty with the
use of inlining. Instead of needing to rely on including all of that
information in the diagnostic message it can now be extracted out into
a `DiagnosticRelatedInformation`.

These changes reference the conversation in #6868
2022-04-12 11:13:19 +02:00
Amina Adewusi 020385d917 Attempts to fix sbt#6810 - deadlock issue 2022-03-18 17:23:30 +00:00
Amina Adewusi ca8fd354bd Fixes parsing command args quote problem
Fixes #6802.
2022-02-04 17:52:39 +00:00
tpetillot 4f9fe2af64 fix: propagate `InterruptedException` from JLine.readLine
Motivation:
Cannot exit from InteractionService.readLine

Modification:
Remove try/catch of InterruptedException mapped to None in JLine.readLine
2022-01-31 21:40:32 -05:00
David Francoeur a448b1caab
Load credentials from SBT_CREDENTIALS (#6724)
Load credentials from SBT_CREDENTIALS
Prefer sys.env to System.getenv
2021-11-27 02:44:49 -05:00
xuwei-k 5c90a84c72 SourcePositionMacro for Scala 3 2021-11-16 16:32:31 +09: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
Eric Peters c1ed109f89 Update MainAppender.defaulScreen to use passed in console arg #6678 2021-09-29 07:39:09 -07:00
Eric Peters 804bd4b8b5 Rename internal/util-logging/src/main/scala/sbt/internal/util/MainLogging.scala to MainAppender.scala to match contents 2021-09-29 07:34:20 -07:00
Amina Adewusi 696a19f5d7 Virtualize Sync.sync so it can be cached remotely for resources dir syncing
An alternative to https://github.com/sbt/sbt/pull/6554.
2021-07-31 18:23:30 +01:00
eugene yokota d3db8388b6
Merge branch 'develop' into fix-carriage-return 2021-06-20 18:07:29 -04:00
Eugene Yokota 8628f95e66 lazily initialize ProxyTerminal to SimpleTerminal
Problem
-------
Console.systemOut is hooked up to Terminal.get, which internally calls
ProxyTerminal, which lets us deffer the wiring of terminal to
activeTerminal. This mechanism allows us to swap out the terminal
capable of standard out forwarding for sbtn.
However, as it stands this breaks the contract of being able to use
Console.systemOut with wrapped inside of `Terminal.withStreams() {...}`.

Solution
--------
Check if `activeTerminal.get` returns `null`, and if so initialize it to
the conventional `Terminal.SimpleTerminal`, which behaves as expected.
2021-06-20 17:32:42 -04:00
Sebastian Alfers d339863041 Fix carriage return in supershell progress state 2021-06-20 15:41:59 +02:00
Adrien Piquerez bf29e2a908 Fix size of server running message 2021-02-24 17:31:28 +01:00
Eugene Yokota 22d12f6618 Use nowarn annotation 2021-02-06 22:31:47 -05:00
Eugene Yokota 61a077e3a6 Scala 2.12.13 2021-01-31 12:59:31 -05:00