我浏览了文档,发现了许多有用的东西。我目前正在使用 apache archiva 作为镜像。使用 maven 下载工件可以正常工作,但出于某些原因,我希望能够使用 REST api 下载工件。
现在我可以通过使用指向工件下载 URL 的直接 url 来做到这一点,这似乎不是一个好方法。
是否有任何我错过的休息服务可以让我执行以下服务器:port/restServices/getArtifact/groupId/artifactId/version
The REST call is:
GET http://server/restServices/archivaServices/browseService/artifactDownloadInfos/{group}/{artifact}/{version}
The response contains a list of entries whose 'url' key is the link to download the artifact. There's an entry for each downloadable resource, e.g. one for jar, another for pom, etc. The 'type' key can be used to tell which.
Example response:
[
{
"context": "internal",
"url": "http://server/repository/internal/group/artifact/version/artifact-version.jar",
"groupId": "group",
"artifactId": "obs.interfaces",
"repositoryId": "internal",
"version": "version",
"prefix": null,
"goals": null,
"bundleVersion": null,
"bundleSymbolicName": null,
"bundleExportPackage": null,
"bundleExportService": null,
"bundleDescription": null,
"bundleName": null,
"bundleLicense": null,
"bundleDocUrl": null,
"bundleImportPackage": null,
"bundleRequireBundle": null,
"classifier": null,
"packaging": "jar",
"fileExtension": "jar",
"size": "31.78 K",
"type": "jar",
"path": "group/artifact/version/artifact-version.jar",
"id": "artifact-version.jar",
"scope": null
},
{
"context": "internal",
"url": "http://server/repository/internal/group/artifact/version/artifact-version.pom",
"groupId": "group",
"artifactId": "artifact",
"repositoryId": "internal",
"version": "version",
"prefix": null,
"goals": null,
"bundleVersion": null,
"bundleSymbolicName": null,
"bundleExportPackage": null,
"bundleExportService": null,
"bundleDescription": null,
"bundleName": null,
"bundleLicense": null,
"bundleDocUrl": null,
"bundleImportPackage": null,
"bundleRequireBundle": null,
"classifier": null,
"packaging": "pom",
"fileExtension": "pom",
"size": "1.58 K",
"type": "pom",
"path": "group/artifact/version/artifact-version.pom",
"id": "artifact-version.pom",
"scope": null
}
]
Enjoy!
您可以通过 Maven url 上的 get 下载工件。搜索返回的工件应将其返回给您。