diff --git a/.gitignore b/.gitignore index 1b6985c..fb56380 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ +/.sgp + # Ignore Gradle project-specific cache directory -.gradle +/.gradle # Ignore Gradle build output directory -build +/build diff --git a/README.md b/README.md index 6806364..9c9cd83 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,18 @@ ### Setup +**Commandline** + Check which Java toolchains can be found by Gradle: ```shell ./gradlew javaToolchains ``` +- `shell.nix` -> broken (as well for `gradle javaToolchains` +- `shell1.nix` -> works +- `shell2.nix` -> broken (as well for `gradle javaToolchains`) + This should include version >= 17, e.g.: ``` @@ -22,6 +28,19 @@ This should include version >= 17, e.g.: | Detected by: Current JVM ``` +**IntelliJ** + +TODO, nothing has worked so far. + +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 + ### Tasks List all Gradle tasks which can be run: diff --git a/shell (Copy).nix b/shell1.nix similarity index 51% rename from shell (Copy).nix rename to shell1.nix index 64f3dd9..49fb481 100644 --- a/shell (Copy).nix +++ b/shell1.nix @@ -5,10 +5,6 @@ let jdk = unstable.jdk23; in -# Open issue: gradle's toolchain support does not work with IntelliJ -# Solution from 2022 did no longer work: https://github.com/NixOS/nixpkgs/issues/207153#issue-1506967648 -# Instead we found this: https://discourse.nixos.org/t/overriding-the-jdk-for-gradle-in-a-nix-flake/36541/2 - pkgs.mkShell { buildInputs = with pkgs; [ jdk diff --git a/shell2.nix b/shell2.nix new file mode 100644 index 0000000..e720bea --- /dev/null +++ b/shell2.nix @@ -0,0 +1,66 @@ +{ pkgs ? import { } }: + +let + unstable = import (fetchTarball https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz) { }; + toolchains = [ (unstable.jdk11 + "/lib/openjdk") (unstable.jdk17 + "/lib/openjdk") ]; + patchedGradle = unstable.gradle_8.overrideAttrs (curr: old: { + fixupPhase = (old.fixupPhase or "") + '' + cat > $out/lib/gradle/gradle.properties < ./.sgp < .idea/gradle.xml < + + + + + +EOF +echo IntelliJ IDEA configured, restart running instances +EOS + chmod +x ./.sgp + ''; +} +