[英]Multiproject dependency management with gradle
There are currently 3 projects/git repos set up with gradle:目前有 3 个项目/git repos 设置了 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.由于
app
和client
不依赖于backend
所有内容,就像它们不依赖于 spring 等,而是依赖于某些模型类,因此我需要找到一个很好的解决方案来构建项目。
I thought of ...我想到了...
backend
artifact backend
神器src/main/java
and src/api/java
src/main/java
和src/api/java
api
source folder compiled as a jar artifact api
源文件夹编译为 jar 工件app
and client
app
和client
backend/src/api/java
to app
and client
backend/src/api/java
到app
和client
api
project api
项目app -> api
client -> api
backend -> api
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.第一个和第二个解决方案不需要有第四个 git repo,我认为在
backend
有api
组件并不是一个坏主意,但是在 gradle 的上下文中,像 3. 中的项目依赖项会更透明我思考。
Any best practices?任何最佳实践?
Thank you for helping !感谢您的帮助 !
Best practice is option number 3 (create a new api
project).最佳实践是选项 3(创建一个新的
api
项目)。
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.旁注:您不需要为 api 项目制作单独的 repo,如果需要,您可以将它与后端项目一起保存。
Edit: Adding Repo Layout编辑:添加回购布局
If you want to have the api along side the server, you would want this layout.如果您想将 api 放在服务器旁边,您会想要这种布局。 Then reference the API like
project(":backend:api")
然后引用像
project(":backend:api")
这样的 API
.
├── app
│ └── build.gradle
├── backend
│ ├── api
│ │ └── build.gradle
│ └── server
│ └── build.gradle
├── build.gradle
├── client
│ └── build.gradle
└── settings.gradle
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.