This message was deleted.
# community-support
s
This message was deleted.
v
For a start, do not use
target.plugins
, have a look at its (
getPlugins()
) JavaDoc. Besides that, if you develop a convention plugin, the you specify your dependencies and their versions in the build script of the project building those convention plugins. So specifying the plugin as
implementation
dependency in the build building the plugin and then applying it in your convention plugin is practically the same as your second snippet.
g
great, thank you, that works! also can you elaborate why I should not use
target.plugins
? i am using Kotlin to develop my plugins, and in kotlin
target.getPlugins()
and
target.plugins
are the same. in fact i am getting a warning that i should use property access syntax instead of the getter method…
v
I know they are the same. I said read its JavaDoc where it tells you not to use it. 😉
What you want to use is
target.apply(...)
g
oh, i missed that, thanks! so it’s
Copy code
class KotlinConventionPlugin : Plugin<Project> {
    override fun apply(target: Project) {
        target.apply {
            it.plugin("org.jetbrains.kotlin.jvm")
        }
    }
}
v
o_O ... no
target._apply_(plugin = "org.jetbrains.kotlin.jvm")
g
oh, so many options to do the same thing… 🙂 thanks!
oh wait, this does not compile…
Copy code
class KotlinConventionPlugin : Plugin<Project> {
    override fun apply(target: Project) {
        target.apply(plugin = "org.jetbrains.kotlin.jvm")
    }
}
what am i doing wrong?
v
Might be from the
gradleKotlinDsl()
that you might want to add as dependency to
compileOnly
and maybe
testImplementation
. Or you could apply the
kotlin-dsl
plugin which also does a few other things.
kotlin-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.
g
got it, thank you for the help!
👌 1