gpt4 book ai didi

maven - 使用来自 Ivy 的时间戳解决 SNAPSHOT 依赖项

转载 作者:行者123 更新时间:2023-12-04 17:59:01 25 4
gpt4 key购买 nike

我正在尝试使用 Ivy 解决带时间戳的 SNAPSHOT 依赖项。

环境是 Ant + Ivy 1.2.0 + Archiva。 Archiva 本身由 Maven2 构建填充。 Ivy 仅用于解析依赖项(来自单个非 Maven2 项目)。

如何配置 Ivy 以正确解析来自 Archiva 或 m2 存储库的带时间戳的 Artifact ?

作为引用,我目前的配置是:

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 不会尝试解析带时间戳的 Artifact 。例如。
[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

有一个 maven-metadata.xml 快照/com/myorg/myartifact :
<?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>

maven-metadata.xml 快照/com/myorg/myartifact/1.8.0-SNAPSHOT :
<?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>

不是那么有用,但为了完整性,目录 中的文件快照/com/myorg/myartifact/1.8.0-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 解析器上的指定模式必须以:

[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]

在您的设置中并非如此,因此 Ivy 不会尝试查找您的时间戳快照。将您的模式更新为这个模式应该可以解决您的问题;将您的存档快照存储库的定义更新为:
    <ibiblio name="archiva-snapshots"
m2compatible="true"
usepoms="true"
pattern="[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
root="http://host:port/archiva/repository/snapshots"/>

备注:注意 [organisation] 中的 's' 而不是 'z'。

马丁

关于maven - 使用来自 Ivy 的时间戳解决 SNAPSHOT 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2399099/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com