简体   繁体   English

如何将本地Maven / Eclipse项目依赖项封装为jar?

[英]How to encapsulate local Maven/Eclipse project dependency as a jar?

I have some Eclipse/Maven projects with complex dependencies. 我有一些具有复杂依赖关系的Eclipse / Maven项目。 To simplify just consider projects A , B , and C where A and B are independent but both have a dependency on a common project C. Project C contains a bunch of service interface definitions that don't change very often. 为了简化起见,请考虑项目ABC ,其中AB是独立的,但是都依赖于一个公共项目C。项目C包含一堆服务接口定义,这些定义很少经常更改。

Now I want to split up projects A and B into their own separate repositories, with separate build pipelines, etc. Project C is very simple and may not even have its own CI pipeline. 现在,我想将项目A和B拆分为各自的独立存储库,并使用独立的构建管道,等等。项目C非常简单,甚至可能没有自己的CI管道。

And here's the rub, I need things to work smoothly whether a developer has one, two, or all three projects checked out simultaneously, without any developer having to take extra configuration steps. 麻烦的是,无论开发人员同时签出一个,两个或所有三个项目,我都需要工作顺利进行,而无需任何开发人员采取额外的配置步骤。 Is this possible? 这可能吗?

Since both A and B require project C the jar of C project just needs to be provided. 由于A和B都需要项目C,因此只需要提供C项目的jar。

A clean approach would be to add the C jar dependency in a nexus repository. 一种干净的方法是在一个关系存储库中添加C jar依赖项。

Adding the C jar dependency to A and B from your nexus repository would fetch the jar. 从您的关系存储库中将C jar依赖项添加到A和B将会获取jar。

If a nexus repository is not an option you can include the C jar in projects A and B together with a script to install it in the local maven repo. 如果没有关系存储库,则可以将C jar包含在项目A和B中,以及将其安装在本地Maven存储库中的脚本。 (Or another way to use the jar smoothly) However everytime C is updated A and B will need to be updated. (或使用另一种方式平稳地使用jar),但是每次C更新时,A和B将需要更新。 So in practice when C is checked out A and B should be checked out too. 因此在实践中,当C被检出时,A和B也应被检出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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