Aitch
Aitch

Reputation: 1697

Multiproject dependency management with gradle

There are currently 3 projects/git repos set up with gradle:

Dependencies:

app    -> backend
client -> backend

Since app and client don't depend on everything in backend like they do not depend on spring etc. but on some model classes, I need to find a good solution for building the project.

I thought of ...

1. backend artifact

2. extend sourceSets

3. new api project

app     -> api
client  -> api
backend -> api

conclusion

The first and second solution does not need to have a fourth git repo and I think it's not a bad idea to have the api component in the backend, but in the context of gradle a project dependency like in 3., would be more transparent I think.

Any best practices?

Thank you for helping !

Upvotes: 2

Views: 348

Answers (1)

Ethan
Ethan

Reputation: 6913

Best practice is option number 3 (create a new api project).

Side note: You don't need to make a separate repo for the api project, you could keep it alongside the backend project if you wanted.

Edit: Adding Repo Layout

If you want to have the api along side the server, you would want this layout. Then reference the API like project(":backend:api")

.
├── app
│   └── build.gradle
├── backend
│   ├── api
│   │   └── build.gradle
│   └── server
│       └── build.gradle
├── build.gradle
├── client
│   └── build.gradle
└── settings.gradle

Upvotes: 1

Related Questions