Clone this repo:

Branches

  1. 68aa614 Roll android_deps from Ij_VXMBwIhYiJfAHB... to 2hih_vvXKUPFfw6rX... by chromium-autoroll · 2 days ago main master
  2. 823c0ec android_deps: Add license overrides for commonmark and safere by Andrew Grieve · 2 days ago
  3. ee38be9 Android: Use kotlin-stdlib from //third_party/android_deps by Andrew Grieve · 2 days ago
  4. d83d43e Manual roll android_deps from Z0vj7XyKKJ7zK... to Ij_VXMBwIhYiJfAH... by Andrew Grieve · 2 days ago
  5. fca5a32 android_deps: Add an alias target for kotlin_stdlib by Andrew Grieve · 3 days ago

Android Deps

Chromium's way to pull prebuilt .jar / .aar files from Maven.

There are 2 roots for libraries:

  1. //third_party/androidx

  2. //third_party/android_deps

    • Contains all other libraries, listed in //third_party/android_deps/build.gradle.template
    • Also contains the scripts and gradle plugin used by both roots
    • All libraries are combined into a single CIPD instance by android-androidx-packager (out of convenience).
    • Auto-rolled by android-deps-chromium

This system supports deps between roots, but since they roll separately, such deps can require manually rolling multiple roots atomically, and sometimes explicitly adding dependent libraries to build.gradle{.template} files.

Adding a new Library

See first: //docs/adding_to_third_party.md.

For AndroidX libries, see //third_party/androidx/README.md

Adding an Autorolled Library

  1. Add the gradle entry for the desired target to //third_party/android_deps/build.gradle.template
  2. Do a trial run (downloads files locally):
    third_party/android_deps/fetch_all.py --local
    
  3. Assuming it works fine, upload & submit your change to build.gradle.template
  4. Wait for the android-androidx-packager and android-deps-chromium to run (or trigger the packager manually to expedite)

Common Issues

Missing Metadata

E.g. missing license, HTML in license, missing URL or description:

BUILD.gn Needs Customization

  • For AndroidX, add an entry to //third_party/androidx/customizations.gni
  • For others, add an entry to addSpecialTreatment(), or for hand-written targets, edit //third_party/android_deps/overrides.gni (BUILD.gn is overwritten by the roller)

Implementation Notes

The script invokes a Gradle plugin to leverage its dependency resolution features. An alternative way to implement it is to mix gradle to purely fetch dependencies and their pom.xml files, and use Python to process and generate the files. This approach was not as successful, as some information about the dependencies does not seem to be available purely from the POM file, which resulted in expecting dependencies that gradle considered unnecessary. This is especially true nowadays that pom.xml files for many dependencies are no longer maintained by the package authors.

Groovy Style Guide

The groovy code in //third_party/android_deps/buildSrc/src/main/groovy is best edited using Android Studio (ASwB works too). This code can be auto-formatted by using Android Studio's code formatting actions.

The easiest way to find these actions is using Ctrl+Shift+A and then typing the name of the action to be performed (e.g. reformat). Another easy way is setting up Settings>Tools>Actions on Save>Reformat code and ..>Optimize imports.

The current code is formatted using a specific code style, you can import //third_party/android_deps/Chromium_Groovy.xml via Settings>Editor>Code Style>[settings gear]>Import Scheme....