org.eclipse.aether.spi.locator.ServiceLocator Java Examples

The following examples show how to use org.eclipse.aether.spi.locator.ServiceLocator. 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: DependencyResolver.java    From start.spring.io with Apache License 2.0 6 votes vote down vote up
DependencyResolver() {
	try {
		ServiceLocator serviceLocator = createServiceLocator();
		DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
		session.setArtifactDescriptorPolicy(new SimpleArtifactDescriptorPolicy(false, false));
		this.localRepositoryLocation = Files.createTempDirectory("metadata-validation-m2");
		LocalRepository localRepository = new LocalRepository(this.localRepositoryLocation.toFile());
		this.repositorySystem = serviceLocator.getService(RepositorySystem.class);
		session.setLocalRepositoryManager(
				this.repositorySystem.newLocalRepositoryManager(session, localRepository));
		session.setReadOnly();
		this.repositorySystemSession = session;
	}
	catch (Exception ex) {
		throw new RuntimeException(ex);
	}
}
 
Example #2
Source File: Resolver.java    From buck with Apache License 2.0 6 votes vote down vote up
public Resolver(ArtifactConfig config) {
  this.modelBuilder =
      new DefaultModelBuilderFactory()
          .newInstance()
          .setProfileSelector(new DefaultProfileSelector())
          .setPluginConfigurationExpander(new DefaultPluginConfigurationExpander())
          .setPluginManagementInjector(new DefaultPluginManagementInjector())
          .setDependencyManagementImporter(new DefaultDependencyManagementImporter())
          .setDependencyManagementInjector(new DefaultDependencyManagementInjector());
  ServiceLocator locator = AetherUtil.initServiceLocator();
  this.repoSys = locator.getService(RepositorySystem.class);
  this.localRepo = new LocalRepository(Paths.get(config.mavenLocalRepo).toFile());
  this.session = newSession(repoSys, localRepo);

  this.buckRepoRoot = Paths.get(Objects.requireNonNull(config.buckRepoRoot));
  this.buckThirdPartyRelativePath = Paths.get(Objects.requireNonNull(config.thirdParty));
  this.visibility = config.visibility;

  this.repos =
      config.repositories.stream()
          .map(AetherUtil::toRemoteRepository)
          .collect(ImmutableList.toImmutableList());
}
 
Example #3
Source File: AetherUtil.java    From buck with Apache License 2.0 6 votes vote down vote up
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: DependencyResolver.java    From start.spring.io with Apache License 2.0 5 votes vote down vote up
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 #5
Source File: MavenResolverDependencyManagementVersionResolver.java    From initializr with Apache License 2.0 5 votes vote down vote up
MavenResolverDependencyManagementVersionResolver(Path cacheLocation) {
	ServiceLocator serviceLocator = createServiceLocator();
	DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
	session.setArtifactDescriptorPolicy(new SimpleArtifactDescriptorPolicy(false, false));
	LocalRepository localRepository = new LocalRepository(cacheLocation.toFile());
	this.repositorySystem = serviceLocator.getService(RepositorySystem.class);
	session.setLocalRepositoryManager(this.repositorySystem.newLocalRepositoryManager(session, localRepository));
	session.setReadOnly();
	this.repositorySystemSession = session;
}
 
Example #6
Source File: MavenResolverDependencyManagementVersionResolver.java    From initializr with Apache License 2.0 5 votes vote down vote up
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;
}