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.resolution.ArtifactRequest;
28 import org.eclipse.aether.resolution.ArtifactResult;
29
30
31
32
33 public class ResolveArtifact
34 {
35
36 public static void main( String[] args )
37 throws Exception
38 {
39 System.out.println( "------------------------------------------------------------" );
40 System.out.println( ResolveArtifact.class.getSimpleName() );
41
42 RepositorySystem system = Booter.newRepositorySystem();
43
44 RepositorySystemSession session = Booter.newRepositorySystemSession( system );
45
46 Artifact artifact = new DefaultArtifact( "org.eclipse.aether:aether-util:1.0.0.v20140518" );
47
48 ArtifactRequest artifactRequest = new ArtifactRequest();
49 artifactRequest.setArtifact( artifact );
50 artifactRequest.setRepositories( Booter.newRepositories( system, session ) );
51
52 ArtifactResult artifactResult = system.resolveArtifact( session, artifactRequest );
53
54 artifact = artifactResult.getArtifact();
55
56 System.out.println( artifact + " resolved to " + artifact.getFile() );
57 }
58
59 }