Add support for aar_import_external and aar_maven_import_external

Usage example:

```python
# In WORKSPACE
load("@bazel_tools//tools/build_defs/repo:android.bzl", "aar_import_external", "aar_maven_import_external")

# Specify the URL directly:
aar_import_external(
    name = "com_android_support_preference_v14_25_1_0",                              # required
    licenses = ["notice"],                                                           # required
    aar_urls = [                                                                     # required
        "https://dl.google.com/dl/android/maven2/com/android/support/preference-v14/25.1.0/preference-v14-25.1.0.aar"
    ],
    aar_sha256 = "442473fe5c395ebef26c14eb01d17ceda33ad207a4cc23a32a2ad95b87edfabb", # optional or empty string
    deps = [                                                                         # optional or empty list
        "@com_android_support_recyclerview_v7_25_1_0//aar",
        "@com_android_support_appcompat_v7_25_1_0//aar",
        "@com_android_support_preference_v7_25_1_0//aar",
        "@com_android_support_support_v4_25_1_0//aar",
    ],
)

# Or, specify the artifact coordinate:
aar_maven_import_external(
    name = "com_android_support_preference_v14_25_1_0",                         # required
    artifact = "com.android.support.test:preference-v14:25.1.0",                # required
    sha256 = "442473fe5c395ebef26c14eb01d17ceda33ad207a4cc23a32a2ad95b87edfabb" # optional or empty string
    licenses = ["notice"],                                                      # required
    server_urls = ["https://maven.google.com"],                                 # required
    deps = [                                                                    # optional or empty list
        "@com_android_support_recyclerview_v7_25_1_0//aar",
        "@com_android_support_appcompat_v7_25_1_0//aar",
        "@com_android_support_preference_v7_25_1_0//aar",
        "@com_android_support_support_v4_25_1_0//aar",
    ],
)

# In BUILD.bazel
android_library(
    name = "foo",
    srcs = [...],
    deps = [
        "@com_android_support_preference_v14_25_1_0//aar",
    ],
)
```

To test this out with gmaven_rules, change the `load` statement in https://github.com/bazelbuild/gmaven_rules/blob/master/gmaven.bzl to

```
load('@bazel_tools//tools/build_defs/repo:android.bzl', 'aar_import_external')
load('@bazel_tools//tools/build_defs/repo:java.bzl', 'java_import_external')
```

Fixes https://github.com/bazelbuild/bazel/issues/4654

RELNOTES: New rules for importing Android dependencies: `aar_import_external` and `aar_maven_import_external`. `aar_import_external` enables specifying external AAR dependencies using a list of HTTP URLs for the artifact. `aar_maven_import_external` enables specifying external AAR dependencies using the artifact coordinate and a list of server URLs.

Closes #5319.

Change-Id: I9517e68ab78f2e30fb6ceabfe3b35061c585d607
PiperOrigin-RevId: 199839047
3 files changed
tree: 2d007328e8b45f57b1a5c9ce44cea56eb6a17bec
  1. .bazelci/
  2. examples/
  3. scripts/
  4. site/
  5. src/
  6. third_party/
  7. tools/
  8. .gitattributes
  9. .gitignore
  10. AUTHORS
  11. BUILD
  12. CHANGELOG.md
  13. combine_distfiles.py
  14. combine_distfiles_to_tar.sh
  15. compile.sh
  16. CONTRIBUTING.md
  17. CONTRIBUTORS
  18. distdir.bzl
  19. ISSUE_TEMPLATE.md
  20. LICENSE
  21. README.md
  22. WORKSPACE
README.md

Bazel

{Fast, Correct} - Choose two

Build and test software of any size, quickly and reliably.

  • Speed up your builds and tests: Bazel only rebuilds what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.

  • One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.

  • Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.

  • Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.

Getting Started

Documentation

Contributing to Bazel

See CONTRIBUTING.md

Build status

Bazel is released in ‘Beta’. See the product roadmap to learn about the path toward a stable 1.0 release.