Skip to content

Commit

Permalink
For recent versions of Gradle, use .convention to provide the default (
Browse files Browse the repository at this point in the history
…#2803)

This allows to call `customTypeMap.put()`
  • Loading branch information
martinbonnin authored Dec 21, 2020
1 parent 54389d1 commit d47fad5
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.SetProperty
import org.gradle.util.GradleVersion
import javax.inject.Inject

abstract class DefaultCompilerParams @Inject constructor(objects: ObjectFactory) : CompilerParams {
Expand Down Expand Up @@ -42,11 +43,16 @@ abstract class DefaultCompilerParams @Inject constructor(objects: ObjectFactory)
abstract override val alwaysGenerateTypesMatching: SetProperty<String>

init {
// see https://github.com/gradle/gradle/issues/7485
// TODO replace with `convention(null)` when we can target Gradle 6.2
customTypeMapping.set(null as Map<String, String>?)
sealedClassesForEnumsMatching.set(null as List<String>?)
alwaysGenerateTypesMatching.set(null as Set<String>?)
if (GradleVersion.current() >= GradleVersion.version("6.2")) {
// This allows users to call customTypeMapping.put("Date", "java.util.Date")
// see https://github.com/gradle/gradle/issues/7485
customTypeMapping.convention(null as Map<String, String>?)
sealedClassesForEnumsMatching.convention(null as List<String>?)
alwaysGenerateTypesMatching.convention(null as Set<String>?)
} else {
customTypeMapping.set(null as Map<String, String>?)
sealedClassesForEnumsMatching.set(null as List<String>?)
alwaysGenerateTypesMatching.set(null as Set<String>?)
}
}

}

0 comments on commit d47fad5

Please sign in to comment.