Given the following structure of plugins used in a...
# community-support
n
Given the following structure of plugins used in a project, how would I get access to the extension provided by the helm plugin from our own convention plugin?
Copy code
gradle module
\-- convention plugin
    \-- in-house published plugin
        \-- helm plugin
See thread for more detail.
The generated kotlin dsl accessor shows the following:
Copy code
/**
 * Configures the `helm` extension.
 *
 * `helm` is not accessible in a type safe way because:
 * - `com.citi.gradle.plugins.helm.dsl.HelmExtension` is not available
 */
internal
fun org.gradle.api.Project.`helm`(configure: Action<Any>): Unit =
    (this as org.gradle.api.plugins.ExtensionAware).extensions.configure("helm", configure)
I tried using a composite build to switch the in-house plugin's dependency declaration to the helm plugin from
implementation
to
api
, but that didn't seem to make the extension available. Or perhaps I have to force the regeneration of the accessor somehow?
hmm, reading through the documentation, I suppose it's because of how the helm plugin is applied by our in-house plugin:
Copy code
override fun apply(project: Project) {
        project.apply<HelmPlugin>()
Is there any way to improve this on our end without requiring the convention plugin from "re-applying" the helm plugin, just to get typesafe accessors?
v
I suppose it's because of how the helm plugin is applied by our in-house plugin:
No, that should be fine. And if that were the issue, you would not have any accessor at all. But you have the accessor, just not typed.
implementation
vs.
api
should not be important I think, because this distinction is when you compile something against the in-house plugin. But here you use the in-house plugin, so the runtime classpath is the relevant thing. Why your accessor is untyped I don't know just from this snippet. I've seen such a situation exactly once before. In https://github.com/gradle/gradle/issues/27979 where a plugin was added to init script classpath and applied to root project. Then in the root project you had the accessor for the extension, but as the plugin was only present in the init script classloader which is not a parent of the root project classloader, the extension was untyped like in your case. But why it happens in your exact case is hard to tell without an MCVE.
n
Thanks for the details here. I'll do some digging. As far as I can tell, the plugin is not added through an init script. But perhaps there's some other classloader isolation issue.
👌 1