0

How do I use the Aether library to look up an artifact's URI?

4

2 回答 2

0

根据http://dev.eclipse.org/mhonarc/lists/aether-users/msg00127.html,您可以执行以下操作:

Artifact artifact = new DefaultArtifact("com.google.guava", "guava", "jar", "18.0");
MavenDefaultLayout defaultLayout = new MavenDefaultLayout();
RemoteRepository centralRepository = new RemoteRepository.Builder("central", "default", "http://repo1.maven.org/maven2/").build();
URI centralUri = URI.create(centralRepository.getUrl());
URI artifactUri = centralUri.resolve(defaultLayout.getPath(artifact));

应该在哪里artifact更改为您要查找的工件。

于 2013-09-28T15:52:17.613 回答
0

只是为了完成正确的答案。你可以像这样创建一个工件

Artifact artifact = new DefaultArtifact("com.google.guava", "guava", "jar", "18.0");
于 2014-09-19T08:33:00.177 回答