Commit Graph

94 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
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
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
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 61a077e3a6 Scala 2.12.13 2021-01-31 12:59:31 -05:00
Sam Halliday 816208f081 Terminal support for GNU Emacs 2021-01-21 10:50:57 +00:00
Eugene Yokota bd7a2e05bf Use `Global / localCacheDirectory` for remote caching
Fixes https://github.com/sbt/sbt/issues/6102

https://github.com/sbt/sbt/pull/6026 changed the implementation of remote cache to NOT use dependency resolution (Coursier), and directly use Ivy resolver for efficiency. This was good, but when I made the change, I've changed the cache directory to be `crossTarget.value / "remote-cache"`. This was ok for local testing purpose, but not great for real usage since we don't want the cache to be wiped out either in the CI machines or on a local laptop.

This adds a new Global key called `localCacheDirectory`. Similar to Coursier cache, this is meant to be shared across all builds running on a machine. Also similar to Coursier cache this will try to follow the operating system specifc caching directory.

### localCacheDirectory location

- Environment variable: `SBT_LOCAL_CACHE`
- System property: `sbt.global.localcache`
- Windows: %LOCALAPPDATA%\sbt\v1
- macOS: $HOME/Library/Caches/sbt/v1
- Linux: $HOME/.cache/sbt/v1
2020-11-22 14:35:20 -05:00
Ethan Atkins 38d67cfdf0 Improve sbt build load time by 25%
The sbt project load made a number of relatively inefficient
transformations of scala collecitons. I went through and found the slow
parts during project loading and made my best attempt at fixing them.
The most significant changes I made were in places using IMap. An IMap
is more or less a wrapper around an immutable Map. It can be much faster
to construct an IMap by creating a java mutable hashmap, wrapping it a
scala Map that delegates to the underlying java hashmap (with a copy on
write if the map is modified) and constructing the IMap from the wrapped
map. It was also in many cases to parallelize some transformations
wherever the order didn't matter.

After applying all of these changes, I found that loading the sbt
project took generally between 8.5 and 9 seconds on my laptop. With
1.3.13, it hovered around 11.5 seconds. I saw a similar speedup in zinc.
The biggest specific improvement was that generating the compiled map
dropped from between 3.5-4 seconds to pretty consistently being around
1.5 seconds.
2020-07-26 19:52:26 -07:00
Ethan Atkins bc4fe0a31a Cross build collectionProj 2020-07-10 13:37:54 -07:00
Ethan Atkins 6565618a15 Cache compiled map during build load
The continuous command recompiles the setting graph into a CompiledMap
data structure so that it can determine which files it needs to
transitively monitor during watch. Generating the CompiledMap can be
very slow for large projects (5 seconds or so on my computer in the sbt
project) and this startup cost is paid every time the user enters a
watch with `~`. To avoid this, we can cache the compile map that is
generated during the initial settings evaluation.

The only real drawback I can see is that the compiled map is guaranteed
to remain in memory so long as the BuildStructure instance that holds it
is alive. Given the performance benefit, this seems like a worthwhile
tradeoff.
2020-07-03 14:08:26 -07:00
Ethan Atkins e53c8f6f01 Add Util.ignoreResult
This adds a convenience macro for appending `()` to an expression if it
is the last expression in a block that is supposed to return Unit.
2020-06-24 19:19:06 -07:00
Ethan Atkins 52d19d8f0c Refactor Signal for graalvm
The graalvm issues warnings about the objects defined in
Signal.register, so I made them top level private classes instead.
2020-06-24 19:19:06 -07:00
eugene yokota 2b557851ca
Merge pull request #5041 from jsoref/https
Https
2020-06-14 17:34:58 -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
nigredo-tori 11b7173ec7
Fix a message about an undefined setting
`defining` seems to be the setting or a task that references `referencedKey`, not the other way around.
2020-03-13 12:53:44 +07: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
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
Eugene Yokota 5d0793fece Scala 2.12.10 2019-09-11 23:02:50 -04:00
Josh Soref 747416173a https://apocalisp.wordpress.com 2019-09-05 14:10:59 -04:00
xuwei-k dfe789d7c6 avoid deprecated /: and :\
use foldLeft and foldRight

