简体   繁体   English

大型项目的Java依赖关系管理

[英]Java Dependency Management For Large Projects

I hope I can keep this question specific enough, my team at work is currently debating the best way to manage our dependencies for a huge project (150+ dependencies ~300mb). 我希望我能够保持这个问题的具体性,我的工作团队目前正在讨论管理一个巨大项目(150多个依赖项~300mb)的依赖项的最佳方法。

We have two main problems 我们有两个主要问题

  • Keeping all the developers dependencies the same so we are compiling against the same files 保持所有开发人员依赖关系相同,以便我们针对相同的文件进行编译
  • Ensure the project (once compiled) is comliped against the same dependencies 确保项目(编译后)与相同的依赖项相互配合

The two ideas that have been suggested are using a BirJar (all dependencies in one file) and just adding a version number to it and using a shared folder and pointing everyone's machines at the same place. 建议的两个想法是使用BirJar(一个文件中的所有依赖项),只是添加一个版本号并使用共享文件夹并指向每个人的机器在同一个地方。

Or making including all the dependencies in the jar when we compile it (a jar, of jars, of jars) and just have a project that "has no dependencies" 或者在我们编译它时(jar,罐子里的罐子)包含jar中的所有依赖项,并且只有一个“没有依赖关系”的项目

Someone also mentioned setting up an internal version of Ivy and pointing all the code to pull dependencies from there. 有人还提到设置Ivy的内部版本并指出所有代码从中拉出依赖项。

What are the best practices regarding massive dependency management? 关于大规模依赖管理的最佳实践是什么?

Why don't you use Maven and its dependency management ? 你为什么不使用Maven及其依赖管理

You can specify each dependency, its particular version and its scope (compile-time, for testing, for deployment etc.). 您可以指定每个依赖项,其特定版本及其范围(编译时,用于测试,部署等)。 You can provide a master pom.xml (the config file) that specifies these, and developers can override if they need (say, to evaluate new versions). 您可以提供指定这些的主pom.xml (配置文件),开发人员可以在需要时覆盖(例如,评估新版本)。

eg I specify a pom.xml that details the particular jars I require and their versions (or range). 例如,我指定了一个pom.xml,详细说明了我需要的特定罐子及其版本(或范围)。 Dependent jars are determined/downloaded automatically. 依赖罐子自动确定/下载。 I can nominate which of these jars are used for compilation vs. deployment etc. If I use a centralised repository such as Nexus I can then build my artefact (eg a library) and deploy that into Nexus , and it'll become available for other developers to download in exactly the same manner as 3rd party libs etc. 我可以提名这些罐子中的哪一个用于编译和部署等。如果我使用Nexus等集中存储库,我可以构建我的人工制品(例如库)并将其部署到Nexus中 ,它将可用于其他开发人员以与第三方库等完全相同的方式下载。

Incase you dont like/want to follow the Maven project structure... 如果您不喜欢/想要遵循Maven项目结构......

If you already use Ant, then your best bet is to use Ivy for dependency management. 如果您已经使用了Ant,那么最好的办法就是使用Ivy进行依赖管理。

http://ant.apache.org/ivy/ http://ant.apache.org/ivy/

It provides a rich set of ant tasks for dependency manipulation. 它为依赖项操作提供了丰富的ant任务。

from : Ant dependency management 来自: Ant依赖管理

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

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