Merge pull request #255243 from tricktron/f-refactor-buildMavenPackage

buildMavenPackage: add offline build feature flag
This commit is contained in:
Weijia Wang 2023-09-20 16:46:42 +02:00 committed by GitHub
commit 5bd09d53f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,11 +5,14 @@
{ src
, sourceRoot ? null
, buildOffline ? false
, patches ? [ ]
, pname
, version
, mvnHash ? ""
, mvnFetchExtraArgs ? { }
, mvnDepsParameters ? ""
, manualMvnArtifacts ? [ ]
, mvnParameters ? ""
, ...
} @args:
@ -28,9 +31,17 @@ let
buildPhase = ''
runHook preBuild
'' + lib.optionalString buildOffline ''
mvn dependency:go-offline -Dmaven.repo.local=$out/.m2 ${mvnDepsParameters}
for artifactId in ${builtins.toString manualMvnArtifacts}
do
echo "downloading manual $artifactId"
mvn dependency:get -Dartifact="$artifactId" -Dmaven.repo.local=$out/.m2
done
'' + lib.optionalString (!buildOffline) ''
mvn package -Dmaven.repo.local=$out/.m2 ${mvnParameters}
'' + ''
runHook postBuild
'';
@ -65,7 +76,7 @@ stdenv.mkDerivation (builtins.removeAttrs args [ "mvnFetchExtraArgs" ] // {
runHook preBuild
mvnDeps=$(cp -dpR ${fetchedMavenDeps}/.m2 ./ && chmod +w -R .m2 && pwd)
mvn package --offline "-Dmaven.repo.local=$mvnDeps/.m2" ${mvnParameters}
mvn package -o -nsu "-Dmaven.repo.local=$mvnDeps/.m2" ${mvnParameters}
runHook postBuild
'';