Java Code Examples for org.eclipse.aether.impl.DefaultServiceLocator#addService()
The following examples show how to use
org.eclipse.aether.impl.DefaultServiceLocator#addService() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MavenPluginRepository.java From BIMserver with GNU Affero General Public License v3.0 | 6 votes |
private RepositorySystem newRepositorySystem() { DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() { @Override public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) { exception.printStackTrace(); } }); return locator.getService(RepositorySystem.class); }
Example 2
Source File: Helper.java From packagedrone with Eclipse Public License 1.0 | 6 votes |
public static RepositorySystem newRepositorySystem () { final DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator (); locator.addService ( RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class ); locator.addService ( TransporterFactory.class, FileTransporterFactory.class ); locator.addService ( TransporterFactory.class, HttpTransporterFactory.class ); locator.setErrorHandler ( new ErrorHandler () { @Override public void serviceCreationFailed ( final Class<?> type, final Class<?> impl, final Throwable exception ) { final Logger logger = LoggerFactory.getLogger ( impl ); logger.warn ( "Service creation failed: " + type.getName (), exception ); } } ); return locator.getService ( RepositorySystem.class ); }
Example 3
Source File: AetherUtil.java From buck with Apache License 2.0 | 6 votes |
public static ServiceLocator initServiceLocator() { DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.setErrorHandler( new DefaultServiceLocator.ErrorHandler() { @Override public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) { throw new RuntimeException( String.format( "Failed to initialize service %s, implemented by %s: %s", type.getName(), impl.getName(), exception.getMessage()), exception); } }); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); // Use a no-op logger. Leaving this out would introduce a runtime dependency on log4j locator.addService(ILoggerFactory.class, NOPLoggerFactory.class); // Also requires log4j // locator.addService(ILoggerFactory.class, Log4jLoggerFactory.class); return locator; }
Example 4
Source File: ManualRepositorySystemFactory.java From qpid-broker-j with Apache License 2.0 | 6 votes |
public static RepositorySystem newRepositorySystem() { /* * Aether's components implement org.eclipse.aether.spi.locator.Service to ease manual wiring and using the * prepopulated DefaultServiceLocator, we only need to register the repository connector and transporter * factories. */ DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() { @Override public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) { exception.printStackTrace(); } }); return locator.getService(RepositorySystem.class); }
Example 5
Source File: BootstrapMavenContext.java From quarkus with Apache License 2.0 | 6 votes |
private RepositorySystem newRepositorySystem() throws BootstrapMavenException { final DefaultServiceLocator locator = getServiceLocator(); if (!isOffline()) { locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, WagonTransporterFactory.class); locator.setServices(WagonConfigurator.class, new BootstrapWagonConfigurator()); locator.setServices(WagonProvider.class, new BootstrapWagonProvider()); } locator.setServices(ModelBuilder.class, new MavenModelBuilder(workspace, getCliOptions(), workspace == null ? Collections.emptyList() : getActiveSettingsProfiles())); locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() { @Override public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) { log.error("Failed to initialize " + impl.getName() + " as a service implementing " + type.getName(), exception); } }); return locator.getService(RepositorySystem.class); }
Example 6
Source File: DependencyResolver.java From pinpoint with Apache License 2.0 | 6 votes |
static RepositorySystem newRepositorySystem(boolean supportRemote) { DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); if (supportRemote) { locator.addService(TransporterFactory.class, org.eclipse.aether.transport.http.HttpTransporterFactory.class); } locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() { @Override public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) { exception.printStackTrace(); } }); return locator.getService(RepositorySystem.class); }
Example 7
Source File: RemotePluginRepository.java From BIMserver with GNU Affero General Public License v3.0 | 6 votes |
public static RepositorySystem newRepositorySystem() { /* * Aether's components implement org.eclipse.aether.spi.locator.Service * to ease manual wiring and using the prepopulated * DefaultServiceLocator, we only need to register the repository * connector and transporter factories. */ DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() { @Override public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) { exception.printStackTrace(); } }); return locator.getService(RepositorySystem.class); }
Example 8
Source File: LibertyFeatureVersionIT.java From boost with Eclipse Public License 1.0 | 5 votes |
private RepositorySystem newRepositorySystem() { DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); return locator.getService(RepositorySystem.class); }
Example 9
Source File: Util.java From galleon with Apache License 2.0 | 5 votes |
public static RepositorySystem newRepositorySystem() { DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); return locator.getService(RepositorySystem.class); }
Example 10
Source File: MavenSystemManager.java From archiva with Apache License 2.0 | 5 votes |
public static DefaultServiceLocator newLocator() { DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositoryConnectorFactory.class, ArchivaRepositoryConnectorFactory.class);// FileRepositoryConnectorFactory.class ); locator.addService(VersionResolver.class, DefaultVersionResolver.class); locator.addService(VersionRangeResolver.class, DefaultVersionRangeResolver.class); locator.addService(ArtifactDescriptorReader.class, DefaultArtifactDescriptorReader.class); return locator; }
Example 11
Source File: MavenArtifactResolver.java From javafx-maven-plugin with Apache License 2.0 | 5 votes |
private RepositorySystem createRepositorySystem() { DefaultServiceLocator serviceLocator = MavenRepositorySystemUtils.newServiceLocator(); serviceLocator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); serviceLocator.addService(TransporterFactory.class, FileTransporterFactory.class); serviceLocator.addService(TransporterFactory.class, HttpTransporterFactory.class); serviceLocator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() { @Override public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) { throw new RuntimeException(exception); } }); return serviceLocator.getService(RepositorySystem.class); }
Example 12
Source File: MavenDependencyResolver.java From spring-cloud-formula with Apache License 2.0 | 5 votes |
private RepositorySystem newRepositorySystem() { DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(WagonConfigurator.class, PlexusWagonConfigurator.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); return locator.getService(RepositorySystem.class); }
Example 13
Source File: Aether.java From migration-tooling with Apache License 2.0 | 5 votes |
static RepositorySystem newRepositorySystem() { DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); return locator.getService(RepositorySystem.class); }
Example 14
Source File: ArtifactDownload.java From CogniCrypt with Eclipse Public License 2.0 | 5 votes |
private static RepositorySystem newRepositorySystem() { DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); return locator.getService(RepositorySystem.class); }
Example 15
Source File: ModifiedClassPathRunner.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
private List<URL> resolveCoordinates(String[] coordinates) throws Exception { DefaultServiceLocator serviceLocator = MavenRepositorySystemUtils .newServiceLocator(); serviceLocator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); serviceLocator.addService(TransporterFactory.class, HttpTransporterFactory.class); RepositorySystem repositorySystem = serviceLocator .getService(RepositorySystem.class); DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); LocalRepository localRepository = new LocalRepository( System.getProperty("user.home") + "/.m2/repository"); session.setLocalRepositoryManager( repositorySystem.newLocalRepositoryManager(session, localRepository)); CollectRequest collectRequest = new CollectRequest(null, Arrays.asList(new RemoteRepository.Builder("central", "default", "https://repo.maven.apache.org/maven2").build())); collectRequest.setDependencies(createDependencies(coordinates)); DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null); DependencyResult result = repositorySystem.resolveDependencies(session, dependencyRequest); List<URL> resolvedArtifacts = new ArrayList<>(); for (ArtifactResult artifact : result.getArtifactResults()) { resolvedArtifacts.add(artifact.getArtifact().getFile().toURI().toURL()); } return resolvedArtifacts; }
Example 16
Source File: ResolverImpl.java From vertx-stack with Apache License 2.0 | 5 votes |
private static DefaultServiceLocator getDefaultServiceLocator() { DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() { @Override public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) { LOGGER.error("Service creation failure: " + exception.getMessage(), exception); } }); return locator; }
Example 17
Source File: ArtifactHelperTest.java From LicenseScout with Apache License 2.0 | 5 votes |
private static RepositorySystem newRepositorySystem() { DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); return locator.getService(RepositorySystem.class); }
Example 18
Source File: MavenInitializer.java From thorntail with Apache License 2.0 | 5 votes |
public static RepositorySystem newRepositorySystem() { DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); return locator.getService(RepositorySystem.class); }
Example 19
Source File: PluginPreprocessor.java From gyro with Apache License 2.0 | 4 votes |
@Override public List<Node> preprocess(List<Node> nodes, RootScope scope) { PluginSettings settings = scope.getSettings(PluginSettings.class); List<String> artifactCoords = new ArrayList<>(); List<Node> repositoryNodes = new ArrayList<>(); for (Node node : nodes) { if (node instanceof DirectiveNode) { if ("plugin".equals(((DirectiveNode) node).getName())) { artifactCoords.add(getArtifactCoord((DirectiveNode) node)); } else if ("repository".equals(((DirectiveNode) node).getName())) { repositoryNodes.add(node); } } } if (artifactCoords.stream().allMatch(settings::pluginInitialized)) { return nodes; } NodeEvaluator evaluator = new NodeEvaluator(); evaluator.evaluate(scope, repositoryNodes); for (String ac : artifactCoords) { if (settings.pluginInitialized(ac)) { continue; } try { GyroCore.ui().write("@|magenta ↓ Loading plugin:|@ %s\n", ac); DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); RepositorySystem system = locator.getService(RepositorySystem.class); DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); String localDir = Paths.get(System.getProperty("user.home"), ".m2", "repository").toString(); LocalRepository local = new LocalRepository(localDir); LocalRepositoryManager manager = system.newLocalRepositoryManager(session, local); session.setLocalRepositoryManager(manager); Artifact artifact = new DefaultArtifact(ac); Dependency dependency = new Dependency(artifact, JavaScopes.RUNTIME); DependencyFilter filter = DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME); List<RemoteRepository> repositories = scope.getSettings(RepositorySettings.class).getRepositories(); CollectRequest collectRequest = new CollectRequest(dependency, repositories); DependencyRequest request = new DependencyRequest(collectRequest, filter); DependencyResult result = system.resolveDependencies(session, request); settings.putDependencyResult(ac, result); for (ArtifactResult ar : result.getArtifactResults()) { settings.putArtifactIfNewer(ar.getArtifact()); } } catch (Exception error) { throw new GyroException( String.format("Can't load the @|bold %s|@ plugin!", ac), error); } } settings.addAllUrls(); return nodes; }
Example 20
Source File: GithubImporter.java From scava with Eclipse Public License 2.0 | 4 votes |
private static RepositorySystem newRepositorySystem(DefaultServiceLocator locator) { locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); return locator.getService(RepositorySystem.class); }