diff options
author | superherointj <5861043+superherointj@users.noreply.github.com> | 2024-06-09 10:59:06 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-09 10:59:06 -0300 |
commit | 21f2d189e40ef88e16d4e4cee1b70eccd37c18c9 (patch) | |
tree | 96798aea6b21e6941edd60adf6331684334934bb /pkgs/development/tools/build-managers | |
parent | ba90b227d5de6fb9b17f9a6c07d189c50109edea (diff) | |
parent | 0fb204103940dc4ec7d0b1e604b832883cabcc1f (diff) |
Merge pull request #316764 from atorres1985-contrib/maven-refactor
Maven: refactor
Diffstat (limited to 'pkgs/development/tools/build-managers')
-rw-r--r-- | pkgs/development/tools/build-managers/apache-maven/build-package.nix | 98 | ||||
-rw-r--r-- | pkgs/development/tools/build-managers/apache-maven/default.nix | 50 |
2 files changed, 0 insertions, 148 deletions
diff --git a/pkgs/development/tools/build-managers/apache-maven/build-package.nix b/pkgs/development/tools/build-managers/apache-maven/build-package.nix deleted file mode 100644 index f9ff54696dfe9..0000000000000 --- a/pkgs/development/tools/build-managers/apache-maven/build-package.nix +++ /dev/null @@ -1,98 +0,0 @@ -{ lib -, stdenv -, maven -}: - -{ src -, sourceRoot ? null -, buildOffline ? false -, doCheck ? true -, patches ? [ ] -, pname -, version -, mvnHash ? "" -, mvnFetchExtraArgs ? { } -, mvnDepsParameters ? "" -, manualMvnArtifacts ? [ ] -, manualMvnSources ? [ ] -, mvnParameters ? "" -, ... -} @args: - -# originally extracted from dbeaver -# created to allow using maven packages in the same style as rust - -let - mvnSkipTests = lib.optionalString (!doCheck) "-DskipTests"; - fetchedMavenDeps = stdenv.mkDerivation ({ - name = "${pname}-${version}-maven-deps"; - inherit src sourceRoot patches; - - nativeBuildInputs = [ - maven - ] ++ args.nativeBuildInputs or [ ]; - - buildPhase = '' - runHook preBuild - '' + lib.optionalString buildOffline '' - mvn de.qaware.maven:go-offline-maven-plugin:1.2.8:resolve-dependencies -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 - - for artifactId in ${builtins.toString manualMvnSources} - do - group=$(echo $artifactId | cut -d':' -f1) - artifact=$(echo $artifactId | cut -d':' -f2) - echo "downloading manual sources $artifactId" - mvn dependency:sources -DincludeGroupIds="$group" -DincludeArtifactIds="$artifact" -Dmaven.repo.local=$out/.m2 - done - '' + lib.optionalString (!buildOffline) '' - mvn package -Dmaven.repo.local=$out/.m2 ${mvnSkipTests} ${mvnParameters} - '' + '' - runHook postBuild - ''; - - # keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside - installPhase = '' - runHook preInstall - - find $out -type f \( \ - -name \*.lastUpdated \ - -o -name resolver-status.properties \ - -o -name _remote.repositories \) \ - -delete - - runHook postInstall - ''; - - # don't do any fixup - dontFixup = true; - outputHashAlgo = if mvnHash != "" then null else "sha256"; - outputHashMode = "recursive"; - outputHash = mvnHash; - } // mvnFetchExtraArgs); -in -stdenv.mkDerivation (builtins.removeAttrs args [ "mvnFetchExtraArgs" ] // { - inherit fetchedMavenDeps; - - nativeBuildInputs = args.nativeBuildInputs or [ ] ++ [ - maven - ]; - - buildPhase = '' - runHook preBuild - - mvnDeps=$(cp -dpR ${fetchedMavenDeps}/.m2 ./ && chmod +w -R .m2 && pwd) - mvn package -o -nsu "-Dmaven.repo.local=$mvnDeps/.m2" ${mvnSkipTests} ${mvnParameters} - - runHook postBuild - ''; - - meta = args.meta or { } // { - platforms = args.meta.platforms or maven.meta.platforms; - }; -}) diff --git a/pkgs/development/tools/build-managers/apache-maven/default.nix b/pkgs/development/tools/build-managers/apache-maven/default.nix deleted file mode 100644 index c8b5fdaa04a95..0000000000000 --- a/pkgs/development/tools/build-managers/apache-maven/default.nix +++ /dev/null @@ -1,50 +0,0 @@ -{ lib -, stdenvNoCC -, fetchurl -, jdk -, makeWrapper -, callPackage -}: - -assert jdk != null; - -stdenvNoCC.mkDerivation (finalAttrs: { - pname = "apache-maven"; - version = "3.9.6"; - - src = fetchurl { - url = "mirror://apache/maven/maven-3/${finalAttrs.version}/binaries/${finalAttrs.pname}-${finalAttrs.version}-bin.tar.gz"; - hash = "sha256-bu3SyuNibWrTpcnuMkvSZYU9ZCl/B/AzQwdVvQ4MOks="; - }; - - sourceRoot = "."; - - nativeBuildInputs = [ makeWrapper ]; - - installPhase = '' - runHook preInstall - - mkdir -p $out/maven - cp -r ${finalAttrs.pname}-${finalAttrs.version}/* $out/maven - - makeWrapper $out/maven/bin/mvn $out/bin/mvn \ - --set-default JAVA_HOME "${jdk}" - makeWrapper $out/maven/bin/mvnDebug $out/bin/mvnDebug \ - --set-default JAVA_HOME "${jdk}" - - runHook postInstall - ''; - - passthru.buildMavenPackage = callPackage ./build-package.nix { - maven = finalAttrs.finalPackage; - }; - - meta = with lib; { - mainProgram = "mvn"; - description = "Build automation tool (used primarily for Java projects)"; - homepage = "https://maven.apache.org/"; - license = licenses.asl20; - platforms = platforms.unix; - maintainers = with maintainers; [ cko ]; - }; -}) |