Maven:在项目版本控制中保留依赖的jar [英] Maven: keeping dependent jars in project version control

查看:127
本文介绍了Maven:在项目版本控制中保留依赖的jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有一个战争项目,其中包含几个在任何存储库中都不可用的相关jar.直到最近,我一直将它们保留在src/main/webapp/WEB-INF/lib中,并使用

So, I have a war project with several dependent jars that are not available in any repository. Up until recently, I'd been keeping them in src/main/webapp/WEB-INF/lib, and adding them to the pom with system scope.

我知道那是有问题的,所以我正在寻找清理我的构建的方法.我已经通过install:install-file插件将罐子手动安装到了.m2/repository中.那对我来说很棒,但是我团队中的其他人呢?我们很小,设置Nexus并不是我们真正的选择.我已经在pom.xml中添加了注释,解释了如何为每个jar运行install:install-file.

I get that that's problematic, so I'm looking to clean up my build. I've semi-manually installed the jars into my .m2/repository via the install:install-file plugin. That's great for me, but what about the other people on my team? We're tiny, and setting up Nexus isn't really an option for us. I've resorted to adding comments to the pom.xml explaining how to run install:install-file for each jar.

我对install:install-file解决方案表示满意,但我仍想将这些工件包括在项目的版本控制中,而不仅仅是将它们散布在我的文件系统中.

I'm OK with the install:install-file solution, but I'd still like to include these artifacts in my project's version control, and not merely have them sprinkled about my filesystem.

将它们保留在src/main/webapp/WEB-INF/lib中是行不通的,因为这会自动将它们添加到生成的战争工件中(题外话:如果maven只是继续将它们添加到类路径中,则无需完成安装:install-file!)

Keeping them in src/main/webapp/WEB-INF/lib doesn't work, since that automatically adds them to the resulting war artifact (digression: if maven would simply go ahead and add them to the classpath here I'd be done, no need for install:install-file!)

问题::在Maven目录布局中是否有一个可以保存这些.jar文件的地方,以便我可以将它们保留在我的项目中?

Question: is there a sanctioned place in the maven directory layout where I can tuck these .jar files, just so that I can keep them as part of my project?

我确实意识到这里发生了什么-Maven试图将依赖的jars保留在我的构建的外部 ,以便当其他项目依赖于我的构建时,它们可以解决可传递的依赖.这对于即将进入公共Maven仓库的开源项目非常有用,但是我敢打赌,大多数使用Maven的人都在从事诸如此类的叶"项目,而且一定有一种方法真的很方便将jar文件作为项目的一部分包含在内,而无需经历太多的麻烦.

I do realize what's going on here- Maven is attempting to keep dependent jars outside of my build so that when other projects depend on my build, they can resolve the transitive dependencies. That's great for open-source projects that are going into the public maven repos, but I'd bet that the vast majority of people using Maven are working on "leaf" projects such as this, and it would be really handy to have a way to include jar files as part of the project without jumping through so many hoops.

推荐答案

如果按照Jan的建议设置Nexus或只是一个简单的文件服务器存储库真的太麻烦了,这里还有其他一些选择:

If setting up Nexus or just a simple fileserver repo as suggested by Jan is really too much trouble, here are some other options:

  • 仅包含JAR和脚本,即可将它们全部安装在版本控制中您选择的目录中.无需Maven结构对其进行批准.
  • 将版本控制系统用作存储库的主机,既可以在主项目中单独在分支上,也可以在单独的项目中使用.让您已经在版本控制上拥有的所有备份,安全性等都适用于存储库,而无需在实际检出并提交的文件集中包含jar.
  • 将jar放在一个充当迷你存储库的文件夹中,该存储库已与其余代码一起签出.让pom.xml指向该文件夹作为其使用的存储库.我不是100%确信这是可能的,但似乎很有可能.

这篇关于Maven:在项目版本控制中保留依赖的jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