我一直在使用 Ivy,但我似乎还有很多东西要学。
我有两个项目。一个是 Web 应用程序,另一个是 Web 应用程序所依赖的库。设置是将库项目编译为 jar 文件并使用 Ivy 发布到项目内的目录中。在 Web 应用程序构建文件中,我有一个调用 Ivy 解析 ant 任务的 ant 目标。
我想做的是让 Web 应用程序在开发期间(在开发人员的本地机器上)使用动态解析模式,并为测试和生产构建使用默认解析模式。以前我在库存档文件中附加了一个时间戳,这样当网络应用程序试图解决它对它的依赖时,Ivy 会注意到文件的变化。在 Eclipse 中,这很麻烦,因为在 Web 应用程序中,每次发布新的库 jar 时都必须刷新项目并调整构建路径。我认为,每次发布一个类似命名的 jar 文件只需要开发人员刷新项目。
问题是 Web 应用程序无法检索动态 jar 文件。
我得到的输出看起来像这样:
resolve:
[ivy:configure] :: Ivy 2.1.0 - 20090925235825 :: http://ant.apache.org/ivy/ ::
[ivy:configure] :: loading settings :: file = /Users/richard/workspace/webapp/web/WEB-INF/config/ivy/ivysettings.xml
[ivy:resolve] :: resolving dependencies :: com.webapp#webapp;working@hoth-3.local
[ivy:resolve] confs: [default]
[ivy:resolve] found com.webapp#library;latest.integration in local
[ivy:resolve] :: resolution report :: resolve 142ms :: artifacts dl 0ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 1 | 0 | 0 | 0 || 0 | 0 |
---------------------------------------------------------------------
[ivy:resolve]
[ivy:resolve] :: problems summary ::
[ivy:resolve] :::: WARNINGS
[ivy:resolve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve] :: UNRESOLVED DEPENDENCIES ::
[ivy:resolve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve] :: com.webapp#library;latest.integration: impossible to resolve dynamic revision
[ivy:resolve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve] :::: ERRORS
[ivy:resolve] impossible to resolve dynamic revision for com.webapp#library;latest.integration: check your configuration and make sure revision is part of your pattern
[ivy:resolve]
[ivy:resolve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
BUILD FAILED
/Users/richard/workspace/webapp/build.xml:71: impossible to resolve dependencies:
resolve failed - see output for details
Web 应用程序解析目标如下所示:
<target name="resolve" depends="load-ivy">
<ivy:configure file="${ivy.dir}/ivysettings.xml" />
<ivy:resolve
file="${ivy.dir}/ivy.xml"
resolveMode="${ivy.resolve.mode}"/>
<ivy:retrieve pattern="${lib.dir}/[artifact]-[revision].[ext]" type="jar" sync="true" />
</target>
在这种情况下,ivy.resolve.mode 的值为“动态”(不带引号)。
Web 应用程序的 Ivy 文件很简单。它看起来像这样:
<ivy-module version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="com.webapp" module="webapp"/>
<dependencies>
<dependency name="library" rev="${ivy.revision.default}" revConstraint="${ivy.revision.dynamic}" />
</dependencies>
</ivy-module>
在开发过程中,ivy.revision.dynamic 的值为“latest.integration”。而在生产或测试期间,“ivy.revision.default”的值为“1.0”。
有任何想法吗?如果我需要提供更多信息,请告诉我。
谢谢!