Java module depending on Kotlin module unable to compile


#1

I have been running into some strange issues when depending on a gradle module that uses Kotlin. I have setup a small demo project to demonstrate my issues and I would love to know what I might be doing wrong.

I have a simple multi-module gradle setup

moduleA (Java)
moduleB (Kotlin)

in moduleA I have 2 simple data classes.

package com.test.library

class MyNonDataClass() {
}

data class MyTestDataClass(val str: String)

in moduleB I have a simple Main class that attempt to use these classes

import com.test.library.MyNonDataClass;
import com.test.library.MyTestDataClass;

public class TestingClass {

    public static void main(String[] args) {
        MyNonDataClass clazz1 = new MyNonDataClass();
        MyTestDataClass clazz = new MyTestDataClass("hello");
    }
}

When running via IntelliJ all is well. Things compile and run properly. However I am running into strange issues when compiling via gradle at the command line.

When i run

./gradlew compileJava

I am told the Kotlin classes can not be found ( shortened for brevity)

error: cannot find symbol
MyTestDataClass clazz = new MyTestDataClass("hello");

However if I then run the command again

./gradlew compileJava

Everything compiles properly with no issues.

Is this a bug with the gradle plugin?