2024-11-19 19:15:58 +01:00
|
|
|
# Bring Powersort to Java
|
|
|
|
|
|
|
|
## Gradle
|
|
|
|
|
|
|
|
### Setup
|
|
|
|
|
2024-11-20 13:49:18 +01:00
|
|
|
**Commandline**
|
|
|
|
|
2024-11-19 19:15:58 +01:00
|
|
|
Check which Java toolchains can be found by Gradle:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
./gradlew javaToolchains
|
|
|
|
```
|
|
|
|
|
2024-11-20 13:49:18 +01:00
|
|
|
- `shell.nix` -> broken (as well for `gradle javaToolchains`
|
2024-11-23 16:10:18 +00:00
|
|
|
- `shell1.nix` -> works 🥳
|
2024-11-20 13:49:18 +01:00
|
|
|
- `shell2.nix` -> broken (as well for `gradle javaToolchains`)
|
2024-11-23 16:10:18 +00:00
|
|
|
- `shell3.nix` -> works 🥳
|
2024-11-23 16:39:45 +00:00
|
|
|
- `shell4.nix` -> works 🥳
|
2024-11-20 13:49:18 +01:00
|
|
|
|
2024-11-19 19:15:58 +01:00
|
|
|
This should include version >= 17, e.g.:
|
|
|
|
|
|
|
|
```
|
|
|
|
+ N/A JDK 23-ga
|
|
|
|
| Location: /nix/store/48290hnlb13xmwjw9y16a1s785993bv7-openjdk-23-ga/lib/openjdk
|
|
|
|
| Language Version: 23
|
|
|
|
| Vendor: N/A
|
|
|
|
| Architecture: amd64
|
|
|
|
| Is JDK: true
|
|
|
|
| Detected by: Current JVM
|
|
|
|
```
|
|
|
|
|
2024-11-20 13:49:18 +01:00
|
|
|
**IntelliJ**
|
|
|
|
|
|
|
|
Open issue: gradle's toolchain support does not work with IntelliJ
|
|
|
|
|
|
|
|
- `shell.nix`
|
|
|
|
- Solution from 2022 did no longer work: https://github.com/NixOS/nixpkgs/issues/207153#issue-1506967648
|
|
|
|
- `shell1.nix`
|
|
|
|
- Instead, we found this: https://discourse.nixos.org/t/overriding-the-jdk-for-gradle-in-a-nix-flake/36541/2
|
|
|
|
- `shell2.nix`
|
|
|
|
- Another approach - which did no longer work! https://github.com/utybo/Tegral/blob/main/shell.nix
|
2024-11-23 16:10:18 +00:00
|
|
|
- `shell3.nix`
|
2024-11-23 16:39:45 +00:00
|
|
|
- This works with JDK 21 🥳
|
2024-11-23 16:10:18 +00:00
|
|
|
- STRG ALT SHIFT s -> SDK -> add JDK ->
|
|
|
|
- home path: /usr/lib/openjdk
|
|
|
|
- name: usr-lib-jdk
|
|
|
|
- STRG ALT s -> build tools -> gradle ->
|
|
|
|
- local installation: /usr/lib/gradle
|
|
|
|
- Gradle JVM: usr-lib-jdk
|
2024-11-23 16:39:45 +00:00
|
|
|
- `shell4.nix`
|
|
|
|
- This works with JDK23 🚀
|
2024-11-20 13:49:18 +01:00
|
|
|
|
2024-11-19 19:15:58 +01:00
|
|
|
### Tasks
|
|
|
|
|
2024-11-19 19:24:56 +01:00
|
|
|
List all Gradle tasks which can be run:
|
2024-11-19 19:15:58 +01:00
|
|
|
|
|
|
|
```shell
|
|
|
|
./gradlew tasks
|
|
|
|
```
|
|
|
|
|
2024-11-19 19:24:56 +01:00
|
|
|
This can also be done graphically in IntelliJ:
|
|
|
|
|
|
|
|
![intellij-gradle.png](intellij-gradle.png)
|
|
|
|
|
2024-11-19 19:35:34 +01:00
|
|
|
### Test Cases
|
2024-11-19 19:15:58 +01:00
|
|
|
|
|
|
|
Run the task "test":
|
|
|
|
|
|
|
|
```shell
|
|
|
|
./gradlew test
|
|
|
|
```
|
2024-11-19 19:35:34 +01:00
|
|
|
|
|
|
|
## TimSort
|
|
|
|
|
|
|
|
Imported from
|
|
|
|
- src/java.base/share/classes/java/util/TimSort.java
|
|
|
|
- src/java.base/share/classes/java/util/ComparableTimSort.java
|