Skip to content

grab/grazel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grazel

Grazel stands for Gradle to Bazel. A Gradle plugin to migrate Android projects to Bazel build system in an incremental and automated fashion.

Maven Central

Components

  • Gradle plugin
  • A Kotlin Starlark DSL to generate Starlark code in a type-safe way.
  • Grab Bazel Common - Custom rules to bridge the gap between Gradle/Bazel.

Features

  • Generates BUILD.bazel and WORKSPACE from Gradle configuration
  • Powered by Grab Bazel Common - custom Bazel rules for Android/Kotlin
  • Gradle remains the source of truth and minimal code changes required on Gradle side.

For documentation and usage instructions, please visit website.

How it works

Grazel reads your Gradle configuration and generates equivalent Bazel build scripts. Running ./gradlew migrateToBazel produces BUILD.bazel files for each module.

For example, for the following Gradle configuration:

plugins {
    id("com.android.library")
    id("kotlin-android")
}

android {
    namespace = "com.example.mylibrary"

    defaultConfig {
        manifestPlaceholders = [minSdkVersion: "21"]
    }

    sourceSets {
        debug {
            res.srcDirs += "src/debug/res"
        }
    }

    lint {
        baseline = file("lint_baseline.xml")
    }
}

dependencies {
    implementation(project(":core"))
    implementation("androidx.appcompat:appcompat:1.6.1")
}

Grazel's migrateToBazel task generates the following build script:

load("@grab_bazel_common//rules:defs.bzl", "android_library")

android_library(
    name = "my-library-debug",
    srcs = glob(["src/main/java/**/*.kt"]),
    custom_package = "com.example.mylibrary",
    manifest = "src/main/AndroidManifest.xml",
    manifest_values = {
        "minSdkVersion": "21",
    },
    resource_sets = {
        "main": {
            "res": "src/main/res",
            "manifest": "src/main/AndroidManifest.xml",
        },
        "debug": {
            "res": "src/debug/res",
        },
    },
    lint_options = {
        "enabled": True,
        "baseline": "lint_baseline.xml",
        "config": "//:lint.xml",
    },
    visibility = ["//visibility:public"],
    deps = [
        "//core:core-debug",
        "@maven//:androidx_appcompat_appcompat",
    ],
)

Grazel also generates android_unit_test and android_instrumentation_binary targets for testing. Other supported features include flavors, mapping correct dependency data to Bazel, Dagger, Databinding, and Jetpack Compose etc

See the documentation for the full list of capabilities.

Resources

License

Copyright 2022 Grabtaxi Holdings PTE LTD (GRAB)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

A tool to migrate Android projects from Gradle to Bazel incrementally and automatically

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 15