This message was deleted.
# community-support
s
This message was deleted.
v
Of course it is. But some notes: • use Kotlin DSL 😄 • do not use the legacy
apply ...
, but use
plugins { ... }
block to apply plugins • Is
PluginName
the id or the class name?
If it is the ID, then better namespace it, plugins without dot should be reserved for built-in plugins, and more importantly put it in quotes, so that it is a string. If it is the class name, does it really have no package / did you forget to import it?
m
But that’s the point my gradle file is still in groovy. It’s quite big and would require a lot of effort to migrate to kotlin dsl fully. The plugin doesn’t have package name. At least yet, I am experimenting I do not bother with such details 😄 PluginName is the class name.
v
Hm, then I would expect it to work. Maybe try with adding a class name?
Or it is my brain being almost in holidays already. 😄
p
try with
PluginNameKt
m
Tried it already, didn’t work 😞
v
Really? Isn't that just for top-level declarations in a
PluginName.kt
, but not if you have
abstract class PluginName : Plugin<Project>
?
m
I wonder if the fact that my buildSrc is a now a mix of groovy and kotlin may be problematic 🤔
Tried exposing the plugin id using
gradlePlugins { }
block. In such case I got
Could not find implementation class 'PluginName' for plugin 'my.plugin'
Now I wonder if the plugin class is on the classpath
p
is
:buildSrc:compileKotlin
actually running? is the
.class
file present in
buildSrc/build/classes
? is it present in the jar under
buildSrc/build/
?
m
I’ve moved the plugin from
groovy
to
kotlin
source set. It can now be correctly applied. I won’t be able though to use a Task written in groovy in the
groovy
source set right? 😉
Perhaps I can play with the sourcesets
v
I don't remember what the default order and dependency between the languages is, but you can change it. There is a snippet of what you need to do in the docs somewhere. 🙂
m
Yes, I just realized I will have to change it. Looking for the snippet as apparently by default kotlin takes precedence over groovy.
v
It's not so much about precedence, but order and dependencies. I wouldn't wonder if there is even no relationship either way by default.
m
Forgot to thank both of you @Vampire and @Paul Merlin. 🙏 Using your help I eventually managed to achieve what I was trying to do 😉 Although I had to apply this one: https://github.com/gradle/gradle/issues/11333 to force the kotlin compiler to take groovy compiler output to the kotlin compiler classpath. The code snippet there is also a bit outdated as
classpath
property of the
KotlinCompile
task shouldn’t be used anymore in favour of a new
libraries
property.
👌 2