Can I use Kotlin package features and package properties in different sets of sources? When I try to do this, I have a NoSuchMethodError .
Example
I have a Gradle project with Kotlin code and its two sources, main and test . In main , I have the following code in one of the files:
package ru.ifmo.ctddev.igushkin.dkvs ... public val payloadSplitter: String = " ### "
In test I am trying to access payloadSplitter with the following code:
package ru.ifmo.ctddev.igushkin.dkvs ... public class MessageTests { ... test fun testParsing() { ... checkParseAndToString("p1b 345 ${payloadSplitter} set abc") } ... }
And exactly in the first line where payloadSplitter is payloadSplitter , at runtime I get
java.lang.NoSuchMethodError: ru.ifmo.ctddev.igushkin.dkvs.DkvsPackage.getPayloadSplitter()Ljava/lang/String;
Other global variables and functions are also not available in test with the same error.
UPD The Kotlin team explained the problem and announced a fix here .
nosuchmethoderror kotlin gradle source-sets
hotkey
source share