Hello,
I have problem with compiling Kotlin sources in bnd workspace and I'm not sure if the problem lies in Kotlin or bnd Gradle plugin, or should I modify my build.gradle to fit the situation.
The example project is on
https://github.com/jest/test-bnd-gradle-kotlin-nodepends-bugI have two bundles, b.dependant.api and a.depending.provider. A depends on B, so B must be build before A is compiled. It works correctly, when only Java sources are present, but as soon as I add Kotlin file and configure Gradle to compile it, Kotlin compilation ignores A->B dependency and A compilation results in error:
$ ./gradlew clean
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details
:a.depending.provider:clean
:b.dependant.api:clean
BUILD SUCCESSFUL
Total time: 5.413 secs
$ ./gradlew jar
:a.depending.provider:compileKotlin
e: /home/jest/work/eclipses-ws/gradle_bnd_kotlin_nodepends_bug/a.depending.provider/src/a/depending/provider/DependingExampleKotlin.kt: (3, 8): Unresolved reference: b
e: /home/jest/work/eclipses-ws/gradle_bnd_kotlin_nodepends_bug/a.depending.provider/src/a/depending/provider/DependingExampleKotlin.kt: (6, 30): Unresolved reference: Example
:a.depending.provider:compileKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':a.depending.provider:compileKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2.814 secs
When I manually build B first, it works fine:
$ ./gradlew clean
:a.depending.provider:clean
:b.dependant.api:clean
BUILD SUCCESSFUL
Total time: 1.037 secs
$ ./gradlew b.dependant.api:jar
:b.dependant.api:compileJava
:b.dependant.api:processResources UP-TO-DATE
:b.dependant.api:classes
:b.dependant.api:jar
BUILD SUCCESSFUL
Total time: 1.629 secs
$ ./gradlew jar
:a.depending.provider:compileKotlin
w: /home/jest/work/eclipses-ws/gradle_bnd_kotlin_nodepends_bug/a.depending.provider/src/a/depending/provider/DependingExampleKotlin.kt: (6, 18): Parameter 'dependency' is never used
:b.dependant.api:compileJava UP-TO-DATE
:b.dependant.api:processResources UP-TO-DATE
:b.dependant.api:classes UP-TO-DATE
:b.dependant.api:jar UP-TO-DATE
:b.dependant.api:assemble UP-TO-DATE
:a.depending.provider:compileJava
:a.depending.provider:copyMainKotlinClasses
:a.depending.provider:processResources UP-TO-DATE
:a.depending.provider:classes
:a.depending.provider:jar
BUILD SUCCESSFUL
Total time: 1.862 secs
Building with --debug shows that the build path includes B's bundle only when it was proviously built (see "compiling with classpath" in the last lines):
With errors:
13:48:14.226 [DEBUG] [org.gradle.api.Task] [KOTLIN] all kotlin sources: a.depending.provider/src/a/depending/provider/DependingExampleKotlin.kt
13:48:14.227 [DEBUG] [org.gradle.api.Task] [KOTLIN] compileKotlin destinationDir = /home/jest/work/eclipses-ws/gradle_bnd_kotlin_nodepends_bug/a.depending.provider/generated/kotlin-classes/main
13:48:14.227 [DEBUG] [org.gradle.api.Task] [KOTLIN] compileKotlin source roots: [
/home/jest/work/eclipses-ws/gradle_bnd_kotlin_nodepends_bug/a.depending.provider/src,
/home/jest/work/eclipses-ws/gradle_bnd_kotlin_nodepends_bug/a.depending.provider/src/main/kotlin]
13:48:14.228 [DEBUG] [org.gradle.api.Task] [KOTLIN] compileKotlin java source roots: [
/home/jest/work/eclipses-ws/gradle_bnd_kotlin_nodepends_bug/a.depending.provider/src]
13:48:14.228 [DEBUG] [org.gradle.api.Task] [KOTLIN] Removing all kotlin classes in /home/jest/work/eclipses-ws/gradle_bnd_kotlin_nodepends_bug/a.depending.provider/generated/kotlin-classes/main
13:48:14.231 [DEBUG] [org.gradle.api.Task] [KOTLIN] compiling with args: [-no-stdlib, -no-reflect, -module, /tmp/kjps4283698478727396698adependingprovider_main.script.xml, -module-name, a.depending.provider_main, -jvm-target, 1.6, -language-version, 1.0, -api-version, 1.0]
13:48:14.231 [DEBUG] [org.gradle.api.Task] [KOTLIN] compiling with classpath: /home/jest/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-runtime/1.0.5/67d6f90bf8ed20fcdc78a23fcdc6804749d24498/kotlin-runtime-1.0.5.jar, /home/jest/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.0.5/5784635914dadf0635e7bf3f28f1711317e1433a/kotlin-stdlib-1.0.5.jar
Without errors:
13:49:55.426 [DEBUG] [org.gradle.api.Task] [KOTLIN] all kotlin sources: a.depending.provider/src/a/depending/provider/DependingExampleKotlin.kt
13:49:55.426 [DEBUG] [org.gradle.api.Task] [KOTLIN] compileKotlin destinationDir = /home/jest/work/eclipses-ws/gradle_bnd_kotlin_nodepends_bug/a.depending.provider/generated/kotlin-classes/main
13:49:55.427 [DEBUG] [org.gradle.api.Task] [KOTLIN] compileKotlin source roots: [
/home/jest/work/eclipses-ws/gradle_bnd_kotlin_nodepends_bug/a.depending.provider/src,
/home/jest/work/eclipses-ws/gradle_bnd_kotlin_nodepends_bug/a.depending.provider/src/main/kotlin]
13:49:55.428 [DEBUG] [org.gradle.api.Task] [KOTLIN] compileKotlin java source roots: [
/home/jest/work/eclipses-ws/gradle_bnd_kotlin_nodepends_bug/a.depending.provider/src]
13:49:55.428 [DEBUG] [org.gradle.api.Task] [KOTLIN] Removing all kotlin classes in /home/jest/work/eclipses-ws/gradle_bnd_kotlin_nodepends_bug/a.depending.provider/generated/kotlin-classes/main
13:49:55.433 [DEBUG] [org.gradle.api.Task] [KOTLIN] compiling with args: [-no-stdlib, -no-reflect, -module, /tmp/kjps8502199755777343608adependingprovider_main.script.xml, -module-name, a.depending.provider_main, -jvm-target, 1.6, -language-version, 1.0, -api-version, 1.0]
13:49:55.434 [DEBUG] [org.gradle.api.Task] [KOTLIN] compiling with classpath: /home/jest/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-runtime/1.0.5/67d6f90bf8ed20fcdc78a23fcdc6804749d24498/kotlin-runtime-1.0.5.jar, /home/jest/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.0.5/5784635914dadf0635e7bf3f28f1711317e1433a/kotlin-stdlib-1.0.5.jar, /home/jest/work/eclipses-ws/gradle_bnd_kotlin_nodepends_bug/b.dependant.api/generated/b.dependant.api.jar