'How does gradle run main in test module?

I have a luncher for test only so it is defined in test moudle. I run it with IDEA run configuration and it throws the error that Cannot find the main class. I'm guess this test class is not compiled.

// in test moudule

object Launch {

    @JvmStatic
    fun main(args: Array<String>) {
        println("launch")
    }
}

I also found that once I run other test case with @Test, it will compile Launch and make it work as I expected.

EDITED:

I found that the Launch.class had been output to build/classes/kotlin/test, it means that Launch had be compiled. But it still doesn't work. I'm confused.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source