Is it possible to use Kotlin package functions and package properties in different sourcesets? When I try to do so, I have NoSuchMethodError
thrown.
Example
I have Gradle project with Kotlin code and two sourcesets in it, 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 try to access payloadSplitter
with the following code:
package ru.ifmo.ctddev.igushkin.dkvs
...
public class MessageTests {
...
test fun testParsing() {
...
checkParseAndToString("p1b 345 ${payloadSplitter} set a b c")
}
...
}
And exactly in the first line where payloadSplitter
is accessed, at runtime I get
java.lang.NoSuchMethodError: ru.ifmo.ctddev.igushkin.dkvs.DkvsPackage.getPayloadSplitter()Ljava/lang/String;
Other global variables and functions are also inaccessible in test
with the same error.
UPD Kotlin team explained the issue and announced the fix here.
test
and it started working. I suggest you posting an answer with this solution. I would also be happy to know what is the exact reason of such a strange behaviour. – Sacculate