سؤال

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

هل كانت مفيدة؟

المحلول 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.

نصائح أخرى

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

Artifact artifact = new DefaultArtifact("com.google.guava", "guava", "jar", "18.0");
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top