Gradle Plugin
Capture bridge messages from a one-time mapping, without Dari calls in your bridge code
The Dari Gradle plugin records bridge traffic without per-call code. You tell it once where your bridge receives requests and where it sends responses. In debug builds it then inserts the same DariInterceptor calls you would otherwise write by hand.
Everything after capture stays the same: storage, the in-app inspector, the desktop app, export and masking.
The plugin is optional. Calling the interceptor yourself, as in Setup, remains the default and keeps working, and both can live in one app.
Where each piece goes
| File | What to put there |
|---|---|
app/build.gradle.kts dependencies { } | dari / dari-noop, the same as for the manual way. The plugin doesn't add them. |
settings.gradle.kts | mavenCentral() in pluginManagement { repositories { } }, so Gradle can find the plugin. |
app/build.gradle.kts (the module that adds dari / dari-noop) | id("io.github.easyhooon.dari") in plugins { }, and the dari { } mapping block. |
Your Application.onCreate() | Dari.setProtobufDecoder(...), only if you capture protobuf payloads. |
| Your bridge code | Nothing. |
The dependencies alone don't turn this on: without the plugin and dari { }, nothing changes. Don't put dari { } in the root build.gradle.kts. A bridge in another module needs the plugin and its own dari { } in that module's build.gradle.kts.
Setup
// settings.gradle.kts
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}// app/build.gradle.kts
plugins {
id("com.android.application")
id("io.github.easyhooon.dari") version "2.7.0"
}
dependencies {
debugImplementation("io.github.easyhooon:dari:2.7.0")
releaseImplementation("io.github.easyhooon:dari-noop:2.7.0")
}
dari {
webToAppRequest("com.example.MainActivity.BridgeInterface", "onBridgeRequest") {
handlerName = arg(0)
requestId = arg(1)
data = arg(2)
}
webToAppResponse("com.example.MainActivity", "sendResponseToWeb") {
handlerName = arg(0)
requestId = arg(1)
success = arg(2)
data = arg(3)
}
}Use the same version for the plugin, dari and dari-noop.
The mapping works best when your bridge has one request entry point and one response sender. The interceptor guide recommends that layout for manual logging too.
Next
- How it works: What the plugin does during the build, and ASM
- Mapping reference: Functions, fields and expressions for
dari { } - Recipes: Mappings for common bridge layouts
- Performance: Capture cost and build time
- Rules and limits: What gets transformed, build warnings, what is not covered