Why can we not define extension methods like this ...
# gradle
e
Why can we not define extension methods like this
inline fun PluginDependenciesSpec.android(type: String = "application") = id("com.android.$type")
to be used in the
plugins
block like
Copy code
plugins {
  android() // OR
  android("library")
}
h
The
plugins { ... }
blocks are somewhat special, as they are resolved and executed before any other build script parts or plugins, are loaded. Even the
buildSrc
declarations are not available in the
plugins { ... }
blocks. I believe that's why.
e
Just confirmed this 👍
t
Even the
buildSrc
declarations are not available in the
plugins { ... }
blocks
I am using versions object defined in
buildSrc
🤔
e
@tapchicoma In the plugins block? 🤔 And not in the package
org.gradle.kotlin.dsl
? 🤔
t
I am referencing about having:
Copy code
object Versions {
    val somePlugin = "1.0.0"
}
in
buildSrc
and using it in plugins block:
Copy code
plugins {
   id("some.plugin.id") version Versions.somePlugin
}
so, possibly, you may create this function in
buildSrc
and use it in
plugins { .. }
block.
e
I'm surprised that was working for you. I could've sworn that wasn't possible before. I'll try it just to confirm for myself.