zyxist / chainsaw

Gradle plugin: adds support for building Java 9 modules.
Apache License 2.0
70 stars 4 forks source link

Doesn't work with Kotlin #29

Open mikehearn opened 6 years ago

mikehearn commented 6 years ago

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.

zyxist commented 6 years ago

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

Burtan commented 6 years ago

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.

utybo commented 5 years ago

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 commented 5 years ago

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.