1 package org.apache.maven.resolver.examples.manual;
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.repository.internal.MavenRepositorySystemUtils;
23 import org.eclipse.aether.RepositorySystem;
24 import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
25 import org.eclipse.aether.impl.DefaultServiceLocator;
26 import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
27 import org.eclipse.aether.spi.connector.transport.TransporterFactory;
28 import org.eclipse.aether.transport.file.FileTransporterFactory;
29 import org.eclipse.aether.transport.http.HttpTransporterFactory;
30
31
32
33
34
35 public class ManualRepositorySystemFactory
36 {
37
38 public static RepositorySystem newRepositorySystem()
39 {
40
41
42
43
44
45 DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
46 locator.addService( RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class );
47 locator.addService( TransporterFactory.class, FileTransporterFactory.class );
48 locator.addService( TransporterFactory.class, HttpTransporterFactory.class );
49
50 locator.setErrorHandler( new DefaultServiceLocator.ErrorHandler()
51 {
52 @Override
53 public void serviceCreationFailed( Class<?> type, Class<?> impl, Throwable exception )
54 {
55 exception.printStackTrace();
56 }
57 } );
58
59 return locator.getService( RepositorySystem.class );
60 }
61
62 }