Java Code Examples for org.apache.maven.repository.internal.MavenRepositorySystemUtils#newServiceLocator()
The following examples show how to use
org.apache.maven.repository.internal.MavenRepositorySystemUtils#newServiceLocator() .
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: AetherUtil.java From vertx-deploy-tools 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) { LOG.error(exception.getMessage(), exception); } }); 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: 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 4
Source File: MavenUtil.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 DefaultServiceLocator.ErrorHandler () { @Override public void serviceCreationFailed ( final Class<?> type, final Class<?> impl, final Throwable exception ) { exception.printStackTrace (); } } ); return locator.getService ( RepositorySystem.class ); }
Example 5
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 6
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 7
Source File: AetherUtils.java From Orienteer with Apache License 2.0 | 6 votes |
private RepositorySystem getRepositorySystem() { 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) { LOG.error("ServiceLocator failed", exception); } }); return locator.getService(RepositorySystem.class); }
Example 8
Source File: Aether.java From pro with GNU General Public License v3.0 | 5 votes |
public static Aether create(Path mavenLocalRepository, List<URI> remoteRepositories) { // respository system var 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(); } }); RepositorySystem system = locator.getService(RepositorySystem.class); // session var session = MavenRepositorySystemUtils.newSession(); var localRepository = new LocalRepository(mavenLocalRepository.toString()); session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepository)); // central repository var central = new RemoteRepository.Builder("central", "default", "https://repo1.maven.org/maven2/").build(); // remote repositories var remotes = Stream.concat( remoteRepositories.stream().map(uri -> new RemoteRepository.Builder(null, "default", uri.toString()).build()), Stream.of(central) ) .collect(Collectors.toUnmodifiableList()); return new Aether(system, session, remotes); }
Example 9
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 10
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 11
Source File: Cadfael.java From Poseidon with Apache License 2.0 | 5 votes |
private Cadfael(List<RemoteRepository> repositories, Set<NonVersionedArtifact> allowedArtifacts, Set<Scope> ignoredScopes, boolean rejectSnapshots) { this.repositories = repositories; this.allowedArtifacts = allowedArtifacts; this.ignoredScopes = ignoredScopes; this.rejectSnapshots = rejectSnapshots; final DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); this.system = newRepositorySystem(locator); this.session = newSession(system); }
Example 12
Source File: MavenResolverDependencyManagementVersionResolver.java From initializr with Apache License 2.0 | 5 votes |
private static ServiceLocator createServiceLocator() { DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositorySystem.class, DefaultRepositorySystem.class); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); return locator; }
Example 13
Source File: MavenContainer.java From furnace with Eclipse Public License 1.0 | 5 votes |
public RepositorySystem getRepositorySystem() { final DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.setServices(ModelBuilder.class, new DefaultModelBuilderFactory().newInstance()); // Installing Wagon to fetch from HTTP repositories locator.setServices(WagonProvider.class, new ManualWagonProvider()); locator.addService(TransporterFactory.class, WagonTransporterFactory.class); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); final RepositorySystem repositorySystem = locator.getService(RepositorySystem.class); return repositorySystem; }
Example 14
Source File: Maven.java From bazel-deps with MIT License | 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); locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() { @Override public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) { exception.printStackTrace(); } }); return locator.getService(RepositorySystem.class); }
Example 15
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 16
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 17
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 18
Source File: DependencyResolver.java From start.spring.io with Apache License 2.0 | 5 votes |
private static ServiceLocator createServiceLocator() { DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositorySystem.class, DefaultRepositorySystem.class); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, DependencyResolver.JarSkippingHttpTransporterFactory.class); return locator; }
Example 19
Source File: BootstrapMavenContext.java From quarkus with Apache License 2.0 | 4 votes |
private DefaultServiceLocator getServiceLocator() { return serviceLocator == null ? serviceLocator = MavenRepositorySystemUtils.newServiceLocator() : serviceLocator; }
Example 20
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; }