does this work? I've never seen it before now ```...
# community-support
t
does this work? I've never seen it before now
Copy code
class MyPlugin : Plugin<Any> {
    override fun apply(target: Any) {
        when (target) {
            is Settings -> applyToSettings(target)
            is Project -> applyToProject(target)
            else ->
                throw IllegalArgumentException(
                    "MyPlugin can only be applied to Settings or Project, not ${target::class.simpleName}"
                )
        }
    }
1
t
nice!
a
instead of
Any
you could consider
PluginAware
, which
Project
,
Settings
and
Gradle
(for init plugins) all implement https://docs.gradle.org/current/javadoc/org/gradle/api/plugins/PluginAware.html
👍 2