Commit Graph

37 Commits

Author SHA1 Message Date
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
Eugene Yokota cb63de6574 Merge branch '1.10.x' into wip/merge-1.10.x 2025-02-10 02:43:30 -05:00
xuwei-k 13d6626564 update .scalafmt.conf. enforce new scala 3 syntax 2025-01-02 11:25:34 +09: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 c4aebf5744 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:40:27 -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
xuwei-k 4da8d942ce use extension instead of implicit 2024-11-17 07:38:40 +09:00
Eugene Yokota 56941dac04 refactor: Update Scala 3 syntax 2024-10-27 23:55:30 -04: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 c81d269ed2 Merge branch '1.10.x' into wip/merge-1.10.x 2024-05-07 04:39:25 -04:00
Adrien Piquerez 369e647008 Fix scala 2 compat with -Xsource:3 and scala-collection-compat 2024-03-05 13:32:15 +01:00
Adrien Piquerez c15a4031a9 Fix or mute warnings 2024-03-05 10:39:00 +01:00
Julien Richard-Foy 72bfb3f45a Transfer copyright to Scala Center 2023-06-20 16:39:07 +02:00
Eugene Yokota 50b062b795 Port util-logging 2023-01-15 23:40:57 -05:00
Amina Adewusi 97cdf21416 Remove log4j
WIP
2021-12-03 17:13:29 +00:00
xuwei-k 535b15b83e fix Scala 2.13 warnings 2021-11-14 22:59:34 +09:00
Ethan Atkins 2e9805b9d0 Add internal multi logger implementation
Prior to these changes, sbt was leaking large amounts of memory via
log4j appenders. sbt has an unusual use case for log4j because it
creates many ephemeral loggers while also having a global logger that is
supposed to work for the duration of the sbt session. There is a lot of
shared global state in log4j and properly cleaning up the ephemeral task
appenders would break global logging. This commit fixes the behavior by
introducing an alternate logging implementation. Users can still use the
old log4j logging implementation but it will be off by default. The
internal implementation is very simple: it just blocks the current
thread and writes to all of the appenders. Nevertheless, I found the
performance to be roughly identical to that of log4j in my sample
project. As an experiment, I did the appending on a thread pool and got
a significant performance improvement but I'll defer that to a later PR
since parallel io is harder to reason about.

Background: I was testing sbt performance in
https://github.com/jtjeferreira/sbt-multi-module-sample and noticed that
performance rapidly degraded after I ran compile a few times. I took a
heap dump and it became obvious that sbt was leaking console appenders.
Further investigation revealed that all of the leaking appenders in the
project were coming from task streams. This made me think that the fix
would be to track what loggers were created during task evaluation and
clear them out when task evaluation completed. That almost worked except
that log4j has an internal append only data structure containing logger
names. Since we create unique logger names for each run, that internal
data structure grew without bound. It looked like this could be worked
around by creating a new log4j Configuration (where that data structure
was stored) but while creating new configurations with each task runs
did fix the leak, it also broke global logging, which was using a
different configuration. At this point, I decided to write an alternate
implementation of the appender api where I could be sure that the
appenders were cleaned up without breaking global logging.

Implementation: I made ConsoleAppender a trait and made it no longer
extends log4j AbstractAppender. To do this, I had to remove the one
log4j specific method, append(LogEvent). ConsoleAppender now has a
method toLog4J that, in most cases, will return a log4j Appender that is
almost identical to the Appenders that we previously used. To manage
the loggers created during task evaluation, I introduce a new class,
LoggerContext. The LoggerContext determines which logging backend to use
and keeps track of what appenders and loggers have been created. We can
create a fresh LoggerContext before each task evaluation and clear it
out, cleaning up all of its resources after task evaluation concludes.

In order to make this work, there were many places where we need to
either pass in a LoggerContext or create a new one. The main magic is
happening in the `next(State)` method in Main. This is where we create a
new LoggerContext prior to command evaluation and clean it up after the
evaluation completes.

Users can toggle log4j using the new useLog4J key. They also can set the
system property, sbt.log.uselog4j. The global logger will use the sbt
internal implementation unless the system property is set.

