1 package org.apache.maven.resolver.examples;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.resolver.examples.util.Booter;
23 import org.eclipse.aether.RepositorySystem;
24 import org.eclipse.aether.RepositorySystemSession;
25 import org.eclipse.aether.artifact.Artifact;
26 import org.eclipse.aether.artifact.DefaultArtifact;
27 import org.eclipse.aether.graph.Dependency;
28 import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
29 import org.eclipse.aether.resolution.ArtifactDescriptorResult;
30
31
32
33
34 public class GetDirectDependencies
35 {
36
37
38
39
40
41
42 public static void main( String[] args )
43 throws Exception
44 {
45 System.out.println( "------------------------------------------------------------" );
46 System.out.println( GetDirectDependencies.class.getSimpleName() );
47
48 RepositorySystem system = Booter.newRepositorySystem();
49
50 RepositorySystemSession session = Booter.newRepositorySystemSession( system );
51
52 Artifact artifact = new DefaultArtifact( "org.apache.maven.resolver:maven-resolver-impl:1.3.3" );
53
54 ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
55 descriptorRequest.setArtifact( artifact );
56 descriptorRequest.setRepositories( Booter.newRepositories( system, session ) );
57
58 ArtifactDescriptorResult descriptorResult = system.readArtifactDescriptor( session, descriptorRequest );
59
60 for ( Dependency dependency : descriptorResult.getDependencies() )
61 {
62 System.out.println( dependency );
63 }
64 }
65
66 }