status-react/nix/deps/gradle
Jakub Sokołowski 939ce8bef5
nix: Upgrade Android SDK, use nixpkgs master
This makes use of the refactoring of Android SDK done in:
https://github.com/NixOS/nixpkgs/pull/89775

Which allows us to drop the use of our own fork of `nixpkgs`.

Android Upgrades:
* Build Tools - `29.0.2` to `30.0.3`
* Platform Tools - `29.0.6` to `30.0.5`
* NDK Bundle - `21.0.6113669` to `21.3.6528147`

Other Upgrades:
* Git - `2.28.0` to `2.29.2`
* Go - `1.14.7` to `1.14.13`
* Clojure - `1.10.1.645` to `1.10.1.763`
* NodeJS - `12.18.3` to `12.20.1`
* Yarn - `1.22.4` to `1.22.10`
* OpenJDK - `8u265-ga` to `8u272-b10`
* PatchElf - `0.11` to `0.12`
* CoreUtils - `8.31` to `8.32`

Signed-off-by: Jakub Sokołowski <jakub@status.im>
2021-01-13 15:35:59 +01:00
..
README.md nix: add a way to deal with new gradle version to docs 2020-11-27 14:56:42 +01:00
default.nix nix: refactor loading of node.js modules 2020-05-15 16:19:27 +02:00
deps.json nix: Upgrade Android SDK, use nixpkgs master 2021-01-13 15:35:59 +01:00
deps.list Add react-native-fast-image for external assets 2020-12-25 15:03:59 +03:00
deps.urls nix: Upgrade Android SDK, use nixpkgs master 2021-01-13 15:35:59 +01:00
generate.sh nix: add a way to deal with new gradle version to docs 2020-11-27 14:56:42 +01:00
get_deps.sh nix: replace grep and sed with AWK for parsing Gradle deps 2020-05-25 19:34:56 +02:00
get_projects.sh nix: refactor updating Gradle dependencies 2020-05-14 09:46:30 +02:00
gradle_parser.awk nix: replace grep and sed with AWK for parsing Gradle deps 2020-05-25 19:34:56 +02:00
proj.list Add react-native-fast-image for external assets 2020-12-25 15:03:59 +03:00
url2json.sh nix: replace grep and sed with AWK for parsing Gradle deps 2020-05-25 19:34:56 +02:00

README.md

Description

This directory contains the tools and the data that allows Nix to manage Gradle project dependencies for the app.

Usage

Simply calling generate.sh should result in a deps.json file which is used in the derivation that provides Gradle dependencies when building the Android app.

You can see in nix/mobile/android/release.nix that it's used via the -Dmaven.repo.local='${deps.gradle}' Gradle flag.

Files

First we have the files that store data on Gradle dependencies:

  • proj.list - List of projects of which our Gradle project consists.
  • deps.list - List of dependencies for our project and sub-projects.
  • deps.urls - List of URLs to POMs for all of the dependencies.
  • deps.json - Final file containing all of the necessary data for Nix.

Generating scripts:

  • generate.sh - Main script which generates all the above files.
  • get_projects.sh - Calls Gradle to get a list of sub-projects.
  • get_deps.sh - Calls Gradle to get all the dependencies of sub-projects.
  • gradle_parser.awk - An AWK script that parses above Gradle output.
  • url2json.sh - Converts the list of URLs into a format consumable by Nix.

Finally we have the Nix derivation in default.nix which produces a derivation with all of the Gradle project dependencies:

 $ nix-build --no-out-link --attr pkgs.deps.gradle default.nix       
/nix/store/57g95ik19k6gs5w68yid3hzhsax60i3m-status-react-maven-deps

 $ ls -l /nix/store/57g95ik19k6gs5w68yid3hzhsax60i3m-status-react-maven-deps | head -n 5 
total 32
dr-xr-xr-x  3 root root  3 Jan  1  1970 android
dr-xr-xr-x 35 root root 35 Jan  1  1970 androidx
dr-xr-xr-x 15 root root 15 Jan  1  1970 com
dr-xr-xr-x  3 root root  3 Jan  1  1970 commons-cli
...

Dependencies

One dependency these scripts require is the go-maven-resolver which turns a list of packages into list of all URLs of POMs for them and their dependencies.

Known Issues

One edge case that is currently not handled by this setup is an addition of a new dependency that requires a version of Gradle we don't have. In that case running make nix-update-gradle would fail with:

AILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':react-native-example-project'.
> Could not resolve all artifacts for configuration ':react-native-example-project:classpath'.
   > Could not find com.android.tools.build:gradle:3.4.0.
     Searched in the following locations:
       - file:/nix/store/34a4qd5qhg2a9kq6a0q9lp7hgmi48q4x-status-react-maven-deps/com/android/tools/build/gradle/3.4.0/gradle-3.4.0.pom
       - file:/nix/store/34a4qd5qhg2a9kq6a0q9lp7hgmi48q4x-status-react-maven-deps/com/android/tools/build/gradle/3.4.0/gradle-3.4.0.jar
     Required by:
         project :react-native-example-project

This happens because get_projects.sh and get_deps.sh depend on running Gradle to generate their output, and that will not work because Gradle cannot find the matching JAR for the new dependency.

A manual solution would involve adding that specific Gradle version into deps.urls:

echo com.android.tools.build:gradle:3.4.0 | go-maven-resolver >> nix/deps/gradle/deps.urls

Then you'll need to remove duplicates and sort deps.urls:

sort -o nix/deps/gradle/deps.urls nix/deps/gradle/deps.urls

And finally generate the deps.json for Nix using:

nix/deps/gradle/generate.sh gen_deps_json