There are a fairly significant number of mima issues since I changed the
type of ConsoleAppender. All of the mima changes were in the
sbt.internal package so I think this should be ok.

Effects: the memory leaks are gone. I successfully ran 5000 no-op
compiles in the sbt-multi-module-sample above with no degradation of
performace. There was a noticeable degradation after 30 no-op compiles
before.

During the refactor, I had to work on TestLogger and in doing so I also
fixed https://github.com/sbt/sbt/issues/4480.

This also should fix https://github.com/sbt/sbt/issues/4773
2020-08-09 11:20:34 -07:00
Ethan Atkins cf745255e8 Apply javafmt in sbt project 2020-01-14 14:38:08 -08:00
Ethan Atkins 639b812a01 Don't strip quotes in _sbt_ scripted command arguments
Stripping quotation marks makes it impossible to cleanly test certain
sbt features without resorting to weird hacks. For example:
> set Compile / scalacOptions += "-Xfatal-warnings"
did not work while
> set Compile / scalacOptions += '"-Xfatal-warnings"'
did.

I leave the single quote parser unchanged since single quotes are not
really used in sbt and so there is utility in leaving them as a way to
group arguments that should not be split apart.

This change should only affect the scripted tests in the sbt repo. We
can consider making stripQuotes = false the default for the plugin as
well.
2020-01-11 16:50:22 -08:00
Ethan Atkins ad59e71b1a Add util headers
None of the util files had headers.
2019-12-08 10:29:22 -08:00
Eugene Yokota 98ec0075f4 apply formatting 2019-04-20 23:23:13 -04:00
Antonio Cunei 0a1bd5a3b2 Change modifiedTime definitions 2017-12-22 00:13:27 +01:00
Antonio Cunei 8ba68eedfd Revert *ModifiedTime() calls to *lastModified*() calls
There are just too many instances in which sbt's code relies on
the `lastModified`/`setLastModified` semantics, so instead of moving
to `get`/`setModifiedTime`, we use new IO calls that offer the new
timestamp precision, but retain the old semantics.
2017-12-22 00:13:27 +01:00
Eugene Yokota e835ce0689 bump plugins 2017-12-15 13:15:34 -05:00
Antonio Cunei d2338ff287 Removed a couple more direct imports of getModifiedTime() 2017-12-15 17:23:39 +01:00
Dale Wijnand 13a8d53369
Use IO.getModified over importing the method
.. and make getModifiedTimeOrZero private.
2017-12-13 15:47:15 +00:00
Antonio Cunei d03dfb3981 Moved Milli._ to IO. 2017-12-06 20:29:41 +01:00
Antonio Cunei ccf149e8bf Convert lastModified() calls to sbt.io.Milli.getModifiedTime() 2017-12-06 20:29:41 +01:00
Dale Wijnand d31b9c5093
Add, configure & enable Scalafmt 2017-08-10 11:44:24 +01:00
Eugene Yokota 2d777a85ee clean up warnings 2017-07-01 07:47:39 -04:00
Eugene Yokota c985d9cdc0 Switch Scripted tests to used ManagedLogger 2017-01-24 21:13:58 -05:00
Dale Wijnand 121e7f5d9e Add -Ywarn-unused & -Ywarn-unused-import, & fix warnings 2016-06-19 11:42:31 +01:00
Eugene Yokota 9c49a0ed9f Update dependencies 2016-05-04 16:27:29 -04:00
Grzegorz Kossakowski 9f9ac3a9cc Scripted logger logs everything
Do not filter any logging in scripted logger by setting the log level to
Debug.
The caller of ScriptedRunner passes a logger and decides the level of
logging it wants to receive. Scripted shouldn't filter anything.
2016-04-12 20:14:10 +02:00
Grzegorz Kossakowski 89e88ff584 Run scripted tests in the alphabetical order
Makes the order deterministic and makes it easier to see the progress on
running tests.
2016-04-07 12:48:45 +02:00
Martin Duhem 149122ab4d Hide stacktrace upon failure on pending scripted test 2016-01-25 14:48:06 +01:00
Martin Duhem 23698d6664 Add scripted-core 2015-12-23 09:50:36 +01:00