maskarade / gradle-android-ribbonizer-plugin

Modifies launcher icons on debug build
https://bintray.com/gfx/maven/ribbonizer-plugin
MIT License
355 stars 37 forks source link

Support Kotlin DSL friendly interface #29

Open tnj opened 5 years ago

tnj commented 5 years ago

Fixes #28

Gradle Kotlin DSL automatically generates accessors for each Extension for static type-safe access, but it didn't play well with Ribonizer because RibobonizerExtension was not public, as described at #28 .

Also, I've modified some codes where depends on Groovy's runtime dynamic type resolution. For utilities like grayRibbonFilter(), I've specified implementation classes like ColorRibbonFilter instead of Consumer<BufferedImage> to enable access to options.

With this change, you can use Ribbonizer in Kotlin DSL, like:

ribbonizer {
    builder { variant, iconFile ->
        when (variant.buildType.name) {
            "debug" -> yellowRibbonFilter(variant, iconFile).apply { label = branchName }
            else -> grayRibbonFilter(variant, iconFile)
        }
    }
}
pablodeafsapps commented 4 years ago

Hi!

I understand this issue has not been merged yet. Do you plan to do it at some point in the future? I have recently moved my Gradle files to Kotlin DSL and I'd like to keep on using your library.

Thanks and regards,