This message was deleted.
# plugin-development
s
This message was deleted.
t
I'd say you're expected to add a dependency (possibly a compile-only one) to the third-party plugin.
Gradle will actually apply the plugin to an empty project and generate the type-safe accessors, so your precompiled script plugin can actually be compiled.
f
you mean add a dependency to the third-party plugin to the convention plugins module?
of course, makes total sense and I'm actually already doing that for other plugins 🤦
thanks!
a
your question is more related to the Plugins DSL vs legacy plugin application, because you could copy-paste your first codeblock into a precompiled script plugin. Although there is a link to precompiled script plugins, because the plugins DSL is available in them, and not class-based plugins.
f
I see, thanks for clarifying!
follow up question:
implementation
doesn't seem to be available in the script plugin unless I add an obscure import:
import gradle.kotlin.dsl.accessors._07bf104a0ea43b0dca361639a0f9e875.implementation
which I guess is somehow generated
a
definitely don't add that import :)
f
yeah 🙂
a
implementation
is a Kotlin DSL Accessor that Gradle will generate when you apply (using the Plugins DSL!) the Java plugin (or some other plugin that also registers
implementation
)
f
ah, so I guess if I add for example
kotlin("jvm")
, that would do the trick?
a
exactly
f
This is an android project, so I'm trying
kotlin("android")
. That doesn't work 🤔
a
Gradle & Kotlin scripting does some clever magic under the hood so the generated accessors are added as default imports, but they're specific per kts script. But if you copy/paste then IntelliJ tries to be clever and copies the imports, but it shouldn't!
f
Yeah I figured there was some magic involved
a
you might have to run 'Gradle sync' a couple of times
f
hmm I did but it doesn't seem to pick it up
a
sometimes IntelliJ really struggles to keep track of the accessors. It might help running
./gradlew clean
, restarting IntelliJ, running the 'repair IDE' steps until IJ restarts, and run Gradle sync
assuming your project is working and compiling - if there's a problem in a build script then Gradle can't run, so it can't generate the accessors.
f
ok will try a few things, thanks!
👍 1
figured it out,
kotlin("android")
requires either `com.android.application`or
com.android.library
to be applied as well. Which is a bit of a pity because now I need to have 2 convention plugins for this thing, one for apps and one for libs, but it works 👍
a
sounds good! A bit of repetition isn't too bad, so long as it's clear.
f
yeah, I guess it's ok