本文整理汇总了Java中org.sonatype.aether.collection.CollectRequest.setRoot方法的典型用法代码示例。如果您正苦于以下问题:Java CollectRequest.setRoot方法的具体用法?Java CollectRequest.setRoot怎么用?Java CollectRequest.setRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sonatype.aether.collection.CollectRequest
的用法示例。
在下文中一共展示了CollectRequest.setRoot方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getArtifactsWithDep
import org.sonatype.aether.collection.CollectRequest; //导入方法依赖的package包/类
/**
*
* @param dependency
* @param excludes list of pattern can either be of the form groupId:artifactId
* @return
* @throws Exception
*/
public List<ArtifactResult> getArtifactsWithDep(String dependency,
Collection<String> excludes) throws Exception {
Artifact artifact = new DefaultArtifact(inferScalaVersion(dependency));
DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter( JavaScopes.COMPILE );
PatternExclusionsDependencyFilter exclusionFilter =
new PatternExclusionsDependencyFilter(inferScalaVersion(excludes));
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
synchronized (repos) {
for (RemoteRepository repo : repos) {
collectRequest.addRepository(repo);
}
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
DependencyFilterUtils.andFilter(exclusionFilter, classpathFlter));
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
示例2: fetchArtifactWithDep
import org.sonatype.aether.collection.CollectRequest; //导入方法依赖的package包/类
private List<ArtifactResult> fetchArtifactWithDep(Dependency dep)
throws DependencyResolutionException, ArtifactResolutionException {
Artifact artifact = new DefaultArtifact(dep.getGroupArtifactVersion());
DependencyFilter classpathFilter = DependencyFilterUtils
.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(
dep.getExclusions());
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new org.sonatype.aether.graph.Dependency(artifact,
JavaScopes.COMPILE));
collectRequest.addRepository(mavenCentral);
collectRequest.addRepository(mavenLocal);
for (Repository repo : repositories) {
RemoteRepository rr = new RemoteRepository(repo.getId(), "default", repo.getUrl());
rr.setPolicy(repo.isSnapshot(), null);
collectRequest.addRepository(rr);
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
示例3: getArtifactsWithDep
import org.sonatype.aether.collection.CollectRequest; //导入方法依赖的package包/类
/**
* @param dependency
* @param excludes list of pattern can either be of the form groupId:artifactId
* @return
* @throws Exception
*/
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency,
Collection<String> excludes) throws RepositoryException {
Artifact artifact = new DefaultArtifact(dependency);
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter =
new PatternExclusionsDependencyFilter(excludes);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
synchronized (repos) {
for (RemoteRepository repo : repos) {
collectRequest.addRepository(repo);
}
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
try {
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
} catch (NullPointerException | DependencyResolutionException ex) {
throw new RepositoryException(
String.format("Cannot fetch dependencies for %s", dependency), ex);
}
}
示例4: getArtifactsWithDep
import org.sonatype.aether.collection.CollectRequest; //导入方法依赖的package包/类
/**
* @param dependency
* @param excludes list of pattern can either be of the form groupId:artifactId
* @return
* @throws Exception
*/
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency,
Collection<String> excludes) throws Exception {
Artifact artifact = new DefaultArtifact(inferScalaVersion(dependency));
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter =
new PatternExclusionsDependencyFilter(inferScalaVersion(excludes));
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
synchronized (repos) {
for (RemoteRepository repo : repos) {
collectRequest.addRepository(repo);
}
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
示例5: testCollectDependencies
import org.sonatype.aether.collection.CollectRequest; //导入方法依赖的package包/类
public void testCollectDependencies()
throws Exception
{
Artifact artifact = new DefaultArtifact( "ut.simple:artifact:extension:classifier:1.0" );
// notice: extension and classifier not really used in this test...
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot( new Dependency( artifact, null ) );
collectRequest.addRepository( newTestRepository() );
CollectResult collectResult = system.collectDependencies( session, collectRequest );
List<DependencyNode> nodes = collectResult.getRoot().getChildren();
assertEquals( 2, nodes.size() );
checkUtSimpleArtifactDependencies( nodes.get( 0 ).getDependency(), nodes.get( 1 ).getDependency() );
}
示例6: resolve
import org.sonatype.aether.collection.CollectRequest; //导入方法依赖的package包/类
private void resolve( ResolveRequest resolveRequest )
{
RepositorySystem system = newRepositorySystem();
RepositorySystemSession session = newRepositorySystemSession( system, resolveRequest.localRepoDir );
org.sonatype.aether.artifact.Artifact artifact = new DefaultArtifact(
resolveRequest.groupId + ":" + resolveRequest.artifactId + ":" + resolveRequest.version );
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot( new Dependency( artifact, "" ) );
// add remote repositories
for ( RemoteRepository remoteRepository : resolveRequest.remoteRepositories )
{
collectRequest.addRepository(
new org.sonatype.aether.repository.RemoteRepository( remoteRepository.getId(), "default",
remoteRepository.getUrl() ) );
}
collectRequest.setRequestContext( "project" );
//collectRequest.addRepository( repo );
try
{
CollectResult collectResult = system.collectDependencies( session, collectRequest );
collectResult.getRoot().accept( resolveRequest.dependencyVisitor );
log.debug( "test" );
}
catch ( DependencyCollectionException e )
{
log.error( e.getMessage(), e );
}
}
示例7: createCollectRequestForGAV
import org.sonatype.aether.collection.CollectRequest; //导入方法依赖的package包/类
private CollectRequest createCollectRequestForGAV(String gav) {
DefaultArtifact artifact = new DefaultArtifact(gav);
Dependency dependency = new Dependency(artifact, COMPILE_SCOPE);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(dependency);
for (RemoteRepository repository : repositories) {
collectRequest.addRepository(repository);
}
return collectRequest;
}
示例8: resolveDependencies
import org.sonatype.aether.collection.CollectRequest; //导入方法依赖的package包/类
/**
* Resolves dependencies transitively from the given jar artifact, with the specified Maven scope
* (compile, runtime, and so on.)
*/
public DependencyResult resolveDependencies(GAV a, String scope) throws DependencyResolutionException {
DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(scope);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(new DefaultArtifact(a.toString()), JavaScopes.COMPILE));
collectRequest.setRepositories(remoteRepositories);
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFlter);
return resolveDependencies(dependencyRequest);
}
示例9: getClasspathFromMavenProject
import org.sonatype.aether.collection.CollectRequest; //导入方法依赖的package包/类
public static List<String> getClasspathFromMavenProject(File projectPom, File localRepoFolder, boolean isRunwayEnvironment) throws DependencyResolutionException, IOException, XmlPullParserException
{
MavenProject proj = loadProject(projectPom);
PropertyReplacer propReplacer = new PropertyReplacer(proj);
List<Repository> repos = proj.getRepositories();
List<String> classpath = new ArrayList<String>();
RepositorySystem system = Booter.newRepositorySystem();
RepositorySystemSession session = Booter.newRepositorySystemSession( system, localRepoFolder );
RemoteRepository centralRepo = Booter.newCentralRepository();
DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter( JavaScopes.COMPILE );
List<org.apache.maven.model.Dependency> dependencies = proj.getDependencies();
Iterator<org.apache.maven.model.Dependency> it = dependencies.iterator();
while (it.hasNext()) {
org.apache.maven.model.Dependency depend = it.next();
Artifact artifact = new DefaultArtifact(propReplacer.replace(depend.getGroupId()), propReplacer.replace(depend.getArtifactId()), propReplacer.replace(depend.getClassifier()), propReplacer.replace(depend.getType()), propReplacer.replace(depend.getVersion()));
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot( new Dependency( artifact, JavaScopes.COMPILE ) );
collectRequest.addRepository( centralRepo );
for (Repository repo : repos) {
collectRequest.addRepository(new RemoteRepository(propReplacer.replace(repo.getId()), propReplacer.replace(repo.getLayout()), propReplacer.replace(repo.getUrl())));
}
try {
DependencyRequest dependencyRequest = new DependencyRequest( collectRequest, classpathFlter );
List<ArtifactResult> artifactResults =
system.resolveDependencies( session, dependencyRequest ).getArtifactResults();
for ( ArtifactResult artifactResult : artifactResults )
{
Artifact art = artifactResult.getArtifact();
if (isRunwayEnvironment && art.getGroupId().equals("com.runwaysdk") && (
art.getArtifactId().equals("runwaysdk-client") ||
art.getArtifactId().equals("runwaysdk-common") ||
art.getArtifactId().equals("runwaysdk-server")
)) {
continue;
}
classpath.add(art.getFile().getAbsolutePath());
}
}
catch (DependencyResolutionException e) {
// Is Maven ignoring this? I'm confused.
log.error(e);
e.printStackTrace();
}
}
if (log.isTraceEnabled()) {
String cpath = "";
for (Iterator<String> i = classpath.iterator(); i.hasNext();) {
cpath = cpath + ", " + i.next();
}
log.trace("Resolved pom [" + projectPom.getAbsolutePath() + "] classpath to [" + cpath + "]");
}
return classpath;
}