多模块 Gradle 项目
我目前正在构建一个具有多个分布式 api(通过 Java Spring Boot)的客户端-服务器应用程序,并且我已经抽象了 API 组件(@Controller、@Service @Mapper 和 @Repository)。
我有一个多模块 gradle 项目,看起来像这样:
---- Projects
------ properties.gradle
------ settings.gradle
------ ClientProj
-------- ClientApplication
-------- build.gradle
------ ApiProj1
-------- ApiProj1Application
-------- build.gradle
------ ApiProj2
-------- ApiProj2Application
-------- build.gradle
------ common
-------- build.gradle
------ api-components
-------- build.gradle
但我想可能做这样的事情: (请注意,我试图将所有 api 相关组件包装在一起)。
---- Projects
------ properties.gradle
------ settings.gradle
------ ClientProj
-------- ClientApplication
-------- build.gradle
------ common
-------- build.gradle
------ api
-------- ApiProj1
---------- ApiProj1Application
---------- build.gradle
-------- ApiProj2
---------- ApiProj2Application
---------- build.gradle
------- api-components
---------- build.gradle
从我在网上看到的情况来看,我没有注意到其他模块中的多模式,就像我用 API 展示的最后一个示例。想请问大家这样的设计是否可以接受,如果可以的话,这些嵌套的api模块是否会被视为子项目。从我迄今为止不成功的尝试来看,以这种方式构建时,访问嵌套项目似乎真的很困难。
对于使用 Gradle,我还算初级,但多模块和子项目对我来说是新的,我认为它在隔离问题和组织代码方面有很大的潜力。任何反馈将不胜感激!先感谢您。 :)
I'm currently building a client-server app with multiple distributed apis (via Java Spring Boot), and I've abstracted the API components (@Controller, @Service @Mapper, and @Repository).
I have a multi-module gradle project that looks something like this:
---- Projects
------ properties.gradle
------ settings.gradle
------ ClientProj
-------- ClientApplication
-------- build.gradle
------ ApiProj1
-------- ApiProj1Application
-------- build.gradle
------ ApiProj2
-------- ApiProj2Application
-------- build.gradle
------ common
-------- build.gradle
------ api-components
-------- build.gradle
But I want to possibly do something like this instead:
(Notice that I'm trying to wrap all the api related components together).
---- Projects
------ properties.gradle
------ settings.gradle
------ ClientProj
-------- ClientApplication
-------- build.gradle
------ common
-------- build.gradle
------ api
-------- ApiProj1
---------- ApiProj1Application
---------- build.gradle
-------- ApiProj2
---------- ApiProj2Application
---------- build.gradle
------- api-components
---------- build.gradle
From what I've seen online, I haven't noticed multimodes within other modules like the last example I show with the api. I'd like to ask everyone whether this design is acceptable, and if so, whether these nested api modules would be considered subprojects. From my unsuccessful attempts thus far, it seems really difficult to access nested projects when constructed this way.
I'm a bit more than beginner for using Gradle but multimodules and subprojects are new to me and I think has a lot of potential to isolate concerns and organize code. Any feedback would be greatly appreciated! Thank you in advance. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仍然可以使用第二种结构。您的第一个结构的
settings.gradle.kts
必须类似于:对于第二个结构,应将其更改为:
It's still possible to use the second structure. Your first structure's
settings.gradle.kts
must be like:For the second, it should be changed to: