about summary refs log tree commit diff
path: root/pkgs/build-support/build-maven.nix
diff options
context:
space:
mode:
authorCharles Duffy <charles@dyfis.net>2018-11-29 17:18:23 +0000
committerCharles Duffy <charles@dyfis.net>2018-11-29 17:29:59 +0000
commit8f90b3324019890974fdb4d205bc1f6e73bf2a5f (patch)
tree7fd4ec5f6a4c67808957402b7fc87e35e44b471c /pkgs/build-support/build-maven.nix
parent45c67945737f9e7158dd06d22c241efaf244c353 (diff)
buildMaven: Support metadata-only dependencies
The circumstances which can make this necessary are discussed in NixOS/mvn2nix-maven-plugin#17
Diffstat (limited to 'pkgs/build-support/build-maven.nix')
-rw-r--r--pkgs/build-support/build-maven.nix18
1 files changed, 11 insertions, 7 deletions
diff --git a/pkgs/build-support/build-maven.nix b/pkgs/build-support/build-maven.nix
index b9da06c43c82d..f47e3ebc61c20 100644
--- a/pkgs/build-support/build-maven.nix
+++ b/pkgs/build-support/build-maven.nix
@@ -15,16 +15,15 @@ infoFile: let
 
   script = writeText "build-maven-repository.sh" ''
     ${lib.concatStrings (map (dep: let
-      inherit (dep)
-        url sha1 groupId artifactId
-        version metadata repository-id;
+      inherit (dep) sha1 groupId artifactId version metadata repository-id;
 
       versionDir = dep.unresolved-version or version;
       authenticated = dep.authenticated or false;
+      url = dep.url or "";
 
-      fetch = (if authenticated then requireFile else fetchurl) {
+      fetch = if (url != "") then ((if authenticated then requireFile else fetchurl) {
         inherit url sha1;
-      };
+      }) else "";
 
       fetchMetadata = (if authenticated then requireFile else fetchurl) {
         inherit (metadata) url sha1;
@@ -32,10 +31,15 @@ infoFile: let
     in ''
       dir=$out/$(echo ${groupId} | sed 's|\.|/|g')/${artifactId}/${versionDir}
       mkdir -p $dir
-      ln -sv ${fetch} $dir/${fetch.name}
+
+      ${lib.optionalString (fetch != "") ''
+        ln -sv ${fetch} $dir/${fetch.name}
+      ''}
       ${lib.optionalString (dep ? metadata) ''
         ln -svf ${fetchMetadata} $dir/maven-metadata-${repository-id}.xml
-        ln -sv ${fetch} $dir/$(echo ${fetch.name} | sed 's|${version}|${dep.unresolved-version}|')
+        ${lib.optionalString (fetch != "") ''
+          ln -sv ${fetch} $dir/$(echo ${fetch.name} | sed 's|${version}|${dep.unresolved-version}|')
+        ''}
       ''}
     '') info.dependencies)}
   '';