1 # Adaptation of the MIT-licensed work on `sbt2nix` done by Charles O'Farrell
10 "https://repo1.maven.org/maven2"
11 "https://oss.sonatype.org/content/repositories/releases"
12 "https://oss.sonatype.org/content/repositories/public"
13 "https://repo.typesafe.com/typesafe/releases"
18 # Example: "org.apache.httpcomponents"
20 # Example: "httpclient"
26 # List of maven repositories from where to fetch the artifact.
27 # Example: [ http://oss.sonatype.org/content/repositories/public ].
29 # The `url` and `urls` parameters, if specified should point to the JAR
30 # file and will take precedence over the `repos` parameter. Only one of `url`
31 # and `urls` can be specified, not both.
34 # The rest of the arguments are just forwarded to `fetchurl`.
38 # only one of url and urls can be specified at a time.
39 assert (url == "") || (urls == [ ]);
40 # if repos is empty, then url or urls must be specified.
41 assert (repos != [ ]) || (url != "") || (urls != [ ]);
45 (lib.replaceStrings [ "." ] [ "_" ] groupId)
47 + (lib.replaceStrings [ "." ] [ "_" ] artifactId);
48 suffix = lib.optionalString (classifier != null) "-${classifier}";
49 filename = "${artifactId}-${version}${suffix}.jar";
52 lib.concatStringsSep "/" [
53 (lib.removeSuffix "/" repoUrl)
54 (lib.replaceStrings [ "." ] [ "/" ] groupId)
62 else if urls != [ ] then
67 builtins.removeAttrs args [
77 name = "${pname}-${version}.jar";
82 inherit pname version;
84 # By moving the jar to $out/share/java we make it discoverable by java
85 # packages packages that mention this derivation in their buildInputs.
87 mkdir -p $out/share/java
88 ln -s ${jar} $out/share/java/${filename}
90 # We also add a `jar` attribute that can be used to easily obtain the path
91 # to the downloaded jar file.