1 package org.apache.maven.resolver.examples.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.List;
25
26 import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
27 import org.eclipse.aether.DefaultRepositorySystemSession;
28 import org.eclipse.aether.RepositorySystem;
29 import org.eclipse.aether.RepositorySystemSession;
30 import org.eclipse.aether.repository.LocalRepository;
31 import org.eclipse.aether.repository.RemoteRepository;
32
33
34
35
36 public class Booter
37 {
38
39 public static RepositorySystem newRepositorySystem()
40 {
41 return org.apache.maven.resolver.examples.manual.ManualRepositorySystemFactory.newRepositorySystem();
42
43
44 }
45
46 public static DefaultRepositorySystemSession newRepositorySystemSession( RepositorySystem system )
47 {
48 DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
49
50 LocalRepository localRepo = new LocalRepository( "target/local-repo" );
51 session.setLocalRepositoryManager( system.newLocalRepositoryManager( session, localRepo ) );
52
53 session.setTransferListener( new ConsoleTransferListener() );
54 session.setRepositoryListener( new ConsoleRepositoryListener() );
55
56
57
58
59 return session;
60 }
61
62 public static List<RemoteRepository> newRepositories( RepositorySystem system, RepositorySystemSession session )
63 {
64 return new ArrayList<>( Collections.singletonList( newCentralRepository() ) );
65 }
66
67 private static RemoteRepository newCentralRepository()
68 {
69 return new RemoteRepository.Builder( "central", "default", "https://repo.maven.apache.org/maven2/" ).build();
70 }
71
72 }