Skip to content
Advertisement

Gradle Kotlin DSL – Build script fails when java.sourceCompatibility defined in Parent but build is successful when added to child module

Am trying to setup a new repository for a multi module springBoot application using gradle (Kotlin DSL for build scripts)

As part of the same I am trying to declare generic configuration and dependencies needed for all subProjects. In doing so, I am trying to define sourceCompatility for all child projects in the subprojects block of parent build.gradle.kts file

When I try to compile my project with above config then build is failing with the following exception

JavaScript

But if I move the line java.sourceCompatibility = org.gradle.api.JavaVersion.VERSION_11 to the child module’s build.gradle.kts file then it is compiling successfully and application is coming up as expected.

I cannot understand what I’m missing here. Please help me understand this.

Parent build.gradle.kts

JavaScript

Child build.gradle.kts

JavaScript

settings.gradle.kts for the project:

JavaScript

P.S: I also tried using

JavaScript

But the same pattern is observed. Error thrown in this case is

JavaScript

Advertisement

Answer

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement