status-react/nix/deps/gradle/get_deps.sh
Jakub Sokołowski ed4d0a1ed9
nix: refactor updating Gradle dependencies
changes:
- Moved Gradle deps setup to `nix/deps/gradle`
- Dropped `nix/mobile/android/maven-and-npm-deps/maven`
- Used GNU Parallel to optimize `nix/deps/gradle/generate.sh`
- Move Maven+Node shell setup from `release-android.nix` to Android shell
- Moved AAPT2 patching to `nix/pkgs/aapt2`
- Drop `patchPhase` and `gradlew` use from `release-android.nix`
- Simplify symlinking `{mobile,desktop}/js_files/*`
- Add new `nodejs` shell and merge it with `clojure` and `gradle`
- Re-created Gradle deps files with new scripts:
  - `nix/deps/gradle/proj.list`
  - `nix/deps/gradle/deps.list`
  - `nix/deps/gradle/deps.urls`
  - `nix/deps/gradle/deps.nix`

Signed-off-by: Jakub Sokołowski <jakub@status.im>
2020-05-14 09:46:30 +02:00

51 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -Eeu
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
# Gradle needs to be run in 'android' subfolder
cd $GIT_ROOT/android
# AWK script to catch only non-test deps
AWK_SCRIPT='
/^(classpath|[a-zA-Z]+ - .*)$/{
if ($1 ~ "test") { next; }
while ($0!="") { print; getline; }
}
'
# Run the gradle command for a project:
# - ':buildEnvironment' to get build tools
# - ':dependencies' to get direct deps limited those by
# implementation config to avoid test dependencies
DEPS=("${@}")
declare -a BUILD_DEPS
declare -a NORMAL_DEPS
for i in "${!DEPS[@]}"; do
BUILD_DEPS[${i}]="${DEPS[${i}]}:buildEnvironment"
NORMAL_DEPS[${i}]="${DEPS[${i}]}:dependencies"
done
# And clean up the output by:
# - keep only lines that start with \--- or +---
# - drop lines that end with (*) or (n) but don't start with (+)
# - drop lines that refer to a project
# - drop entries starting with `status-im:` like `status-go`
# - drop entries that aren't just the name of the dependency
# - extract the package name and version, ignoring version range indications,
# such as in `com.google.android.gms:play-services-ads:[15.0.1,16.0.0) -> 15.0.1`
./gradlew --no-daemon --console plain \
"${BUILD_DEPS[@]}" \
"${NORMAL_DEPS[@]}" \
| awk "${AWK_SCRIPT}" \
| grep -e '[\\\+]---' \
| sed -E 's;.*[\\\+]--- ([^ ]+:)(.+ -> )?([^ ]+).*$;\1\3;' \
| grep --invert-match -E \
-e '^[a-z]+$' \
-e '^:?[^:]+$' \
-e '--- project :' \
-e '^(#|status-im:)' \
-e '(\+|unspecified)$' \
-e '^[^+].+ \([\*n]\)$'