I have a weird issue with Kotlin precompiled acces...
# community-support
k
I have a weird issue with Kotlin precompiled accessors. Suppose I have a plugin that does this:
Copy code
plugins {
  id("third.party.plugin") // declares an extension 'myExtension'
}

myExtension.myProperty.set("foobar")
If I include some other plugin, like so:
Copy code
plugins {
  id("third.party.plugin")
  id("my.other.plugin")
}

myExtension.myProperty.set("foobar")
Under some conditions (that I have yet to suss out), Gradle will flag
myExtension
as not existing. Is there a reason why that would be, and would it depend on this plugin
my.other.plugin
that I'm adding?
v
Could indeed be, but you should see it pretty clearly in the output.
If the other plugin causes a build failure during accessor generation, no accessors will be available.
The whole
plugins
block is transplanted to a dummy project, which is then investigated for extensions the block caused to be added and for those accessors are generated. If during this a plugin causes failure, no accessors are generated, you should report a bug to that plugin, and as workaround need to apply it the legacy way. You can still use the plugins block with "apply false" to bring it to the classpath and then apply it with "apply(...)".
k
If there something I can run to see if there are issues wrt generating accessors?
generatePrecompiledScriptPluginAccessors
seems like it would be a chicken-and-egg thing.
v
It would be obvious if it is this issue. At least if you read the output. 🙂
k
Ugh. There was a problem with
generatePrecompiledScriptPluginAccessors
but the task didn't actually fail. (It could be my older version of Gradle, but I'm heading somewhere.)
v
Yes, it does not fail. As I said. It just causes the failure to be written to the output and no accessors generated.
k
Is there a version that does fail? Just for curiosity.
v
I'm not aware of any. I guess the reasoning is, that there is no reason to fail the build if there is a chance that the generated accessors are not even used and thus the build can run just fine. I thought there was an issue to make the build fail, but I don't find it right now.