在本地解决和发布JAR

在本地解决和发布JAR

本文介绍了Ivy:在本地解决和发布JAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经使用Ivy几个月了,并在办公室的Web服务器上托管了自己的"Ivy Repo".我们所有的项目都配置为转到此存储库以解决依赖关系.

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.

我们的许多项目都使用了几种常见"类型的JAR.正因为如此,并且由于我们只有1个仓库,所以在以下情况下我们会发现很多难看的开销:

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:

  • 开发人员被赋予了向Project 1添加功能的任务(取决于Common jar)
  • 在开发项目1的过程中,开发人员意识到他/她需要对通用jar进行更改
  • 进行了常见的jar更改
  • 普通jar必须经过代码审查和常规代码升级
  • Build master发布新的Common jar
  • 由于Common jar已更新,因此项目1可以恢复开发

这对于我们的团队而言变得荒谬而痛苦.

This is becoming ridiculous and painful for our team.

对我来说,显而易见的解决方案是在每个项目中提供ant目标,这些目标使开发人员可以在本地发布(或从其文件系统中发布).这样,他们可以在周日之前通过9种方式打破Common jar,但在等待Common发布之前不会损失2-4天.这样,开发人员就可以对Project 1和Common进行本地更改,并且代码会一次通过我们的升级过程.

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.

当前,我们对所有项目都使用全局ivy.settings文件.在设置文件中,我们使用其中包含1个url解析器的链式解析器,该解析器连接到我们的"ivy repo".

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".

相信以下是唯一必要的更改,但我不确定100%:

I believe the following is the only change that will be necessary, but I'm not 100% sure:

  • ivy.settings中,我们将需要在调用URL解析器之前添加一个本地文件系统解析器.这样,我们在进入常春藤仓库(Web服务器)之前检查本地文件系统是否存在依赖性
  • 使用允许本地缓存发布的选项配置每个项目的ivy.xml
  • 调整Ant的构建,使其具有一个执行上述选项的publish-locally目标
  • 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

相信这些更改将使我们能够:(1)在查找Web服务器之前始终在本地查找依赖项,(2)在本地作为构建选项(目标)发布.

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).

如果这不是真的,或者我错过了任何步骤,请请告知!.否则,我可能可以从Ivy文档中找出如何添加文件系统解析器的方法,但不知道如何使publish-locally目标起作用.有任何想法吗?预先感谢!

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!

推荐答案

我也更喜欢Marks方法.

I too would prefer Marks approach.

关于publish-locally,您可以告诉发布任务要使用哪个resolver(resolver="local").这样,它可以发布到本地文件系统或任何定义的解析器.

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.

<ivy:publish
        resolver="local"
        overwrite="true"
        revision="${project.version}">
        <artifacts pattern="dist/[artifact]-[revision].[type]" />
    </ivy:publish>

如果使用链式解析器,则应设置returnFirst="true",以便在本地发现某些内容时停止解析.

And if you use a chain resolver you should set returnFirst="true" so that resolving will stop when something was found locally.

这篇关于Ivy:在本地解决和发布JAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 16:42