Reputation: 10377
I want to list all available versions of a Nexus (2.11.1-01) snapshot repository.
The way via REST api / lucene and gav coordinates
like that :
http://nexus/service/local/lucene/search?g=com.foo&a=foo-bar&v=
lists the snapshot versions, but also release versions, because the artifact foo-bar also exists in a release repository. Because of that, i read the maven-metadata.xml :
http://nexus/service/local/repositories/com-foo-snapshots/content/com/foo/foo-bar/maven-metadata.xml
The lucene search lacks a repository coordinate like the maven feature, f.e.
get the latest version of a snapshot :
http://nexus/service/local/artifact/maven/resolve?r=com-foo-snapshots&g=com.foo&a=foo-bar&v=0.3-SNAPSHOT
or get the recent snapshot version :
http://nexus/service/local/artifact/maven/resolve?r=com-foo-snapshots&g=com.foo&a=foo-bar&v=LATEST
Seems, i cant't use the maven-metadata.xml, because not every repository contains that file.
Is there any other way via Nexus REST api or another api to get all versions of a specific Nexus repository/artifactid even if artefactid exists in different repositories ?
Is it possible to force the creation of a maven-metadata.xml for every repository ?
The available administrative scheduled Nexus Task ain't sufficient, maybe a trigger that fires with every artifact update ?
Upvotes: 2
Views: 7869
Reputation: 5931
No need to manually parse maven-metadata.xml.
http://nexus/service/local/lucene/search?g=com.foo&a=foo-bar
returns for every <artifactHit>
all the remaining items that uniquely identify whatever can be downloaded from Nexus, that is: <repositoryId>
and <extension>
(and <classifier>
here undefined):
...
<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>
So after you parse lucene/search response on your own, you can filter it by repositoryId. I think it answers how "to get all versions of a specific Nexus repository/artifactid even if artefactid exists in different repositories".
Upvotes: 3