Matei David
02/07/2025, 7:14 PMinterface MyLibraryExtension {
fun getValue(): String
...
}
I create such an object and register it as myLibrary
extension upon applying the plugin.
I want to test it with TestKit.
In a test project build.gradle.kts
:
• This works: println(myLibrary::class.java.getMethod("getValue").invoke(myLibrary))
• But this fails: println(myLibrary.getValue())
with "Unresolved reference: getValue".
So Gradle under TestKit:
• Finds the extension object just fine.
• It can inspect it and use it via reflection just fine.
• It cannot deal with the extension without reflection...?!
Am I missing something for this to work in TestKit?
It all works fine if I try it out on the CLI without TestKit.
Update: It even works if I use Groovy build.gradle
instead of Kotlin build.gradle.kts
in the test project...Vampire
02/07/2025, 9:10 PMAny
which does not have that method.Vampire
02/07/2025, 9:11 PMwithPluginClasspath
, it might maybe with better.Vampire
02/07/2025, 9:13 PM