https://github.com/scala/scala/blob/v2.13.0/src/library/scala/collection/IterableOnce.scala#L682-L686
2019-08-30 11:20:53 +09:00
xuwei-k 1f3ce5f9ee use Vector instead of List. avoid O(n) append 2019-08-29 21:44:31 +09:00
Ethan Atkins 4bb2f4e968 Used Seq instead of Stream
Streams generically perform poorly and weren't needed here.
2019-08-22 20:35:12 -07:00
Ethan Atkins 1700b89ea4 Parallelize Init.addLocal
During akka startup, addLocal was caused twice and prior to this change,
it took roughly 200ms per call on my computer. After this change, it
took about 100ms.
2019-08-22 20:35:11 -07:00
Ethan Atkins a3ac4c76a6 Bump scalafmt
Intellij had issues resolving 2.0.0-RCX so it will be nice to be using
the latest.
2019-07-18 12:40:21 -07:00
Dale Wijnand 4e89e8ace5
Document helper functions in BuildStructure
Also define LoadedBuildUnit#projects & BuildUnit#thisRootProject, &
cleanup AttributeKey & BasicAttributeMap
2019-06-02 23:28:53 +01:00
Eugene Yokota 1e157b991a apply formatting 2019-04-20 03:23:54 -04:00
Ethan Atkins d178f13fc0 Rename generic parameter
I was seeing a number of compiler warnings about the type parameter
Scope:
    Settings.scala:55:12: type parameter Scope defined in trait Init shadows class Scope defined in package util. You may want to rename your type parameter, or possibly remove it.

I'm not sure why I wasn't seeing these before, but the fix is simple.
2019-03-28 08:31:10 -07:00
Ethan Atkins efa52143d0 Make types private
While the AnyLeft and AnyRight types are necessary to make the extension
class work, I don't want to leak the AnyLeft or AnyRight traits into the
public api. It wasn't neceessary to annotate `some`, but it's good
practice to annotate anything public anyway.
2019-01-31 21:47:33 -08:00
Ethan Atkins 9b40a0e585 Add meaningful toString to TypeFunctions
It can be hard to debug these because the toString output for a kind
projector plugin provided lambda is inscrutable.
2019-01-31 21:47:33 -08:00
Ethan Atkins 16e7c70035 Lint TypeFunctions.scala 2019-01-31 21:47:33 -08:00
Eugene Yokota 4ff4f6e45e Update header 2018-09-14 04:53:36 -04:00
xuwei-k ae1fdff968 use SAM type 2018-07-09 13:06:34 +09:00
xuwei-k 98eca81b17 use val instead of var 2018-07-08 22:35:31 +09:00
eugene yokota eb942f8e5f
Merge pull request #4003 from eed3si9n/wip/opt-delegation3
optimize scope delegation
2018-06-27 15:31:21 -04:00
Dale Wijnand 8f4b8abb7b
Run scalafmt & test:scalafmt 2018-04-24 16:12:10 +01:00
Eugene Yokota 07e26a1dcf don't use toStream
Ref #3979
toStream doesn't help performance.
2018-03-10 18:43:43 -05:00
Dale Wijnand 21eb1f0f12
Cleanup Attributes 2018-03-06 11:54:12 +00:00
Dale Wijnand 5daf10d6c7
Tweak the description of KList 2018-01-23 17:14:27 +00:00
Dale Wijnand b80a6b217b
Remove all warnings from collectionProj 2017-12-12 13:02:18 +00:00
Dale Wijnand 9f1d60be60
Rewrite to polymorphic function syntax 2017-10-25 10:23:46 +01:00
Dale Wijnand f662fdda8e
Rewrite to function syntax 2017-10-25 10:22:48 +01:00
Dale Wijnand fb17cc393f
Rewrite to inline syntax 2017-10-25 10:22:48 +01:00
Dale Wijnand 35c3542492
Get rid of Fn1 2017-10-25 10:21:00 +01:00