org.apache.maven.repository.internal.MavenRepositorySystemUtils Java Examples

The following examples show how to use org.apache.maven.repository.internal.MavenRepositorySystemUtils. 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 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 #2
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 #3
Source File: DependencyResolver.java    From spring-init with Apache License 2.0 6 votes vote down vote up
private DefaultRepositorySystemSession createSession(Properties properties)
		throws NoLocalRepositoryManagerException {
	DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
	LocalRepository repository = localRepository(properties);
	session.setLocalRepositoryManager(
			localRepositoryManagerFactory.newInstance(session, repository));
	applySettings(session);
	ProxySelector existing = session.getProxySelector();
	if (existing == null || !(existing instanceof CompositeProxySelector)) {
		JreProxySelector fallback = new JreProxySelector();
		ProxySelector selector = existing == null ? fallback
				: new CompositeProxySelector(Arrays.asList(existing, fallback));
		session.setProxySelector(selector);
	}
	return session;
}
 
Example #4
Source File: GithubImporter.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
private List<String> getMavenParentDependencies(String parent)
		throws DependencyResolutionException, ArtifactDescriptorException {
	List<String> dependencies = new ArrayList<>();
	DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
	RepositorySystem system = newRepositorySystem(locator);
	RepositorySystemSession session = newSession(system);

	RemoteRepository central = new RemoteRepository.Builder("central", "default", "http://repo1.maven.org/maven2/")
			.build();

	org.eclipse.aether.artifact.Artifact artifact = new DefaultArtifact(parent);
	ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(artifact, Arrays.asList(central), null);
	try {
		ArtifactDescriptorResult result = system.readArtifactDescriptor(session, request);
		for (org.eclipse.aether.graph.Dependency dependency : result.getManagedDependencies()) {
			dependencies.add(dependency.getArtifact().getGroupId() + ":" + dependency.getArtifact().getGroupId());
		}
	} catch (Exception e) {
		logger.error(e.getMessage());
	}
	return dependencies;

}
 
Example #5
Source File: ManualRepositorySystemFactory.java    From qpid-broker-j with Apache License 2.0 6 votes vote down vote up
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: MavenArtifactResolver.java    From spring-cloud-deployer with Apache License 2.0 6 votes vote down vote up
private RepositorySystem newRepositorySystem() {
	DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
	locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
	locator.addService(TransporterFactory.class, FileTransporterFactory.class);

	if (properties.isUseWagon()) {
		locator.addService(WagonProvider.class, StaticWagonProvider.class);
		locator.addService(WagonConfigurator.class, StaticWagonConfigurator.class);
		locator.addService(TransporterFactory.class, WagonTransporterFactory.class);
	} else {
		locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
	}

	locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
		@Override
		public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
			throw new RuntimeException(exception);
		}
	});
	return locator.getService(RepositorySystem.class);
}
 
Example #7
Source File: JavaFXRunMojoTestCase.java    From javafx-maven-plugin with Apache License 2.0 6 votes vote down vote up
private void setUpProject(File pomFile, AbstractMojo mojo) throws Exception {
    super.setUp();

    MockitoAnnotations.initMocks(this);

    ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class);
    buildingRequest.setResolveDependencies(true);
    when(session.getProjectBuildingRequest()).thenReturn(buildingRequest);
    DefaultRepositorySystemSession repositorySession = MavenRepositorySystemUtils.newSession();
    repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory()
            .newInstance(repositorySession, new LocalRepository(RepositorySystem.defaultUserLocalRepository)));
    when(buildingRequest.getRepositorySession()).thenReturn(repositorySession);

    ProjectBuilder builder = lookup(ProjectBuilder.class);
    ProjectBuildingResult build = builder.build(pomFile, buildingRequest);
    MavenProject project = build.getProject();

    project.getBuild().setOutputDirectory(new File( "target/test-classes").getAbsolutePath());
    setVariableValueToObject(mojo, "project", project);
}
 
