mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-24 18:16:21 +03:00
doc: include stripJavaArchivesHook in the java section
This commit is contained in:
parent
63ddc7bc00
commit
e08f26cdb1
1 changed files with 26 additions and 3 deletions
|
@ -4,12 +4,31 @@ Ant-based Java packages are typically built from source as follows:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "...";
|
pname = "...";
|
||||||
|
version = "...";
|
||||||
|
|
||||||
src = fetchurl { ... };
|
src = fetchurl { ... };
|
||||||
|
|
||||||
nativeBuildInputs = [ jdk ant ];
|
nativeBuildInputs = [
|
||||||
|
ant
|
||||||
|
jdk
|
||||||
|
stripJavaArchivesHook # removes timestamp metadata from jar files
|
||||||
|
];
|
||||||
|
|
||||||
buildPhase = "ant";
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
ant # build the project using ant
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
# 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
|
or pre-built via Zulu). Platforms with OpenJDK not (yet) in Nixpkgs
|
||||||
(`Aarch32`, `Aarch64`) point to the (unfree) `oraclejdk`.
|
(`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
|
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
|
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
|
any JARs in the `share/java` directories of the build inputs to the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue