chainsaw icon indicating copy to clipboard operation
chainsaw copied to clipboard

Doesn't work with Kotlin

Open mikehearn opened this issue 6 years ago • 4 comments

Unfortunately my Gradle-fu is not strong enough to debug this, but basically - create a hello world Kotlin project, create a module-info.java file, add Chainsaw and it doesn't work. The java compiler can no longer see the Kotlin generated classes.

Kotlin also does a lot of interesting reconfiguration of tasks and things in order to allow Java/Kotlin code to see and call each other, so undoubtably, they're clashing somewhere and Chainsaw is undoing the Kotlin build modifications.

mikehearn avatar Mar 30 '18 17:03 mikehearn

Thanks for the feedback. Unfortunately I have very little experience with Kotlin, so any support with this issue is really welcome!

zyxist avatar Apr 03 '18 19:04 zyxist

Try these lines (for gradle kotlin DSL)

val compileKotlin: KotlinCompile by tasks
val compileJava: JavaCompile by tasks
compileJava.destinationDir = compileKotlin.destinationDir

It has to do with the directories gradle uses to generate the module.

Burtan avatar Sep 07 '18 20:09 Burtan

Bug is still here, Gradle complains about not finding the packages declared using the Kotlin language when exporting them through the module-info file. @Burtan's solution's works flawlessly, huge thank you sir!

EDIT: Here is an example

module-info.java

module my.module {
    exports package.made.in.kotlin
}

Error:

C:\...\src\main\java\module-info.java:2: error: package is empty or does not exist: package.made.in.kotlin

utybo avatar Jun 25 '19 12:06 utybo

Multi-project builds seem to be broken in Kotlin even with the workaround. Projects that depend on other projects in the same multi-project build complain about missing modules.

utybo avatar Jun 25 '19 12:06 utybo