Skip to content

Commit 6bd53fd

Browse files
committed
Add possibility to disable auto-application of Moshi dependency
1 parent bca14ed commit 6bd53fd

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

moshi-ir/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ plugins {
4040
moshi {
4141
// Opt-in to enable moshi-sealed, disabled by default.
4242
enableSealed.set(true)
43+
// Opt-out to disable auto-application of Moshi dependency, enabled by default.
44+
applyMoshi.set(false)
4345
}
4446
```
4547

moshi-ir/moshi-gradle-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/gradle/MoshiGradlePluginExtension.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ abstract class MoshiPluginExtension @Inject constructor(objects: ObjectFactory)
2121
val generatedAnnotation: Property<String> = objects.property(String::class.java)
2222
/** Enables moshi-sealed code gen. Disabled by default. */
2323
val enableSealed: Property<Boolean> = objects.property(Boolean::class.java).convention(false)
24+
/**
25+
* Set this property to false to disable auto-application of the Moshi dependency. Enabled by
26+
* default.
27+
*/
28+
val applyMoshi: Property<Boolean> = objects.property(Boolean::class.java).convention(true)
2429
}

moshi-ir/moshi-gradle-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/gradle/MoshiGradleSubplugin.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,13 @@ class MoshiGradleSubplugin : KotlinCompilerPluginSupportPlugin {
106106
val generatedAnnotation = extension.generatedAnnotation.orNull
107107

108108
// Minimum Moshi version
109-
project.dependencies.add(
110-
kotlinCompilation.implementationConfigurationName,
111-
"com.squareup.moshi:moshi:1.13.0",
112-
)
109+
val applyMoshi = extension.applyMoshi.get()
110+
if (applyMoshi) {
111+
project.dependencies.add(
112+
kotlinCompilation.implementationConfigurationName,
113+
"com.squareup.moshi:moshi:1.13.0",
114+
)
115+
}
113116

114117
val enableSealed = extension.enableSealed.get()
115118
if (enableSealed) {

0 commit comments

Comments
 (0)