diff options
author | Alyssa Ross <hi@alyssa.is> | 2024-04-10 20:43:08 +0200 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2024-04-10 20:43:08 +0200 |
commit | 69bfdf2484041b9d242840c4e5017b4703383bb0 (patch) | |
tree | d8bdaa69e7990d7d6f09b594b3c425f742acd2d0 /nixpkgs/doc/languages-frameworks/java.section.md | |
parent | c8aee4b4363b6bf905a521b05b7476960e8286c8 (diff) | |
parent | d8fe5e6c92d0d190646fb9f1056741a229980089 (diff) | |
download | nixlib-69bfdf2484041b9d242840c4e5017b4703383bb0.tar nixlib-69bfdf2484041b9d242840c4e5017b4703383bb0.tar.gz nixlib-69bfdf2484041b9d242840c4e5017b4703383bb0.tar.bz2 nixlib-69bfdf2484041b9d242840c4e5017b4703383bb0.tar.lz nixlib-69bfdf2484041b9d242840c4e5017b4703383bb0.tar.xz nixlib-69bfdf2484041b9d242840c4e5017b4703383bb0.tar.zst nixlib-69bfdf2484041b9d242840c4e5017b4703383bb0.zip |
Merge commit 'd8fe5e6c'
Conflicts: nixpkgs/pkgs/build-support/go/module.nix
Diffstat (limited to 'nixpkgs/doc/languages-frameworks/java.section.md')
-rw-r--r-- | nixpkgs/doc/languages-frameworks/java.section.md | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/nixpkgs/doc/languages-frameworks/java.section.md b/nixpkgs/doc/languages-frameworks/java.section.md index 0ce1442cca68..6d56ffcd4503 100644 --- a/nixpkgs/doc/languages-frameworks/java.section.md +++ b/nixpkgs/doc/languages-frameworks/java.section.md @@ -7,7 +7,7 @@ stdenv.mkDerivation { pname = "..."; version = "..."; - src = fetchurl { ... }; + src = fetchurl { /* ... */ }; nativeBuildInputs = [ ant @@ -48,8 +48,10 @@ installs a JAR named `foo.jar` in its `share/java` directory, and another package declares the attribute ```nix -buildInputs = [ libfoo ]; -nativeBuildInputs = [ jdk ]; +{ + buildInputs = [ libfoo ]; + nativeBuildInputs = [ jdk ]; +} ``` then `CLASSPATH` will be set to @@ -62,13 +64,15 @@ If your Java package provides a program, you need to generate a wrapper script to run it using a JRE. You can use `makeWrapper` for this: ```nix -nativeBuildInputs = [ makeWrapper ]; +{ + nativeBuildInputs = [ makeWrapper ]; -installPhase = '' - mkdir -p $out/bin - makeWrapper ${jre}/bin/java $out/bin/foo \ - --add-flags "-cp $out/share/java/foo.jar org.foo.Main" -''; + installPhase = '' + mkdir -p $out/bin + makeWrapper ${jre}/bin/java $out/bin/foo \ + --add-flags "-cp $out/share/java/foo.jar org.foo.Main" + ''; +} ``` Since the introduction of the Java Platform Module System in Java 9, @@ -92,16 +96,18 @@ let something = (pkgs.something.override { jre = my_jre; }); other = (pkgs.other.override { jre = my_jre; }); in - ... + <...> ``` You can also specify what JDK your JRE should be based on, for example selecting a 'headless' build to avoid including a link to GTK+: ```nix -my_jre = pkgs.jre_minimal.override { - jdk = jdk11_headless; -}; +{ + my_jre = pkgs.jre_minimal.override { + jdk = jdk11_headless; + }; +} ``` Note all JDKs passthru `home`, so if your application requires @@ -116,7 +122,9 @@ It is possible to use a different Java compiler than `javac` from the OpenJDK. For instance, to use the GNU Java Compiler: ```nix -nativeBuildInputs = [ gcj ant ]; +{ + nativeBuildInputs = [ gcj ant ]; +} ``` Here, Ant will automatically use `gij` (the GNU Java Runtime) instead of |