| .idea | ||
| gradle/wrapper | ||
| tottori-hungergames | ||
| tottori-microservice-isonline | ||
| tottori-services | ||
| .gitignore | ||
| build.gradle.kts | ||
| gradle.properties | ||
| gradlew | ||
| gradlew.bat | ||
| README.md | ||
| RPC.md | ||
| settings.gradle.kts | ||
TODO use git submodules for each module
Sorry for the monorepo. have some chatgpt instructions:
Below is a clean, standard Gradle multi-module setup where one module called tottori-services is accessible to all other modules.
I’ll show:
- Project structure
settings.gradle- Root
build.gradle tottori-servicesmodule config (important part)- How other modules depend on it
This works for Java / Kotlin JVM projects (Android is slightly different—tell me if that’s your case).
1. Project structure
my-project/
├── settings.gradle
├── build.gradle
├── gradle/
├── gradlew
├── gradlew.bat
├── tottori-services/
│ └── build.gradle
│ └── src/main/java/...
├── app-module/
│ └── build.gradle
│ └── src/main/java/...
├── another-module/
│ └── build.gradle
2. settings.gradle (root)
This tells Gradle which modules exist.
rootProject.name = "my-project"
include(
"tottori-services",
"app-module",
"another-module"
)
3. Root build.gradle
Put shared configuration here so all modules inherit it.
plugins {
id 'java' apply false
}
subprojects {
apply plugin: 'java'
group = "com.example"
version = "1.0.0"
repositories {
mavenCentral()
}
}
4. tottori-services/build.gradle (IMPORTANT)
Use java-library, not just java.
This allows other modules to access its public APIs correctly.
plugins {
id 'java-library'
}
dependencies {
// Example:
api 'org.apache.commons:commons-lang3:3.14.0'
}
Why java-library?
api→ visible to modules that depend on this moduleimplementation→ internal only
Anything you want other modules to see should be:
- in
src/main/java public- declared using
apiif it’s a dependency
5. Use tottori-services in other modules
Example: app-module/build.gradle
dependencies {
implementation project(":tottori-services")
}
Now app-module can access:
import com.example.tottori.SomeService;
as long as:
- the class is
public - it’s in
tottori-services
6. Common mistake checklist
✔ Use java-library in tottori-services
✔ Use api for dependencies you want exposed
✔ Add project(":tottori-services") to every module that needs it
✘ Don’t put shared code in the root project
Optional: Make it automatically available to all modules
If every module should depend on it, add this to root build.gradle:
subprojects {
if (name != "tottori-services") {
dependencies {
implementation project(":tottori-services")
}
}
}
If you want:
- Kotlin DSL (
build.gradle.kts) - Android version
- Shared test utilities
- Publishing
tottori-servicesas a library
just tell me 👍