Merge: zmap: 4.2.0 -> 4.3.1 (#364578)
[NixPkgs.git] / pkgs / by-name / at / atlassian-plugin-sdk / package.nix
blob8f4becdd99147a7e96ad08cbed840978a2dd7e33
2   lib,
3   stdenv,
4   fetchurl,
5   makeWrapper,
6   jdk11,
7   atlassian-plugin-sdk,
8   testers,
9   writeShellScript,
10   common-updater-scripts,
11   curl,
12   jq,
13   yq,
16 let
17   mavenGroupIdUrl = "https://packages.atlassian.com/maven/public/com/atlassian/amps";
20 stdenv.mkDerivation rec {
21   pname = "atlassian-plugin-sdk";
22   version = "9.1.1";
24   src = fetchurl {
25     url = "${mavenGroupIdUrl}/atlassian-plugin-sdk/${version}/atlassian-plugin-sdk-${version}.tar.gz";
26     hash = "sha256-sEAe1eif9qXvIOu8RfZ4MWngEO5yCjU74g4Crd85J3Y=";
27   };
29   nativeBuildInputs = [ makeWrapper ];
30   buildInputs = [ jdk11 ];
32   unpackPhase = "tar -xzf $src";
34   installPhase = ''
35     runHook preInstall
37     mkdir -p $out
38     cp -r atlassian-plugin-sdk-${version}/* $out
39     rm $out/bin/*.bat
41     for file in "$out"/bin/*; do
42       wrapProgram $file --set JAVA_HOME "${jdk11}"
43     done
45     runHook postInstall
46   '';
48   passthru = {
49     tests.version = testers.testVersion {
50       package = atlassian-plugin-sdk;
51       command = "atlas-version";
52       version = "atlassian-plugin-sdk-${version}";
53     };
55     updateScript = writeShellScript "update-atlassian-plugin-sdk" ''
56       set -o errexit
57       export PATH="${
58         lib.makeBinPath [
59           curl
60           jq
61           yq
62           common-updater-scripts
63         ]
64       }:$PATH"
66       NEW_VERSION=$(curl -s ${mavenGroupIdUrl}/atlassian-plugin-sdk/maven-metadata.xml | xq -r '.metadata.versioning.latest')
68       if [[ "${version}" = "$NEW_VERSION" ]]; then
69           echo "The new version same as the old version."
70           exit 0
71       fi
73       DOWNLOAD_URL="${mavenGroupIdUrl}/atlassian-plugin-sdk/${version}/atlassian-plugin-sdk-$NEW_VERSION.tar.gz"
74       NIX_HASH=$(nix hash to-sri sha256:$(nix-prefetch-url $DOWNLOAD_URL))
76       update-source-version "atlassian-plugin-sdk" "$NEW_VERSION" "$NIX_HASH" "$DOWNLOAD_URL"
77     '';
78   };
80   meta = with lib; {
81     description = "Atlassian Plugin SDK";
82     homepage = "https://developer.atlassian.com/server/framework/atlassian-sdk/";
83     license = licenses.asl20;
84     maintainers = with maintainers; [ pathob ];
85     platforms = platforms.linux;
86     mainProgram = "atlas-mvn";
87   };