Oliver Weiler
04/18/2024, 9:32 AMkotlin-dsl
plugin? Can I use it for developing plugins, or is it only intended to be used with convention plugins? It seems to add some nice extensions.
When should I add @Input / @Output etc. annotations to Extensions/Tasks? It seems they are not strictly required?
Thanks in advanceOliver Weiler
04/18/2024, 9:48 AMThe Kotlin DSL Plugin provides a convenient way to develop Kotlin-based projects that contribute build logic. That includes buildSrc projects, included builds and Gradle plugins.
Vampire
04/18/2024, 9:51 AMkotlin-dsl
applies java-gradle-plugin
, kotlin-dsl.base
, and kotlin-dsl.precompiled-script-plugins
plugins
kotlin-dsl.base
plugin applies embedded-kotlin
, adds gradleKotlinDsl()
to the dependencies of compileOnly
and testImplementation
configurations, and configures the Kotlin DSL compiler plugins for example for proper SAM conversion for Action
and similar, or for being able to assign to properties instead of using .set(...)
and similar.
So even if you do not use precompiled script plugins (which you probably meant when saying "convention plugins") the plugin does some quite useful stuff if you develop your plugin in Kotlin. So I would always apply the kotlin-dsl
plugin if you develop anything related to build logic in Kotlin.
input and output annotations you always need on tasks, there they are required or it will fail. On extensions they ususally do not make sense, as the extensions per-se do not have any input or output. Tasks do, Transforms do, and so on. If you use some part of an extension or an extension as @Nested
input for a task, then it on the other hand might make sense. But usually those should be dedicated DSL objects and not the extension directly. It is most often a better idea to wire single properties in the extension to properties in the task.Oliver Weiler
04/18/2024, 10:08 AMOliver Weiler
04/18/2024, 10:09 AMVampire
04/18/2024, 10:13 AM