Closed leo60228 closed 2 years ago
See also https://github.com/gradle/gradle/issues/16645 (sadly not much interest/activity over there)
See also https://discourse.nixos.org/t/auto-detecting-java-installations/4677
I saw those, but if I understand correctly they only apply to compilation and not the Gradle daemon, so they wouldn't help with plugins requiring newer versions of Java (like https://github.com/FabricMC/fabric-loom).
The line in all-packages.nix
making Gradle use Java 8 references #89731. However, as far as I can tell, that PR provides no explanation for why keeping Gradle on Java 8 was necessary. I misread the PR description, never mind.
Ah, it seems I misunderstood what you were aiming at. How about overriding the JDK used for your Gradle?
Making this more flexible is what I was trying to do in https://github.com/NixOS/nixpkgs/pull/119444 but that's somewhat stalled. Maybe also worth considering. Happy to take your feedback and/or improvements there.
I believe this was resolved with https://github.com/NixOS/nixpkgs/pull/119444
It is now possible to pass java
(the JDK that Gradle itself should use) and javaToolchains
(a list of JDKs that should be registered as toolchains). Sane defaults for java
are used.
I'll go ahead and close this issue, because I believe it is resolved and it is inactive for >6 months.
Describe the bug The
gradle
package setsJAVA_HOME
tojdk
, which is Java 8. This means that compilation and Gradle itself will use that version of Java, which is problematic since both projects and Gradle plugins may be using newer versions of Java.To Reproduce Steps to reproduce the behavior:
Expected behavior I expect there to be a clear way to handle needed Java versions.
Additional context There are several workarounds here. Newer versions of Java can be configured as Gradle toolchains, but that doesn't help for plugins, and is somewhat ugly (since toolchains can only be configured via dotfiles or command-line arguments). Alternatively, the Gradle package can be overridden, but this is somewhat ugly and non-trivial with the new Nix CLI. However, this problem is complicated by the fact that many projects will expect a Java 8 compiler. A solution could be to run Gradle itself with the latest packaged version of Java and to have support for Gradle toolchains to use multiple compiler versions.
Notify maintainers
@lorenzleutgeb
Metadata Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.Maintainer information: