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 java.util.List;
23
24 import org.apache.maven.resolver.examples.util.Booter;
25 import org.eclipse.aether.RepositorySystem;
26 import org.eclipse.aether.RepositorySystemSession;
27 import org.eclipse.aether.artifact.Artifact;
28 import org.eclipse.aether.artifact.DefaultArtifact;
29 import org.eclipse.aether.resolution.VersionRangeRequest;
30 import org.eclipse.aether.resolution.VersionRangeResult;
31 import org.eclipse.aether.version.Version;
32
33
34
35
36 public class FindAvailableVersions
37 {
38
39
40
41
42
43
44 public static void main( String[] args )
45 throws Exception
46 {
47 System.out.println( "------------------------------------------------------------" );
48 System.out.println( FindAvailableVersions.class.getSimpleName() );
49
50 RepositorySystem system = Booter.newRepositorySystem();
51
52 RepositorySystemSession session = Booter.newRepositorySystemSession( system );
53
54 Artifact artifact = new DefaultArtifact( "org.apache.maven.resolver:maven-resolver-util:[0,)" );
55
56 VersionRangeRequest rangeRequest = new VersionRangeRequest();
57 rangeRequest.setArtifact( artifact );
58 rangeRequest.setRepositories( Booter.newRepositories( system, session ) );
59
60 VersionRangeResult rangeResult = system.resolveVersionRange( session, rangeRequest );
61
62 List<Version> versions = rangeResult.getVersions();
63
64 System.out.println( "Available versions " + versions );
65 }
66
67 }