what is the right way of using `plugins` block in ...
# gradle
k
what is the right way of using
plugins
block in a multi platform Kotlin project, i.e., if I want to use
plugins
block in both the root as well as sub module
g
You can do that now without problem. Add plugins block and apply required plugins. But you cannot use subprojects or allprojects function to apply plugins using plugins block, it's restriction of plugins dsl, each plugins block processed separately even before invocation of other parts of your config.
k
Well I did some hit n trial and I made the root project ids with apply false and in the module gradle file I made the ids to apply true I don't know if this is the right way but it certainly worked for me.
g
Why do you need “project ids with apply false” at all?
k
I saw that somewhere on the SO
I don't know the specefics but it works
g
To do this you usually need some reason, like configure this plugin and apply to submodules or something like that
but for simple case just use
id("some.plugin") version 1.2.3
for module where this plugin is required
but
apply false
also allows you to omit version of plugin on any of your submodules, but it’s not a big thing
k
What you said does not allow to use 0lugins block in modules and we have to use buildsciplt in the root gradle file and then we can use plugins in the modules. I am not saying my meathod is right but it just works and I want to know hiw to make it work as Gradle is really pushing the plugins dsl
That's what I feel
If so there must be some mechanism to make ut work.
g
Buildscript is legacy API and I believe eventually will be deprecated
Why do you use buildscript in your root project?
Also, Kotlin-dsl just cannot work in type safe way with plugins applied using buildscript
Why do you need 0 plugins In module? What is your case. Usually you need at least one plugin on submodule, to specify type of this module, but it's also not necessary. If you can share your use case I probably can suggest some solution
k
Actually I can't share the project. But thanks anyways.
g
I don't ask to share project of course :) just curious what do you want to achieve
k
I'll create a sample project and will share that in a day or two been travelling a lot :)