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