Spring boot gradle multi module compilation error


#1

Hello !
Take a multi module pure kotlin project, use gradle for build, all modules are spring boot modules.
Let’s say that module C depends on module B that depends on module A.

Well, module B won’t compile complaining about how compileKotlin can’t resolve classes from module A.

$ ./gradlew clean build
e: /Users/adah/workspaces/spring-gradle-kotlin-multimodule/item/src/main/kotlin/cz/zubal/spring/multimodule/b/RepositoryItemService.kt: (3, 36): Unresolved reference: customer
e: /Users/adah/workspaces/spring-gradle-kotlin-multimodule/item/src/main/kotlin/cz/zubal/spring/multimodule/b/RepositoryItemService.kt: (20, 60): Unresolved reference: Customer

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':item: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 in 14s
6 actionable tasks: 3 executed, 3 up-to-date

Hopefully enough, there’s a project doing just that on Github :

Locally, I have something very similar, and same issue : IntelliJ is doing fine (does not complain about compilation) but command line gradle just can’t completes.
I’ve also tried with gradle 4.8, spring boot 2.0.2, and kotlin 1.2.41


#2

I’ve actually found a fix : do not apply the org.springframework.boot plugin on a library module and use

dependencyManagement {
    imports { mavenBom("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") }
  }

See my PR : https://github.com/mzubal/spring-gradle-kotlin-multimodule/pull/2/files