From 43da5a60fe26e62b0c76952f53f670e60a632d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Tue, 16 Nov 2021 11:10:12 +0100 Subject: [PATCH] nix: make url2json.sh parse POM content for packaging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise we can download a JAR when an AAR is necessary. Signed-off-by: Jakub SokoĊ‚owski --- nix/deps/gradle/url2json.sh | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/nix/deps/gradle/url2json.sh b/nix/deps/gradle/url2json.sh index bfbeac30e8..5cad2e5d5d 100755 --- a/nix/deps/gradle/url2json.sh +++ b/nix/deps/gradle/url2json.sh @@ -55,26 +55,6 @@ fi # Get the relative path without full URL OBJ_REL_NAME="${OBJ_REL_URL#${REPO_URL}/}" -OBJ_NIX_FETCH_OUT=$(nix_fetch "${OBJ_REL_URL}.jar") -# Dependency might be a JAR or an AAR -if [[ ${?} -eq 0 ]]; then - # Some deps have only a POM, nor JAR or AAR - OBJ_TYPE="jar" - OBJ_PATH=$(get_nix_path "${OBJ_NIX_FETCH_OUT}") - OBJ_SHA256=$(get_nix_sha "${OBJ_NIX_FETCH_OUT}") - OBJ_SHA1=$(get_sha1 "${OBJ_PATH}") -else - OBJ_NIX_FETCH_OUT=$(nix_fetch "${OBJ_REL_URL}.aar") - if [[ ${?} -eq 0 ]]; then - OBJ_TYPE="aar" - OBJ_PATH=$(get_nix_path "${OBJ_NIX_FETCH_OUT}") - OBJ_SHA256=$(get_nix_sha "${OBJ_NIX_FETCH_OUT}") - OBJ_SHA1=$(get_sha1 "${OBJ_PATH}") - else - OBJ_TYPE="pom" - fi -fi - # Both JARs and AARs have a POM POM_NIX_FETCH_OUT=$(nix_fetch "${OBJ_REL_URL}.pom") POM_PATH=$(get_nix_path "${POM_NIX_FETCH_OUT}") @@ -85,6 +65,23 @@ fi POM_SHA256=$(get_nix_sha "${POM_NIX_FETCH_OUT}") POM_SHA1=$(get_sha1 "${POM_PATH}") +# Identify packaging type, JAR, AAR, or just POM. +OBJ_TYPE=$(grep -oP '\K[^<]+' "${POM_PATH}") +# Bundle is a JAR made using maven-bundle-plugin. +case "${OBJ_TYPE}" in + ''|'bundle') OBJ_TYPE=jar;; + 'aar.asc') OBJ_TYPE=aar;; +esac +# Some dependencies have only a POM file. +if [[ "${OBJ_TYPE}" != "pom" ]]; then + OBJ_NIX_FETCH_OUT=$(nix_fetch "${OBJ_REL_URL}.${OBJ_TYPE}") + if [[ ${?} -eq 0 ]]; then + OBJ_PATH=$(get_nix_path "${OBJ_NIX_FETCH_OUT}") + OBJ_SHA256=$(get_nix_sha "${OBJ_NIX_FETCH_OUT}") + OBJ_SHA1=$(get_sha1 "${OBJ_PATH}") + fi +fi + # Format into a Nix attrset entry echo -ne " {