Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How configure a gradle multi-module project?

I have a 3 microservices and now i need to create a docker-compose for all of it. So when i trying to fellow all my microservices in one project i get this issue

Project directory 'C:\Users\Dany\IdeaProjects\target-root\target-discovery\app' is not part of the build defined by settings file 'C:\Users\Dany\IdeaProjects\target-root\settings.gradle.kts'. If this is an unrelated build, it must have its own settings file.

What i have to read for fix it?

setting.gradle.kts

enter image description here

project structure

enter image description here

like image 966
Daniil Baev Avatar asked Feb 12 '26 02:02

Daniil Baev


1 Answers

The include in settings.gradle.kts should look like:

include(
  ":target-discovery"
)

in case there are more sub-folders (e.g. target-discovery/app, target-discovery/app2):

include(
  ":target-discovery:app",
  ":target-discovery:app2"
)

When defining a module it should always start with : and sub-folders should be delimited by :

Also make sure your root build.gradle.kts define all relevant plugins or define them in each sub-module. You can also create conventions (https://docs.gradle.org/current/samples/sample_convention_plugins.html)

If you just define plugins in the root it wont affect your sub-projects, one way to achive it (altough i prefer convention plugins) is:

build.gradle.kts

plugins {
  kotlin("jvm") version ...
}

subprojects {
  apply(plugin = "kotlin")
}
like image 194
Tom Avatar answered Feb 15 '26 12:02

Tom