mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
add classifier as an argument
This commit is contained in:
parent
49c789703c
commit
38ad378228
@ -17,6 +17,8 @@ args@
|
||||
artifactId
|
||||
, # Example: "4.3.6"
|
||||
version
|
||||
, # Example: "jdk11"
|
||||
classifier ? null
|
||||
, # List of maven repositories from where to fetch the artifact.
|
||||
# Example: [ http://oss.sonatype.org/content/repositories/public ].
|
||||
repos ? defaultRepos
|
||||
@ -36,28 +38,19 @@ assert (repos != []) || (url != "") || (urls != []);
|
||||
|
||||
|
||||
let
|
||||
classifierSplit =
|
||||
with stdenv.lib.strings;
|
||||
splitString "$" artifactId;
|
||||
artifactId_ = builtins.head classifierSplit;
|
||||
classifier =
|
||||
with stdenv.lib;
|
||||
if builtins.length classifierSplit > 1
|
||||
then concatStrings ["-" (builtins.elemAt classifierSplit 1)]
|
||||
else "";
|
||||
name_ =
|
||||
with stdenv.lib; concatStrings [
|
||||
(replaceChars ["."] ["_"] groupId) "_"
|
||||
(replaceChars ["."] ["_"] artifactId_) "-"
|
||||
(replaceChars ["."] ["_"] artifactId) "-"
|
||||
version
|
||||
];
|
||||
mkJarUrl = repoUrl:
|
||||
with stdenv.lib; concatStringsSep "/" [
|
||||
(removeSuffix "/" repoUrl)
|
||||
(replaceChars ["."] ["/"] groupId)
|
||||
artifactId_
|
||||
artifactId
|
||||
version
|
||||
"${artifactId_}-${version}${classifier}.jar"
|
||||
"${artifactId}-${version}-${optionalString (!isNull classifier) "-${classifier}"}.jar"
|
||||
];
|
||||
urls_ =
|
||||
if url != "" then [url]
|
||||
@ -65,8 +58,8 @@ let
|
||||
else map mkJarUrl repos;
|
||||
jar =
|
||||
fetchurl (
|
||||
builtins.removeAttrs args ["groupId" "artifactId" "version" "repos" "url" ]
|
||||
// { urls = urls_; name = "${name_}${classifier}.jar"; }
|
||||
builtins.removeAttrs args ["groupId" "artifactId" "version" "classifier" "repos" "url" ]
|
||||
// { urls = urls_; name = "${name_}.jar"; }
|
||||
);
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
@ -76,7 +69,7 @@ in
|
||||
# packages packages that mention this derivation in their buildInputs.
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/java
|
||||
ln -s ${jar} $out/share/java/${artifactId_}-${version}${classifier}.jar
|
||||
ln -s ${jar} $out/share/java/${artifactId}-${version}.jar
|
||||
'';
|
||||
# We also add a `jar` attribute that can be used to easily obtain the path
|
||||
# to the downloaded jar file.
|
||||
|
Loading…
Reference in New Issue
Block a user