I have groupId
, artifactId
and version
. How do i write a GET request using Nexus Rest API in order to get further artifact description?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Not sure what information you're looking for.
The REST API doco is availble here:
- Core API
- Lucene API
Examples
Obtain the repository id
You're starting with: groupId, artifactId, version:
$ curl --silent 'http://repository.sonatype.org/service/local/lucene/search?g=log4j&a=log4j&v=1.2.16' | grep repositoryId
<repositoryId>central-proxy</repositoryId>
<repositoryId>apache-staging</repositoryId>
<repositoryId>central-proxy</repositoryId>
<repositoryId>apache-staging</repositoryId>
The repositoryId is mandatory in other API calls
Artifact resolution info
$ curl --silent 'http://repository.sonatype.org/service/local/artifact/maven/resolve?r=central-proxy&g=log4j&a=log4j&v=1.2.16'
<artifact-resolution>
<data>
<presentLocally>true</presentLocally>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<extension>jar</extension>
<snapshot>false</snapshot>
<snapshotBuildNumber>0</snapshotBuildNumber>
<snapshotTimeStamp>0</snapshotTimeStamp>
<sha1>7999a63bfccbc7c247a9aea10d83d4272bd492c6</sha1>
<repositoryPath>/log4j/log4j/1.2.16/log4j-1.2.16.jar</repositoryPath>
</data>
Retrieve the POM
$ curl --silent 'http://repository.sonatype.org/service/local/artifact/maven?r=central-proxy&g=log4j&a=log4j&v=1.2.16'
Retrieve the jar
$ curl --silent 'http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=log4j&a=log4j&v=1.2.16'