Gradle Plugin
The simplest way to apply Tangle is via the Gradle plugin.
The plugin will automatically apply the Anvil compiler plugin and all required Tangle extensions. By default, the plugin will automatically determine which Tangle dependencies to add by inspecting the module's Androidx dependencies, and adding the corresponding Tangle features.
For example, if a project has declared a Fragments dependency like so:
dependencies {
api("androidx.fragment:fragment")
}
Then Tangle will add the tangle-fragment dependencies:
- com.rickbusarow.tangle:tangle-fragment-api:0.14.1
- com.rickbusarow.tangle:tangle-fragment-compiler:0.14.1
- Kotlin
- Groovy
// settings.gradle.kts
pluginManagement {
repositories {
gradlePluginPortal()
}
}
// root project build.gradle.kts
plugins {
// add Tangle and Anvil versions to the project's classpath
id("com.squareup.anvil") version <anvil_version> apply false
id("com.rickbusarow.tangle") version "0.14.1" apply false
}
// any Android module's build.gradle.kts
plugins {
id("android-library") // or application, etc.
kotlin("android")
id("com.rickbusarow.tangle") version "0.14.1"
}
// settings.gradle
pluginManagement {
repositories {
gradlePluginPortal()
}
}
// root project build.gradle
plugins {
// add Tangle and Anvil versions to the project's classpath
id 'com.squareup.anvil' version <anvil_version> apply false
id 'com.rickbusarow.tangle' version "0.14.1" apply false
}
// any Android module's build.gradle
plugins {
id 'android-library' // or application, etc.
kotlin("android")
id 'com.rickbusarow.tangle'
}
Explicitly defining behavior
This automatic behavior may be overridden by using the tangle { ... }
configuration block.
These settings are prioritized ahead of the automatic configuration. Note that explicitly setting
a feature to true
(enabled) will force the plugin to add dependencies and compiler extensions
which probably aren't needed. This functionality mostly exists for its ability to disable the
Tangle functionality.
- Kotlin
- Groovy
// any Android module's build.gradle.kts
plugins {
id("android-library") // or application, etc.
kotlin("android")
id("com.rickbusarow.tangle") version "0.14.1"
}
// optional
tangle {
// enables the Fragments feature regardless of the project's dependencies
fragmentsEnabled = true // default is null
// disables the Work/WorkManager feature regardless of the project's dependencies
workEnabled = false // default is null
viewModelOptions {
enabled = true // default is null
activitiesEnabled = true // default is null
composeEnabled = true // default is null
fragmentsEnabled = true // default is null
}
}
// any Android module's build.gradle
plugins {
id 'android-library' // or application, etc.
kotlin("android")
id 'com.rickbusarow.tangle'
}
// optional
tangle {
// enables the Fragments feature regardless of the project's dependencies
fragmentsEnabled = true // default is null
// disables the Work/WorkManager feature regardless of the project's dependencies
workEnabled = false // default is null
viewModelOptions {
enabled true // default is null
activitiesEnabled true // default is null
composeEnabled true // default is null
fragmentsEnabled true // default is null
}
}