如何使用REST以编程方式从apache archiva下载单个工件?

时间:2013-10-11 12:20:24

标签: java rest archiva

我浏览了文档,发现了很多有用的东西。我目前正在使用apache archiva作为镜像。使用maven下载工件可以正常工作,但我希望能够出于某些原因使用REST api下载工件。

现在我可以通过使用工件下载URL的直接URL来实现,这似乎不是一个好方法。

我是否遗漏了任何可以让我执行以下服务器的休息服务:port / restServices / getArtifact / groupId / artifactId / version

2 个答案:

答案 0 :(得分:7)

REST调用是:

GET http://server/restServices/archivaServices/browseService/artifactDownloadInfos/{group}/{artifact}/{version}

响应包含一个条目列表,其“url”键是下载工件的链接。每个可下载资源都有一个条目,例如一个用于jar,另一个用于pom等.'type'键可用于指示哪个。

回复示例:

[
      {
      "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
   }
]

享受!

答案 1 :(得分:1)

您可以使用Maven网址上的get下载工件。搜索返回的工件应该返回给您。