Skip to content

Commit

Permalink
Add possibility to disable auto-application of Moshi dependency (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
plnice authored Sep 16, 2024
1 parent bca14ed commit 4f2af93
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions moshi-ir/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ plugins {
moshi {
// Opt-in to enable moshi-sealed, disabled by default.
enableSealed.set(true)
// Opt-out to disable auto-application of Moshi dependency, enabled by default.
applyMoshiDependency.set(false)
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ abstract class MoshiPluginExtension @Inject constructor(objects: ObjectFactory)
val generatedAnnotation: Property<String> = objects.property(String::class.java)
/** Enables moshi-sealed code gen. Disabled by default. */
val enableSealed: Property<Boolean> = objects.property(Boolean::class.java).convention(false)
/**
* Set this property to false to disable auto-application of the Moshi dependency. Enabled by
* default.
*/
val applyMoshiDependency: Property<Boolean> =
objects.property(Boolean::class.java).convention(true)
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,13 @@ class MoshiGradleSubplugin : KotlinCompilerPluginSupportPlugin {
val generatedAnnotation = extension.generatedAnnotation.orNull

// Minimum Moshi version
project.dependencies.add(
kotlinCompilation.implementationConfigurationName,
"com.squareup.moshi:moshi:1.13.0",
)
val applyMoshiDependency = extension.applyMoshiDependency.get()
if (applyMoshiDependency) {
project.dependencies.add(
kotlinCompilation.implementationConfigurationName,
"com.squareup.moshi:moshi:1.13.0",
)
}

val enableSealed = extension.enableSealed.get()
if (enableSealed) {
Expand Down

0 comments on commit 4f2af93

Please sign in to comment.