grab / grazel

A tool to migrate Android projects from Gradle to Bazel incrementally and automatically
https://grab.github.io/grazel/
Other
277 stars 19 forks source link

Implement support for `resource_sets` API in bazel-common #132

Closed arunkumar9t2 closed 3 weeks ago

arunkumar9t2 commented 7 months ago

This PR implements support for resource_sets API introduced in https://github.com/grab/grab-bazel-common/pull/165.

This is done by mapping AGP's AndroidSourceSet to newly added BazelSourceSet. During mapping, existence of the directories are checked for.

After this source, Gradle like variant declaration can be closely mimicked as below and resources, manifest and assets will be merged before actual build begins.

android_binary(
    name = "android_binary_sample",
    srcs = glob([
        "src/main/java/**/*.kt",
    ]),
    custom_package = "com.grab.test",
    manifest = "src/main/AndroidManifest.xml",
    resource_sets = {
        "flavor": {
            "res": "src/flavor/res",
            "manifest": "src/flavor/AndroidManifest.xml",
            "assets": "src/flavor/assets",
        },
        "main": {
            "res": "src/main/res",
            "manifest": "src/main/AndroidManifest.xml",
            "assets": "src/main/assets",
        },
    },
)