fetchMavenArtifact: support artifact classifier syntax
This commit is contained in:
parent
c1dfbaa8ad
commit
49c789703c
@ -36,19 +36,28 @@ assert (repos != []) || (url != "") || (urls != []);
|
|||||||
|
|
||||||
|
|
||||||
let
|
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_ =
|
name_ =
|
||||||
with stdenv.lib; concatStrings [
|
with stdenv.lib; concatStrings [
|
||||||
(replaceChars ["."] ["_"] groupId) "_"
|
(replaceChars ["."] ["_"] groupId) "_"
|
||||||
(replaceChars ["."] ["_"] artifactId) "-"
|
(replaceChars ["."] ["_"] artifactId_) "-"
|
||||||
version
|
version
|
||||||
];
|
];
|
||||||
mkJarUrl = repoUrl:
|
mkJarUrl = repoUrl:
|
||||||
with stdenv.lib; concatStringsSep "/" [
|
with stdenv.lib; concatStringsSep "/" [
|
||||||
(removeSuffix "/" repoUrl)
|
(removeSuffix "/" repoUrl)
|
||||||
(replaceChars ["."] ["/"] groupId)
|
(replaceChars ["."] ["/"] groupId)
|
||||||
artifactId
|
artifactId_
|
||||||
version
|
version
|
||||||
"${artifactId}-${version}.jar"
|
"${artifactId_}-${version}${classifier}.jar"
|
||||||
];
|
];
|
||||||
urls_ =
|
urls_ =
|
||||||
if url != "" then [url]
|
if url != "" then [url]
|
||||||
@ -57,7 +66,7 @@ let
|
|||||||
jar =
|
jar =
|
||||||
fetchurl (
|
fetchurl (
|
||||||
builtins.removeAttrs args ["groupId" "artifactId" "version" "repos" "url" ]
|
builtins.removeAttrs args ["groupId" "artifactId" "version" "repos" "url" ]
|
||||||
// { urls = urls_; name = "${name_}.jar"; }
|
// { urls = urls_; name = "${name_}${classifier}.jar"; }
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
@ -67,7 +76,7 @@ in
|
|||||||
# packages packages that mention this derivation in their buildInputs.
|
# packages packages that mention this derivation in their buildInputs.
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/share/java
|
mkdir -p $out/share/java
|
||||||
ln -s ${jar} $out/share/java/${artifactId}-${version}.jar
|
ln -s ${jar} $out/share/java/${artifactId_}-${version}${classifier}.jar
|
||||||
'';
|
'';
|
||||||
# We also add a `jar` attribute that can be used to easily obtain the path
|
# We also add a `jar` attribute that can be used to easily obtain the path
|
||||||
# to the downloaded jar file.
|
# to the downloaded jar file.
|
||||||
|
Loading…
Reference in New Issue
Block a user