罐子包装和分发
我们按照预期在包中放置了一些通用代码。 其中一些包是 handler、processor、util、registration
等
Common在这里意味着这些将在多个 Java / Java EE 项目中重复使用,这些项目与每个项目无关其他。
问题在于分销包装。
每个包都包含不同的功能单元,但放在一起,它们就是一个 API。
我们是否应该将各个功能捆绑到一个 JAR 中,最终得到 8 - 10 个 jar。 例如:处理程序 jar、注册 jar 等,
或者
我们是否应该采用最小公分母方法,即将 5 个强制包的基础构建到单个 jar 中。 其他任何人都需要该罐子作为基础,并且可以选择附加罐子。
我们的构建系统是 Ant + Ivy,这些依赖关系将在编译和构建时解决。
We have some common code laid out in packages as expected.
Some of these packages arehandler, processor, util, registration
etc
Common here means these will be re-used across multiple Java / Java EE projects which are unrelated to each other.
The question is on packaging for distribution.
Each package comprises a different functional units but put together, they are an API.
Should we bundle individual functionalities into a JAR and end up with say 8 - 10 jars.
eg: handler jar, registration jar etc
or
Should we take the least common denominator approach which is a Base Build of 5 compulsory packages into a single jar.
Any one else needs that jar as the base and can choose add-on jars.
Our build system is Ant + Ivy and these dependencies will be resolved at compile and build time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
除非你有很多很多 API 类(比如 Spring)或者意识到它们之间存在一些干扰,否则我认为没有理由将它们分成单独的 jar。将 API 分解到单独的 jar 中的唯一另一个原因是使不同的团队能够独立工作。
管理单个 jar 简化了很多事情,并且不值得修复不存在的问题。
Unless you have lots and lots of API classes (think Spring) or aware of some interference among them, it is my opinion, that there is very little reason to break them into separate jars. The only other reason to break API in separate jars is to enable different teams work independently.
Managing single jar simplifies a lot of things and it does not worth fixing the problem that does not exist.
使用单独的罐子的解决方案更好。顺便说一句,如果您使用 Maven 并且每个逻辑组件都有自己的 pom.xml,这是唯一的选择。
一大罐的优点是更容易分发。例如,如果您的用户从互联网下载 jar 并手动安装它们,则处理一个 jar 比处理多个 jar 更容易。但如果不是这种情况,我建议您使用多罐解决方案。但不要忘记在每个罐子上标记其版本。至少将版本放入manifest.mf 文件中。 Maven 还将版本作为 jar 名称的一部分。这是非常好的做法。
Solutions with separate jars is better. BTW if you are using maven and each logical component has its own pom.xml this is the only option.
One big jar has advantage of easier distribution. If for example your users download jar from internet and install them manually it is easier to deal with one jar than with many. But if this is not the case I'd recommend you to use multi-jar solution. But do not forget to stamp each jar with its version. At least put version to the manifest.mf file. Maven also puts version as a part of jar name. This is very good practice.
如果 api 很大,最好分成多个 jar,否则创建多个 jar
单个 jar 的好处
如果任何应用程序想要使用多个 jar,例如注册和 util。他/她只需包含 1 罐。
限制
如果您的 jar 大小非常大,并且您只使用 jar 中的 util 类。如果应用程序的大小对您来说不是问题,那么它可能会增加应用程序的大小,那么您可以避免它。
If api is huge better split into mulitple jars otherwise create multiple jars
Benefits of Single jar
If any application wants to use more than one jar eg registration as well as util. he/she have to include only 1 jar.
Limitation
If your jar size is very big in and you are using only util classes in the jar then. It may increase application size if size of application is not a problem for you then you can avoid it.