diff options
Diffstat (limited to 'pkgs/development/java-modules/build-maven-package.nix')
-rw-r--r-- | pkgs/development/java-modules/build-maven-package.nix | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pkgs/development/java-modules/build-maven-package.nix b/pkgs/development/java-modules/build-maven-package.nix new file mode 100644 index 00000000000..182740c552d --- /dev/null +++ b/pkgs/development/java-modules/build-maven-package.nix @@ -0,0 +1,26 @@ +{ stdenv, maven, lib }: +{ mavenDeps, src, name, meta, m2Path, ... }: + +with builtins; +with lib; + +stdenv.mkDerivation rec { + inherit mavenDeps src name meta m2Path; + + flatDeps = flatten mavenDeps; + + propagatedBuildInput = [ maven ] ++ flatDeps; + + find = ''find ${foldl' (x: y: x + " " + y) "" (map (x: x + "/m2/") flatDeps)} -type d -printf '%P\n' | xargs -I {} mkdir -p $out/m2/{}''; + copy = ''cp -rs ${foldl' (x: y: x + " " + y) "" (map (x: x + "/m2/*") flatDeps)} $out/m2''; + + buildPhase = '' + mkdir -p $out/m2/${m2Path} + ${optionalString (length flatDeps > 0) find} + ${optionalString (length flatDeps > 0) copy} + echo "<settings><mirrors>\ + <mirror><id>tmpm2</id><url>file://$out/m2</url><mirrorOf>*</mirrorOf></mirror></mirrors>\ + <localRepository>$out/m2</localRepository></settings>" >> $out/m2/settings.xml + ${maven}/bin/mvn clean install -Dmaven.test.skip=true -gs $out/m2/settings.xml + ''; +} |