我有一个Nexus maven repo,我想利用REST API来查询我特定组中的工件列表.我偶然发现了这个文档,但它似乎非常简洁,我找不到我需要的东西.
https://oss.sonatype.org/nexus-restlet1x-plugin/default/docs/rest.html
我想要这样的东西
http://mydomain:8081/nexus/service/local/repositories/list?groupId=com.test.superproduct&repo=snapshots
Run Code Online (Sandbox Code Playgroud)
它会输出一个列表
更具体地说,我需要一个位于组中的工件版本列表,但我也可以从工件名称中提取版本.
Ser*_*nov 16
我发现我需要的是获取maven-metadata.xml`文件,该文件包含此工件可用的所有版本.例如,
https://oss.sonatype.org/service/local/repositories/snapshots/content/com/alibaba/rocketmq/rocketmq-all/maven-metadata.xml
Run Code Online (Sandbox Code Playgroud)
包含
<?xml version="1.0" encoding="UTF-8"?>
<metadata modelVersion="1.1.0">
<groupId>com.alibaba.rocketmq</groupId>
<artifactId>rocketmq-all</artifactId>
<versioning>
<latest>3.1.8-SNAPSHOT</latest>
<release></release>
<versions>
<version>3.0.2-open-SNAPSHOT</version>
<version>3.0.10-ALIYUN-SNAPSHOT</version>
<version>3.0.11-SNAPSHOT</version>
<version>3.1.8-SNAPSHOT</version>
</versions>
<lastUpdated>20140807060304</lastUpdated>
</versioning>
</metadata>
Run Code Online (Sandbox Code Playgroud)
kub*_*zyk 15
无需手动解析maven-metadata.xml.无需手动解析目录名称或文件名.
http://localhost/nexus/service/local/lucene/search?g=com.foo&a=foo-bar
Run Code Online (Sandbox Code Playgroud)
不仅返回<version>此版本的每个工件的每一个,而且作为奖励,获取驻留在此Nexus实例上的任何单个文件的唯一下载URL所需的所有标识符.下载URL所需的标识符是:<groupId>,<artifactId>(这两个你说你已经知道了), ,<version>,<repositoryId>(<extension>而<classifier>这是可选的,不确定的在我的例子):
...
<artifact>
<groupId>com.foo</groupId>
<artifactId>foo-bar</artifactId>
<version>2.8.1</version>
<latestSnapshot>2.8.5-SNAPSHOT</latestSnapshot>
<latestSnapshotRepositoryId>snapshots</latestSnapshotRepositoryId>
<latestRelease>2.8.3</latestRelease>
<latestReleaseRepositoryId>releases</latestReleaseRepositoryId>
<artifactHits>
<artifactHit>
<repositoryId>releases</repositoryId>
<artifactLinks>
<artifactLink>
<extension>pom</extension>
</artifactLink>
<artifactLink>
<extension>war</extension>
</artifactLink>
</artifactLinks>
</artifactHit>
</artifactHits>
</artifact>
<artifact>
<groupId>com.foo</groupId>
<artifactId>foo-bar</artifactId>
<version>2.8.0</version>
<latestSnapshot>2.8.5-SNAPSHOT</latestSnapshot>
<latestSnapshotRepositoryId>snapshots</latestSnapshotRepositoryId>
<latestRelease>2.8.3</latestRelease>
<latestReleaseRepositoryId>releases</latestReleaseRepositoryId>
<artifactHits>
<artifactHit>
<repositoryId>releases</repositoryId>
<artifactLinks>
<artifactLink>
<extension>pom</extension>
</artifactLink>
<artifactLink>
<extension>war</extension>
</artifactLink>
</artifactLinks>
</artifactHit>
</artifactHits>
</artifact>
Run Code Online (Sandbox Code Playgroud)
在解析lucene/search响应之后,一个好主意是通过repositoryId将其过滤为releases或者snapshots.
这个答案适用于Nexus 2.11.
| 归档时间: |
|
| 查看次数: |
17486 次 |
| 最近记录: |