Introduction
Scabbard is a tool to visualize the application graph produced by Dagger or Hilt.
Set up and configuration
- Add dependency to Scabbard plugin in the project-level
build.gradle
file.
buildscript {
// ...
maven {
url "https://plugins.gradle.org/m2/"
}
// ...
}
dependencies {
// ...
classpath "gradle.plugin.dev.arunkumar:scabbard-gradle-plugin:0.4.0"
// ...
}
}
- Apply plugin in the app-level
build.gradle
file.
apply plugin: "scabbard.gradle"
scabbard {
enabled = true
outputFormat "svg"
}
- Make Project (Cmd + F9)
- Check the generated SVG files under the output folder, which defaults to:
build/tmp/kapt3/classes/debug/scabbard/
.
Here is an example output for theAppComponent
which locates in
app/build/tmp/kapt3/classes/debug/scabbard/com.example.android.dagger.di.AppComponent.svg
NOTE: The app graph is available until at least more than one entry points were created. That said, for Dagger, you have to create at least one component and all dependencies for it. For Hilt, you have to define at least one entry point thru either AndroidEntryPoiont
or EntryPoint
.
@Component(modules = [StorageModule::class])
interface AppComponent {
fun inject(activity: RegistrationActivity)
fun inject(fragment: EnterDetailsFragment)
@Component.Factory
interface Factory {
fun create(@BindsInstance context: Context): AppComponent
}
}
@Module
interface StorageModule {
@Binds
fun provideStorage(storage: SharedPreferencesStorage): Storage
}