nixpkgs/pkgs/development/java-modules/build-maven-package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
1.3 KiB
Nix
Raw Normal View History

2021-01-23 17:15:07 +00:00
{ lib, stdenv, maven, pkgs }:
2016-11-15 19:18:19 +00:00
{ mavenDeps, src, name, meta, m2Path, skipTests ? true, quiet ? true, ... }:
2016-10-30 15:41:20 +00:00
with builtins;
2021-01-23 17:15:07 +00:00
with lib;
2016-10-30 15:41:20 +00:00
2016-10-31 14:23:22 +00:00
let
mavenMinimal = import ./maven-minimal.nix { inherit lib pkgs ; };
2016-10-31 14:23:22 +00:00
in stdenv.mkDerivation rec {
2016-10-30 15:41:20 +00:00
inherit mavenDeps src name meta m2Path;
2016-10-31 14:23:22 +00:00
flatDeps = unique (flatten (mavenDeps ++ mavenMinimal.mavenMinimal));
2016-10-30 15:41:20 +00:00
propagatedBuildInput = [ maven ] ++ flatDeps;
find = ''find ${concatStringsSep " " (map (x: x + "/m2") flatDeps)} -type d -printf '%P\n' | xargs -I {} mkdir -p $out/m2/{}'';
copy = ''cp -rsfu ${concatStringsSep " " (map (x: x + "/m2/*") flatDeps)} $out/m2'';
2016-10-30 15:41:20 +00:00
2021-08-12 22:17:59 +00:00
dontInstall = true;
2016-10-31 17:10:26 +00:00
2016-10-30 15:41:20 +00:00
buildPhase = ''
2016-10-31 17:10:26 +00:00
mkdir -p $out/target
2016-10-30 15:41:20 +00:00
mkdir -p $out/m2/${m2Path}
${optionalString (length flatDeps > 0) find}
${optionalString (length flatDeps > 0) copy}
2016-11-15 19:18:19 +00:00
if [ -f $out/m2/settings.xml ]; then rm $out/m2/settings.xml; fi
2016-10-30 15:41:20 +00:00
echo "<settings><mirrors>\
2016-11-15 19:18:19 +00:00
<mirror><id>tmpm2</id><url>file://$out/m2</url><mirrorOf>*</mirrorOf></mirror></mirrors>\
<localRepository>$out/m2/</localRepository></settings>" >> $out/m2/settings.xml
2017-04-11 16:08:51 +00:00
${maven}/bin/mvn ${optionalString (quiet) "-q"} clean package -Dmaven.test.skip=${boolToString skipTests} -Danimal.sniffer.skip=true -gs $out/m2/settings.xml
2016-11-15 19:18:19 +00:00
cp ./target/*.jar $out/m2/${m2Path}
2016-10-31 17:10:26 +00:00
cp -v ./target/*.jar $out/target/
2016-10-30 15:41:20 +00:00
'';
}