spring-bootgradlegroovygradle-multi-project-build

How to ship a Spring Boot app from a Gradle Multi Build project?


Let's say I have a Gradle Multi Project with 3 subprojects, 2 Spring Boot projects (auth and profile) and 1 Library project (commons).

The 2 Spring Boot projects include a dependency on the Library project: implementation project(":commons")

Actually, to run the 2 Spring Boot projects, I have to run this from the parent project:

gradlew auth:bootRun
gradlew profile:bootRun

If I run gradlew bootRun only, from each Spring Boot subproject, I get the Error like the :commons Library project is not found in the root project, which makes sense, because the :commons project is included only in the parent's settings.gradle file.

I have to push each Spring Boot subproject individually to Heroku.

How should I manage ?


Solution

  • I finally got it, just add this in each subproject's settings.gradle file, then build:

    include ":commons"
    project(':commons').projectDir = new File('../commons')