How do I find out an artifact's URI?

╄→尐↘猪︶ㄣ 提交于 2019-12-12 01:28:13

问题


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


回答1:


just to complete the correct answer. you can create an artifact like this

Artifact artifact = new DefaultArtifact("com.google.guava", "guava", "jar", "18.0");



回答2:


According to http://dev.eclipse.org/mhonarc/lists/aether-users/msg00127.html, you can do the following:

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));

Where artifact should be changed to the artifact you want to look up.



来源:https://stackoverflow.com/questions/19068736/how-do-i-find-out-an-artifacts-uri

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!