Ivy:本地解析和发布 JAR
我们已经使用 Ivy 几个月了,并且在办公室的 Web 服务器上拥有自己托管的“Ivy Repo”。我们所有的项目都配置为转到此存储库来解决依赖关系。
我们有几个“common”类型的 JAR,供我们的许多项目使用。正因为如此,并且因为我们只有 1 个存储库,所以我们发现来自以下场景的大量开销:
- 开发人员接到一项任务,向项目 1 添加功能(这取决于 Common jar)
- 。在开发项目 1 的过程中,开发人员意识到他/她需要对 Common jar 进行更改
- Common jar 已进行更改
- Common jar 必须经过代码审查和正常的代码升级
- 构建大师发布新的 Common jar
- 项目 1 现在可以恢复开发Common jar 已更新
这变得很荒谬对我们团队来说是痛苦的。
对我来说,显而易见的解决方案是在每个项目中提供 ant 目标,允许开发人员在本地发布/解析(往返于他们的文件系统)。这样他们就可以在周日之前以 9 种方式打破 Common 的罐子,但不会在等待 Common 发布的过程中浪费 2 - 4 天的时间。这样,开发人员对项目 1 和 Common 都进行了本地更改,并且代码一次性完成了我们的升级过程。
我知道 Ivy 可以做到这一点,但我对它太陌生了,我什至不知道从哪里开始。
目前,我们对所有项目使用全局 ivy.settings
文件。在设置文件中,我们使用一个链解析,其中有 1 个 url 解析器,它连接到我们的“ivy repo”。
我相信以下是唯一需要的更改,但我不是 100% 确定:
- 在 ivy.settings 中,我们需要添加本地文件系统解析器在 url 解析器被调用之前;这样,我们在转到 ivy 存储库(Web 服务器)之前检查本地文件系统的依赖关系
- 使用允许本地缓存发布的选项配置每个项目的
ivy.xml
- 调整 Ant 构建,使其具有执行上述选项的
publish-locally
目标
我相信这些更改将使我们能够:(1) 在查找 Web 服务器之前始终在本地查找依赖项,(2 ) 作为构建选项在本地发布 (目标)。
如果这不是真的,或者如果我遗漏了任何步骤,请告知!否则,我可能可以弄清楚如何从 Ivy 文档添加文件系统解析器,但不知道如何获取publish-locally
目标可以正常工作。有什么想法吗?提前致谢!
We have been using Ivy for a few months and have our own hosted "Ivy Repo" on a web server here in the office. All of our projects are configured to go to this repo to resolve dependencies.
We have several "commons" type JARs that are used by many of our projects. Because of this, and because we only have 1 repo, we're finding a lot of ugly overhead coming from the following scenario:
- A developer is given a task to add a feature to Project 1 (which depends on a Common jar)
- During the course of developing Project 1, the developer realizes he/she needs to make changes to the Common jar
- Common jar changes are made
- Common jar has to go through code review and normal code promotion
- Build master publishes new Common jar
- Project 1 can resume development now that Common jar has been updated
This is becoming ridiculous and painful for our team.
To me, the obvious solution is to provided ant targets in each project that allow the developer to publish/resolve locally (to and from their file system). That way they can break the Common jar 9 ways to Sunday, but without losing 2 - 4 days while waiting for Common to get published. This way, the developer makes local changes to both Project 1 and Common, and the code goes through our promotion process all at once.
I know this is possible with Ivy, but I'm so new to it I wouldn't even know where to begin.
Currently we use a global ivy.settings
file for all projects. In the settings file, we use a chain resolve that has 1 url resolver inside of it, which connects to our "ivy repo".
I believe the following is the only change that will be necessary, but I'm not 100% sure:
- In
ivy.settings
we will need to add a local file system resolver before the url resolver gets called; this way we check the local file system for dependencies before moving on to the ivy repo (web server) - Configure each project's
ivy.xml
with an option somehow that allows local cache publishing - Tweak the Ant builds to have a
publish-locally
target that exercises the option mentioned above
I believe these changes will allow us to: (1) always look locally for dependencies before looking to the web server, (2) publish locally as a build option (target).
If this is not true, or if I am missing any steps, please advise! Otherwise, I can probably figure out how to add a file system resolver from the Ivy docs, but have no idea how to get the publish-locally
target to work. Any ideas? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也更喜欢马克斯的方法。
对于
publish-locally
,您可以告诉发布任务使用哪个解析器(resolver="local"
)。这样它就可以发布到本地文件系统或任何定义的解析器。如果您使用链解析器,则应该设置
returnFirst="true"
,以便在本地发现某些内容时解析将停止。I too would prefer Marks approach.
As to
publish-locally
you can tell the publish task which resolver(resolver="local"
) to use. This way it can publish to the local filesystem or to any defined resolver.And if you use a chain resolver you should set
returnFirst="true"
so that resolving will stop when something was found locally.Ivy 支持动态修订:
稳定代码将引用最新批准的 commons jar 版本:
不稳定(开发中)代码将引用最新未批准的代码版本
因此,您需要更改 commons 模块的构建过程以具有两个发布目标。一种用于不稳定的代码快照,另一种用于正式版本。
(请参阅 ivy publish 任务上的状态属性)
注意:
在 Maven 中,有两种类型的存储库:发布版本和快照。恕我直言,常春藤对这个概念的支持更微妙、更强大。
Ivy supports dynamic revisions:
Stable code would reference the latest approved version of the commons jar:
Unstable (in development) code would reference the latest unapproved version of the code
So you need to change the build process for your commons module to have two publishing targets. One for unstable snapshots of your code the other for formal releases.
(See the status attribute on the ivy publish task)
Note:
In Maven you have two types of repository, release and snapshot. Ivy support for this concept is more subtle and more powerful IMHO.