Example #8
Source File: Helper.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
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 #9
Source File: MavenUtil.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
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 #10
Source File: RemotePluginLoader.java    From digdag with Apache License 2.0 6 votes vote down vote up
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 #11
Source File: AetherUtils.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
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 #12
Source File: MavenSystemManager.java    From archiva with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new aether repository system session for the given directory and assigns the
 * repository to this session.
 *
 * @param localRepoDir The repository directory
 * @return The newly created session object.
 */
public static RepositorySystemSession newRepositorySystemSession(String localRepoDir) {
    DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();

    LocalRepository repo = new LocalRepository(localRepoDir);

    DependencySelector depFilter = new AndDependencySelector(new ExclusionDependencySelector());
    session.setDependencySelector(depFilter);
    SimpleLocalRepositoryManagerFactory repFactory = new SimpleLocalRepositoryManagerFactory();
    try {
        LocalRepositoryManager manager = repFactory.newInstance(session, repo);
        session.setLocalRepositoryManager(manager);
    } catch (NoLocalRepositoryManagerException e) {
        log.error("Could not assign the repository manager to the session: {}", e.getMessage(), e);
    }

    return session;
}
 
Example #13
Source File: RemotePluginRepository.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
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 #14
Source File: MavenPluginRepository.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
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 #15
Source File: MavenPluginRepository.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
private DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system, File localRepoFile, Settings settings) {
	DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
	if (!settings.getMirrors().isEmpty()) {
		DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector();
		for (Mirror mirror : settings.getMirrors()) {
			mirrorSelector.add(mirror.getId(), mirror.getUrl(), "default", true, mirror.getMirrorOf(), "*");
		}
		session.setMirrorSelector(mirrorSelector);
	}
	session.setProxySelector(proxySelector);

	LocalRepository localRepo = new LocalRepository(localRepoFile);
	session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));

	return session;
}
 
Example #16
Source File: AetherUtil.java    From vertx-deploy-tools with Apache License 2.0 6 votes vote down vote up
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 #17
Source File: InstallDeployTest.java    From takari-lifecycle with Eclipse Public License 1.0 6 votes vote down vote up
private MavenSession newSession(MavenProject project, File localrepo, Properties properties) throws Exception {
  MavenExecutionRequest request = new DefaultMavenExecutionRequest();
  MavenExecutionResult result = new DefaultMavenExecutionResult();
  DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession();
  LocalRepository localRepo = new LocalRepository(localrepo);
  repoSession.setLocalRepositoryManager(mojos.getContainer().lookup(LocalRepositoryManagerFactory.class, "simple").newInstance(repoSession, localRepo));
  MavenSession session = new MavenSession(mojos.getContainer(), repoSession, request, result);
  List<MavenProject> projects = new ArrayList<>();
  projects.add(project);
  for (String module : project.getModules()) {
    MavenProject moduleProject = readMavenProject(new File(project.getBasedir(), module), properties);
    moduleProject.setParent(project);
    projects.add(moduleProject);
  }

  session.setProjects(projects);
  return session;
}
 
Example #18
Source File: Publisher.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * @param toPublish each {@link Artifact} must contain a file, that will be published under maven
 *     coordinates in the corresponding {@link Artifact}.
 * @see Artifact#setFile
 */
public DeployResult publish(List<Artifact> toPublish) throws DeploymentException {
  RepositorySystem repoSys = Objects.requireNonNull(locator.getService(RepositorySystem.class));

  DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
  session.setLocalRepositoryManager(repoSys.newLocalRepositoryManager(session, localRepo));
  session.setReadOnly();

  DeployRequest deployRequest = createDeployRequest(toPublish);

  if (dryRun) {
    return new DeployResult(deployRequest)
        .setArtifacts(toPublish)
        .setMetadata(deployRequest.getMetadata());
  } else {
    return repoSys.deploy(session, deployRequest);
  }
}
 
