2022-03-30 09:31:56 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, maven
|
|
|
|
}:
|
|
|
|
|
|
|
|
{ src
|
2023-07-15 17:15:38 +00:00
|
|
|
, patches ? [ ]
|
2022-03-30 09:31:56 +00:00
|
|
|
, pname
|
|
|
|
, version
|
2023-07-15 17:15:38 +00:00
|
|
|
, mvnHash ? ""
|
|
|
|
, mvnFetchExtraArgs ? { }
|
2022-03-30 09:31:56 +00:00
|
|
|
, mvnParameters ? ""
|
|
|
|
, ...
|
|
|
|
} @args:
|
|
|
|
|
|
|
|
# originally extracted from dbeaver
|
|
|
|
# created to allow using maven packages in the same style as rust
|
|
|
|
|
|
|
|
stdenv.mkDerivation (rec {
|
|
|
|
fetchedMavenDeps = stdenv.mkDerivation ({
|
|
|
|
name = "${pname}-${version}-maven-deps";
|
2023-07-15 17:15:38 +00:00
|
|
|
inherit src patches;
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
nativeBuildInputs = [
|
2022-03-30 09:31:56 +00:00
|
|
|
maven
|
|
|
|
];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
mvn package -Dmaven.repo.local=$out/.m2 ${mvnParameters}
|
|
|
|
'';
|
|
|
|
|
|
|
|
# keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
|
|
|
|
installPhase = ''
|
2023-07-15 17:15:38 +00:00
|
|
|
find $out -type f \( \
|
|
|
|
-name \*.lastUpdated \
|
|
|
|
-o -name resolver-status.properties \
|
|
|
|
-o -name _remote.repositories \) \
|
2022-03-30 09:31:56 +00:00
|
|
|
-delete
|
|
|
|
'';
|
|
|
|
|
|
|
|
# don't do any fixup
|
|
|
|
dontFixup = true;
|
2023-07-15 17:15:38 +00:00
|
|
|
outputHashAlgo = if mvnHash != "" then null else "sha256";
|
2022-03-30 09:31:56 +00:00
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHash = mvnHash;
|
|
|
|
} // mvnFetchExtraArgs);
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
mvnDeps=$(cp -dpR ${fetchedMavenDeps}/.m2 ./ && chmod +w -R .m2 && pwd)
|
|
|
|
mvn package --offline "-Dmaven.repo.local=$mvnDeps/.m2" ${mvnParameters}
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
2022-09-30 11:47:45 +00:00
|
|
|
} // builtins.removeAttrs args [ "mvnFetchExtraArgs" ])
|