maven查找其依存关系的顺序是什么? [英] What order does maven find its dependencies?

查看:110
本文介绍了maven查找其依存关系的顺序是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用战争叠加层的多模块项目,我们有一个持续集成服务器,该服务器经常部署快照。我有这样的问题,如果在CI服务器进行部署之后立即执行 mvn编译,我的构建会得到本地更改还是CI更改?如何强制我的项目使用在本地更改的战争覆盖图?我认为安装可以做到这一点,但是如果CI服务器构建带有新时间戳的版本该怎么办。它会使用哪一个?

I've got a multi module project that uses war overlays and we have a continuous integration server that often deploys the snapshots. I have questions like, if I do a mvn compile right after the CI server does a deploy of it, will my build get my local changes or the CI changes? How do I force my project to use a war overlay I've changed locally? I figure an install could do that, but what if the CI server builds a version with a newer timestamp. Which one will it use?

这只是我有很多问题中的几个,我在maven文档中找不到权威性的答案。但是,即使我可能会回到这里,并请某人更好地解释文档:P所以,我问,顺序/逻辑maven用于查找其依赖项的顺序是什么?

This is just a few of the many questions I have and I can't find an authoritative answer on the maven documentation. But, even if I could I'd probably come right back here and ask someone to explain the documentation better :P So, I ask, what is the order/logic maven uses to find it's dependencies?

推荐答案

就Maven而言,从战争叠加层生成的伪像只是另一种伪像。

As far as Maven concerns, the artifact generated from your war overlays will just be yet another artifact.


如果在CI服务器进行部署后立即执行mvn编译,我的构建会得到本地更改还是CI更改?

if I do a mvn compile right after the CI server does a deploy of it, will my build get my local changes or the CI changes?

这取决于设置文件中的快照updatePolicy。默认情况下,它设置为每天。此处有更多详细信息: http://maven.apache.org/settings.html#Repositories

This will be depending on your snapshots updatePolicy in your settings file. It is by default set to daily. More details here: http://maven.apache.org/settings.html#Repositories


如何强制我的项目使用在本地更改的战争叠加?

How do I force my project to use a war overlay I've changed locally?

将快照updatePolicy更改为从不(或-o选项,由@matsev建议)。这意味着您使用的SNAPSHOT依赖项将始终是本地版本。要使用此updatePolicy force 从存储库中获取最新消息,请使用-U选项。

Change the snapshots updatePolicy to never (or -o option, suggested by @matsev). This means the SNAPSHOT dependencies that you are using will always be the local version. To force grab the latest from the repository one with this updatePolicy, use the -U option.


安装可以做到这一点,但是,如果CI服务器使用新的时间戳构建版本,该怎么办。它会使用哪个?

I figure an install could do that, but what if the CI server builds a version with a newer timestamp. Which one will it use?

是的, install 基本上会将您的工件部署到本地存储库(。 m2文件夹)。然后,根据updatePolicy,maven将比较本地部署的工件和存储库工件。如果将updatePolicy设置为 always ,则maven将总是抢占一个存储库,如果具有更新的时间戳。 daily 也是一样,除了maven只比较时间戳 daily

Yes, install will basically deploy your artifact to your local repository (.m2 folder). Then, depending on the updatePolicy, maven will compare the locally deployed artifact and the repository artifact. If updatePolicy is set to always, maven will always grab the repository one if it has a newer timestamp. The same goes to daily, except that maven will only compare the timestamp daily.


我在Maven文档中找不到权威的答案。

I can't find an authoritative answer on the maven documentation.

完全同意。可悲的是,我大部分是通过经验来理解的。

Totally agree. Sadly, I understand most of these partly through experience.

这篇关于maven查找其依存关系的顺序是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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