Example #19
Source File: DependencyResolver.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
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 #20
Source File: DependencyResolver.java    From spring-cloud-function with Apache License 2.0 6 votes vote down vote up
private DefaultRepositorySystemSession createSession(Properties properties)
		throws NoLocalRepositoryManagerException {
	DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
	LocalRepository repository = localRepository(properties);
	session.setLocalRepositoryManager(
			this.localRepositoryManagerFactory.newInstance(session, repository));
	applySettings(session);
	ProxySelector existing = session.getProxySelector();
	if (existing == null || !(existing instanceof CompositeProxySelector)) {
		JreProxySelector fallback = new JreProxySelector();
		ProxySelector selector = existing == null ? fallback
				: new CompositeProxySelector(Arrays.asList(existing, fallback));
		session.setProxySelector(selector);
	}
	return session;
}
 
Example #21
Source File: MavenSystemManager.java    From archiva with Apache License 2.0 5 votes vote down vote up
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 #22
Source File: Maven.java    From bazel-deps with MIT License 5 votes vote down vote up
public static DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system) {
  DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();

  LocalRepository localRepo = new LocalRepository("target/local-repo");
  session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));

  return session;
}
 
Example #23
Source File: Maven.java    From bazel-deps with MIT License 5 votes vote down vote up
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 #24
Source File: PluginAddCommand.java    From gyro with Apache License 2.0 5 votes vote down vote up
private boolean validate(String plugin) {
    try {
        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(plugin);
        Dependency dependency = new Dependency(artifact, JavaScopes.RUNTIME);
        DependencyFilter filter = DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME);
        CollectRequest collectRequest = new CollectRequest(dependency, repositories);
        DependencyRequest request = new DependencyRequest(collectRequest, filter);
        system.resolveDependencies(session, request);

        return true;
    } catch (DependencyResolutionException e) {
        GyroCore.ui().write("@|bold %s|@ was not installed for the following reason(s):\n", plugin);

        for (Exception ex : e.getResult().getCollectExceptions()) {
            GyroCore.ui().write("   @|red %s|@\n", ex.getMessage());
        }

        GyroCore.ui().write("\n");

        return false;
    }
}
 
Example #25
Source File: MavenUtilTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testRepositorySystemDirect() {
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.setErrorHandler(new MavenUtil.MyErrorHandler());

    RepositorySystem repoSys = locator.getService(RepositorySystem.class);
    Assert.assertNotNull(repoSys);
}
 
Example #26
Source File: DependencyResolver.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
static DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system) {
    DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
    session.setCache(newRepositoryCache());
    String localRepositoryPath = resolveLocalRepository();
    if (logger.isLoggable(Level.INFO)) {
        logger.info("Local repository: " + localRepositoryPath);
    }
    LocalRepository localRepository = new LocalRepository(localRepositoryPath);

    LocalRepositoryManager localRepositoryManager = system.newLocalRepositoryManager(session, localRepository);
    session.setLocalRepositoryManager(localRepositoryManager);

    return session;
}
 
Example #27
Source File: MavenDependencyResolver.java    From spring-cloud-formula with Apache License 2.0 5 votes vote down vote up
private RepositorySystemSession newSession(RepositorySystem system) {
    DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();

    String home = System.getenv("HOME");
    LocalRepository localRepo = new LocalRepository(new File(home, ".m2/repository"));
    session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));

    return session;
}
 
Example #28
Source File: AetherUtils.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private RepositorySystemSession getRepositorySystemSession(RepositorySystem system, String  localRepositoryPath) {
    DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();

    LocalRepository localRepo = new LocalRepository(localRepositoryPath);
    session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));

    return session;
}
 
Example #29
Source File: MavenDependencyResolver.java    From spring-cloud-formula with Apache License 2.0 5 votes vote down vote up
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 #30
Source File: ArtifactResolverTest.java    From revapi with Apache License 2.0 5 votes vote down vote up
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);

    locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
        @Override
        public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
            exception.printStackTrace();
        }
    });

    return locator.getService(RepositorySystem.class);
}