简体   繁体   English

如何在Java中使用Aether搜索RemoteRepositories?

[英]How search RemoteRepositories with Aether in Java?

How can I search a specific artifact in Aether? 如何在Aether中搜索特定的工件?

Dependency dependency =
    new Dependency( new DefaultArtifact( "com.google.code.gson:gson:war:sources:2.5" ), "compile" );
RemoteRepository central = new RemoteRepository.Builder( "central", "default", "http://repo1.maven.org/maven2/" ).build();

CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot( dependency );
collectRequest.addRepository( central );
DependencyNode node = repoSystem.collectDependencies( session, collectRequest ).getRoot();

DependencyRequest dependencyRequest = new DependencyRequest();
dependencyRequest.setRoot( node );

repoSystem.resolveDependencies( session, dependencyRequest  );

PreorderNodeListGenerator nlg = new PreorderNodeListGenerator();
node.accept( nlg );
System.out.println( nlg.getClassPath() );

At first, I want to search all "gson" in RemoteRepository and get result with all information then download it. 首先,我想在RemoteRepository中搜索所有“ gson”并获取包含所有信息的结果,然后下载它。 But how? 但是如何? In this example, I must set correct one and download it. 在此示例中,我必须设置正确的一个并下载。

You can't search for artifacts by name with Aether or Maven. 您无法使用Aether或Maven按名称搜索工件。

If you want a search engine, try http://search.maven.org . 如果您想要搜索引擎,请尝试http://search.maven.org There's also a REST API . 还有一个REST API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM