Function in submodule not found in test (Gradle build)


Hello, I’ve got a Gradle project with a submodule. I have a top-level function defined in the main source of the submodule. I have a test in the root project that calls the function. Everything is fine in IDEA, but it won’t compile from Gradle. I believe my project is organized in the conventional manner; src/main/java, src/main/kotlin, src/test/java, src/test/kotlin, etc. both in root project and submodule.

I’m afraid I can’t even come up with good terms to Google. If someone could give me some idea of what could be wrong I can provide more details. I don’t want post a ton of useless code.

I’m using Gradle 4.6 and Kotlin 1.2.21.



I tried to recreate the problem in a fresh project and I was unable to reproduce the problem.

If I move the top-level functions to a companion object in the same class it work fine. (I’m still looking for help! I don’t want to do it that way!)


Wow, so here’s my submodule file:

fun hereIsAnotherTopLevelFunction() {
    println("** hey **")

fun hereIsATopLevelFunction() {

I have a test that calls the 2 functions. Compilation fails on hereIsAnotherTopLevelFunction but not hereIsATopLevelFunction. Order of the functions doesn’t matter.


Eh, found it. Someone had stuck some jar-building clause into the Gradle script that resulted in omission of some Kotlin artifacts. Look away.