如何在 Java 中使用 Aether 搜索 RemoteRepositories?
How search RemoteRepositories with Aether in Java?
如何在 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() );
起初,我想在 RemoteRepository 中搜索所有 "gson" 并获得包含所有信息的结果,然后下载它。但是怎么办?在这个例子中,我必须设置正确并下载它。
您无法使用 Aether 或 Maven 按名称搜索工件。
如果您需要搜索引擎,请尝试 http://search.maven.org. There's also a REST API。
如何在 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() );
起初,我想在 RemoteRepository 中搜索所有 "gson" 并获得包含所有信息的结果,然后下载它。但是怎么办?在这个例子中,我必须设置正确并下载它。
您无法使用 Aether 或 Maven 按名称搜索工件。
如果您需要搜索引擎,请尝试 http://search.maven.org. There's also a REST API。