问题描述
我正在尝试使用常春藤解决带有时间戳的SNAPSHOT依赖性.
I am attempting to resolve timestamped SNAPSHOT dependencies with Ivy.
环境是Ant + Ivy 1.2.0 + Archiva. Archiva本身是从Maven2构建中填充的. Ivy仅用于解决依赖关系(来自单个非Maven2项目).
The environment is Ant + Ivy 1.2.0 + Archiva. Archiva itself is populated from Maven2 builds. Ivy is only used to resolve dependencies (from a single, non Maven2 project).
如何将Ivy配置为正确解决来自Archiva或m2存储库的带有时间戳的工件?
作为参考,我当前的配置是:
For reference my current configuration is:
ivysettings.xml 类似于:
<ivysettings>
<settings defaultResolver="archiva-chain"/>
<resolvers>
<chain name="archiva-chain" changingPattern=".*SNAPSHOT" checkmodified="true">
<ibiblio name="archiva-internal"
m2compatible="true"
usepoms="true"
pattern="[organization]/[module]/[revision]/[artifact]-[revision].[ext]"
root="http://host:port/archiva/repository/internal"/>
<ibiblio name="archiva-deploy"
m2compatible="true"
usepoms="true"
pattern="[organization]/[module]/[revision]/[artifact]-[revision].[ext]"
root="http://host:port/archiva/repository/deploy"/>
<ibiblio name="archiva-snapshots"
m2compatible="true"
usepoms="true"
pattern="[organization]/[module]/[revision]/[artifact]-[revision].[ext]"
root="http://host:port/archiva/repository/snapshots"/>
</chain>
</resolvers>
</ivysettings>
ivy.xml 依赖项很简单:
<ivy-module version="2.0">
<info organisation="com.myorg" module="myapp"/>
<dependencies>
<dependency org="com.myorg" name="myartifact" rev="1.8.0-SNAPSHOT" changing="true"/>
</dependencies>
</ivy-module>
Ivy不会尝试解决带有时间戳的工件.例如
Ivy does not attempt to resolve a timestamped artifact. E.g.
[ivy:retrieve] :: problems summary ::
[ivy:retrieve] :::: WARNINGS
[ivy:retrieve] module not found: com.myorg#myartifact;1.8.0-SNAPSHOT
[ivy:retrieve] ==== archiva-internal: tried
[ivy:retrieve] -- artifact com.myorg#myartifact;1.8.0-SNAPSHOT!myartifact.jar:
[ivy:retrieve] http://host:port/archiva/repository/internal/com.myorg/myartifact/1.8.0-SNAPSHOT/myartifact-1.8.0-SNAPSHOT.jar
[ivy:retrieve] ==== archiva-deploy: tried
[ivy:retrieve] -- artifact com.myorg#myartifact;1.8.0-SNAPSHOT!myartifact.jar:
[ivy:retrieve] http://host:port/archiva/repository/deploy/com.myorg/myartifact/1.8.0-SNAPSHOT/myartifact-1.8.0-SNAPSHOT.jar
[ivy:retrieve] ==== archiva-snapshots: tried
[ivy:retrieve] -- artifact com.myorg#myartifact;1.8.0-SNAPSHOT!myartifact.jar:
[ivy:retrieve] http://host:port/archiva/repository/snapshots/com.myorg/myartifact/1.8.0-SNAPSHOT/myartifact-1.8.0-SNAPSHOT.jar
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] :: UNRESOLVED DEPENDENCIES ::
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] :: com.myorg#myartifact;1.8.0-SNAPSHOT: not found
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]
[ivy:retrieve]
[ivy:retrieve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
snapshots/com/myorg/myartifact 中有一个 maven-metadata.xml :
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.myorg</groupId>
<artifactId>myartifact</artifactId>
<versioning>
<latest>1.8.0-SNAPSHOT</latest>
<versions>
<version>1.3.0-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
<version>1.6.1-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
</versions>
<lastUpdated>20100303003206</lastUpdated>
</versioning>
</metadata>
snapshots/com/myorg/myartifact/1.8.0-SNAPSHOT 中的 maven-metadata.xml :
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.myorg</groupId>
<artifactId>myartifact</artifactId>
<version>1.8.0-SNAPSHOT</version>
<versioning>
<snapshot>
<buildNumber>7</buildNumber>
<timestamp>20100303.003206</timestamp>
</snapshot>
<lastUpdated>20100303003206</lastUpdated>
</versioning>
</metadata>
对于引用的快照, snapshots/com/myorg/myartifact/1.8.0-SNAPSHOT 目录中的文件不是很有用,但出于完整性考虑:
Not all that useful, but for completeness, the files in the directory snapshots/com/myorg/myartifact/1.8.0-SNAPSHOT for the referenced snapshot:
-rw-r--r-- 1 archiva archiva 240670 Mar 3 10:32 myartifact-1.8.0-20100303.003206-7.jar
-rw-r--r-- 1 archiva archiva 32 Mar 3 10:32 myartifact-1.8.0-20100303.003206-7.jar.md5
-rw-r--r-- 1 archiva archiva 40 Mar 3 10:32 myartifact-1.8.0-20100303.003206-7.jar.sha1
-rw-r--r-- 1 archiva archiva 4068 Mar 3 10:32 myartifact-1.8.0-20100303.003206-7.pom
-rw-r--r-- 1 archiva archiva 32 Mar 3 10:32 myartifact-1.8.0-20100303.003206-7.pom.md5
-rw-r--r-- 1 archiva archiva 40 Mar 3 10:32 myartifact-1.8.0-20100303.003206-7.pom.sha1
-rw-r--r-- 1 archiva archiva 180821 Mar 3 10:32 myartifact-1.8.0-20100303.003206-7-sources.jar
-rw-r--r-- 1 archiva archiva 32 Mar 3 10:32 myartifact-1.8.0-20100303.003206-7-sources.jar.md5
-rw-r--r-- 1 archiva archiva 40 Mar 3 10:32 myartifact-1.8.0-20100303.003206-7-sources.jar.sha1
推荐答案
Ivy支持解析带时间戳的快照,但有以下限制:ibiblio解析器上的指定模式必须以以下结尾:
Ivy supports resolving timestamped snapshots, but with the following limitation: the specified pattern on your ibiblio resolver must end with:
[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]
在您的设置中情况并非如此,因此Ivy不会尝试查找带有时间戳的快照.将您的模式更新为这一模式应该可以解决您的问题;将archiva-snapshots存储库的定义更新为:
This is not the case in your setup, so Ivy won't try to find your timestamped snapshot. Updating your pattern to this one should solve your problem; update the definition of your archiva-snapshots repository to:
<ibiblio name="archiva-snapshots"
m2compatible="true"
usepoms="true"
pattern="[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
root="http://host:port/archiva/repository/snapshots"/>
备注:请注意[组织]中的"s",而不是"z".
Remark: mind the 's' in [organisation] instead of the 'z'.
马丁
这篇关于使用来自Ivy的时间戳解析SNAPSHOT依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!