简体   繁体   中英

Trouble understanding maven modules and parent projects

I am trying to figure out how to structure my project for Maven, and I've become a little confused.

If I have a Project A, that can be distributed and used on its own, but then I have Project B (which can also be distributed on its own) which depends on Project A and sort of 'builds off' of Project A, should is be a module of ProjectA ? Then Say I have project C, which depends on project B, should that be a module of project B?

I guess I'm confused about how a multi-module project works.

Thanks.

如果您不想寻找简短的描述,那么我建议您通过示例查看Maven的第7章: http//books.sonatype.com/mvnex-book/pdf/mvnex-pdf.pdf

In Maven you can't have cycle dependencies. So in my opinion it would be better to create modules that will not depend on each other (or only on project API) and one that will have dependencies from all others. You need logically structurize them, every module must have some purpose.

For example, module A will have your project API, module B will contain project core (and have dependency on A), module C will have some other purpose, some independent classes that you can use (and have dependencу on A), module D will have other functionality (and have dependency on A) and so on. Then, you can create moduleE, that will have dependencies on BC, D and will use functionality from these projects, will contain user interface and will be the main one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM