Hi,
I am writing a Nexus Plugin that would record all the transitive dependencies of any deployed artifact. I have some trouble to get the dependencies properly resolved. Here are the pending problems I have:
Any pointer? At this stage point 1 is the more important. Oscar Picasso |
Buenas Oscar
mavenRepository? repositories? getRepositories()? getRepositorySession()? nexus-indexer version? Saludos! Date: Mon, 28 Apr 2014 08:55:33 -0400 From: [hidden email] To: [hidden email] Subject: [nexus-dev] Resolve dependencies inside a Nexus Plugin Hi,
I am writing a Nexus Plugin that would record all the transitive dependencies of any deployed artifact. I have some trouble to get the dependencies properly resolved.
Here are the pending problems I have:
Any pointer?
At this stage point 1 is the more important.
Oscar Picasso |
Hi Martin, Below refactored code that also show the details. Take note that getRepositories() was a copy/paste mistake in my first email. The real resolveDependencies call is in the code below.
@Named public class DeployRecorder2 extends ComponentSupport implements
EventSubscriber { private final NexusAether nexusAether;
private final RepositoryRegistry repositoryRegistry; @Inject public DeployRecorder2(final NexusAether nexusAether,
final RepositoryRegistry repositoryRegistry) { this.nexusAether = checkNotNull(nexusAether);
this.repositoryRegistry = checkNotNull(repositoryRegistry); }
@Subscribe public void onDeployEvent2(RepositoryItemEventStoreCreate event)
throws Exception { final StorageItem item = event.getItem();
final String path = item.getPath(); if (item instanceof StorageFileItem && path.endsWith(".pom")) {
MavenRepository mavenRepository = (MavenRepository) event .getRepository();
GavCalculator calculator = mavenRepository.getGavCalculator(); Gav gav = calculator.pathToGav(event.getItem().getPath());
Dependency dependency = Utils.createDependencyFromGav(gav, null);
// building repository list, "public" is a nexus repository group
List<RemoteRepository> repositories = new ArrayList<>(); Repository repository = repositoryRegistry.getRepository("public");
M2GroupRepository repoGroup = (M2GroupRepository) repository; List<Repository> members = repoGroup.getMemberRepositories();
for (Repository member : members) { repositories.add(new RemoteRepository(member.getId(),
"default", repository.getLocalUrl())); }
CollectRequest collectRequest = new CollectRequest(dependency,
repositories); DependencyRequest dependencyRequest = new DependencyRequest(
collectRequest, null); DependencyResult result = nexusAether.getRepositorySystem()
.resolveDependencies( nexusAether.getDefaultRepositorySystemSession(),
dependencyRequest); List<ArtifactResult> artifactResults = result.getArtifactResults();
// / etc. }
} } Regards Oscar On Mon, Apr 28, 2014 at 9:12 AM, Martin Gainty <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |