about summary refs log tree commit diff
path: root/doc/languages-frameworks
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2024-03-19 06:01:43 +0000
committerGitHub <noreply@github.com>2024-03-19 06:01:43 +0000
commit66eeab8faf9779c6e990a978e46471ba2d0a7d2a (patch)
tree59ef31658d52add31692e42d855b8fce95c73569 /doc/languages-frameworks
parentb727e4cb210367459e4299f8521d9c781fe70fc5 (diff)
parent8ee0e6664b4d07c288c8c303dcb682ff23bde432 (diff)
Merge staging-next into staging
Diffstat (limited to 'doc/languages-frameworks')
-rw-r--r--doc/languages-frameworks/java.section.md29
1 files changed, 26 insertions, 3 deletions
diff --git a/doc/languages-frameworks/java.section.md b/doc/languages-frameworks/java.section.md
index 371bdf6323fb4..0ce1442cca68f 100644
--- a/doc/languages-frameworks/java.section.md
+++ b/doc/languages-frameworks/java.section.md
@@ -4,12 +4,31 @@ Ant-based Java packages are typically built from source as follows:
 
 ```nix
 stdenv.mkDerivation {
-  name = "...";
+  pname = "...";
+  version = "...";
+
   src = fetchurl { ... };
 
-  nativeBuildInputs = [ jdk ant ];
+  nativeBuildInputs = [
+    ant
+    jdk
+    stripJavaArchivesHook # removes timestamp metadata from jar files
+  ];
+
+  buildPhase = ''
+    runHook preBuild
+    ant # build the project using ant
+    runHook postBuild
+  '';
+
+  installPhase = ''
+    runHook preInstall
 
-  buildPhase = "ant";
+    # copy generated jar file(s) to an appropriate location in $out
+    install -Dm644 build/foo.jar $out/share/java/foo.jar
+
+    runHook postInstall
+  '';
 }
 ```
 
@@ -17,6 +36,10 @@ Note that `jdk` is an alias for the OpenJDK (self-built where available,
 or pre-built via Zulu). Platforms with OpenJDK not (yet) in Nixpkgs
 (`Aarch32`, `Aarch64`) point to the (unfree) `oraclejdk`.
 
+Also note that not using `stripJavaArchivesHook` will likely cause the
+generated `.jar` files to be non-deterministic, which is not optimal.
+Using it, however, does not always guarantee reproducibility.
+
 JAR files that are intended to be used by other packages should be
 installed in `$out/share/java`. JDKs have a stdenv setup hook that add
 any JARs in the `share/java` directories of the build inputs to the