我正在尝试使用eclipse-aether收集工件的依赖项,执行以下操作:
Artifact artifact = ...
DependencyVisitor dependencySaver = ...
ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
descriptorRequest.setArtifact(artifact);
descriptorRequest.setRepositories(Booter.newRepositories(system, session));
ArtifactDescriptorResult descriptorResult = system.readArtifactDescriptor(session, descriptorRequest);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRootArtifact(descriptorResult.getArtifact());
collectRequest.setDependencies(descriptorResult.getDependencies());
collectRequest.setManagedDependencies(descriptorResult.getManagedDependencies());
collectRequest.setRepositories(descriptorRequest.getRepositories());
CollectResult collectResult = system.collectDependencies(session, collectRequest);
collectResult.getRoot().accept(dependencySaver);
Apache存储库恰好包含具有依赖关系的工件,它们本身并不在存储库中。例如,org.apache.deltaspike:parent-code:pom:1.1.0依赖于org.jboss.arquillian:arquillian-bom:pom:1.0.2.Final
,它不存在。
在这种情况下,Aether 拒绝报告结果:
org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.deltaspike:parent-code:pom:1.1.0
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:364)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:217)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor(DefaultRepositorySystem.java:287)
at xxxxxxx.DependencyScanner$NodeScanner.run(DependencyScanner.java:128)
at xxxxxxx.InsistentExecutor$Slave$ActionRunnable.run(InsistentExecutor.java:226)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.maven.model.resolution.UnresolvableModelException: Could not find artifact org.jboss.arquillian:arquillian-bom:pom:1.0.2.Final in apache (https://repository.apache.org/content/repositories/releases)
at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:126)
at org.apache.maven.model.building.DefaultModelBuilder.importDependencyManagement(DefaultModelBuilder.java:966)
at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:397)
at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:368)
at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:359)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:355)
... 9 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact org.jboss.arquillian:arquillian-bom:pom:1.0.2.Final in apache (https://repository.apache.org/content/repositories/releases)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223)
at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:122)
... 14 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.jboss.arquillian:arquillian-bom:pom:1.0.2.Final in apache (https://repository.apache.org/content/repositories/releases)
at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:39)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
... 17 more
有没有办法让以太至少给出所有可访问依赖项的名称的部分结果?