Gradle plugin extension deprecation

I am trying to deprecate a gradle plugin extension to replace it with a new one.
I added @Deprecated annotation to the extension class. But there is no warning appearing in the app build.gradle when i use this extension. How can i show a warning with a message when a user uses that extension?

From Kotlin DSL you would probably get a deprecation warning, as it is type-safely compiled so the compiler knows the type.

From Groovy DSL as you mentioned, I don’t think you can get a deprecation warning like that, as Groovy is duck-typed, so as long as the types match at runtime, everything is fine.
I’m not sure whether there is a convenient way to deprecate a whole extension or even single properties from it for usage in Groovy DSL.

Probably the easiest would be to check whether the properties have non-default values when you query the values and then log a deprecation warning manually.

1 Like