is there anyway to apply alias() function in build-logic module ?
a
is there anyway to apply alias() function in build-logic module ?
h
Nope, the plugin block is extracted and executed isolated. Just use the id, you can also use the ids in your projects and remove the alias. (That will also improve the performance a little bit by not invoking the Kotlin compiler for the plugins block.)
Technically, there is an ugly workaround too, create another included build for your build logic.
a
the problem is that I can't also use the id function in the build-logic ..... when I am trying to access PluginDependencySpec from the build-logic module it doesn't have anything ... just apply(the boolean one) and version functions
can you provide me with any repo for solution please ? thank you so much for your time ❤️
h
You should not use the PluginDependencySpec. This is how I do it: https://github.com/hfhbd/ComposeTodo
a
@hfhbd but in this sample you don't have build-logic module at all right ?
h
I do.
a
it's only have one file and doesn't have any applied plugin @hfhbd ?
we can achieve my question by the plugins (deprecated) block is there any alternative ?
h
The plugins block is not deprecated, it’s best practice. My build logic is inside
gradle/build-logic
. I don’t know what single file you are referring to.
a
@hfhbd
h
Ahhh, you are using not precompiled script plugins but „normal“ class based plugins. In this case you need to use pluginManager.
a
@hfhbd the problem is that with pluginManager there is no alias or id .... only apply
h
apply takes an id or a class.
a
@hfhbd but no version .... and I want it to take version too like alias to use version catalog with it
h
That’s not possible. Gradle can’t download plugins dynamically, the plugins need to be already downloaded and part of your classpath. Just add the plugins you want to apply to your dependencies.
💔 1