Grazel stands for Gradle to Bazel. A Gradle plugin to migrate Android projects
to Bazel build system in an incremental and automated fashion.
- 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.
- Generates
BUILD.bazelandWORKSPACEfrom 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.
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.
- Grab's migration journey from Gradle to Bazel via automation - Build Meetup'21.
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.
