org.eclipse.aether.repository.NoLocalRepositoryManagerException Java Examples

The following examples show how to use org.eclipse.aether.repository.NoLocalRepositoryManagerException. 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: MavenSettingsReader.java    From spring-init with Apache License 2.0 6 votes vote down vote up
public static void applySettings(MavenSettings settings,
		DefaultRepositorySystemSession session) {
	if (settings.getLocalRepository() != null) {
		try {
			session.setLocalRepositoryManager(
					new SimpleLocalRepositoryManagerFactory().newInstance(session,
							new LocalRepository(settings.getLocalRepository())));
		}
		catch (NoLocalRepositoryManagerException e) {
			throw new IllegalStateException(
					"Cannot set local repository to " + settings.getLocalRepository(),
					e);
		}
	}
	session.setOffline(settings.getOffline());
	session.setMirrorSelector(settings.getMirrorSelector());
	session.setAuthenticationSelector(settings.getAuthenticationSelector());
	session.setProxySelector(settings.getProxySelector());
}
 
Example #2
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 #3
Source File: MavenSettingsReader.java    From spring-cloud-function with Apache License 2.0 6 votes vote down vote up
public static void applySettings(MavenSettings settings,
		DefaultRepositorySystemSession session) {
	if (settings.getLocalRepository() != null) {
		try {
			session.setLocalRepositoryManager(
					new SimpleLocalRepositoryManagerFactory().newInstance(session,
							new LocalRepository(settings.getLocalRepository())));
		}
		catch (NoLocalRepositoryManagerException e) {
			throw new IllegalStateException(
					"Cannot set local repository to " + settings.getLocalRepository(),
					e);
		}
	}
	session.setOffline(settings.getOffline());
	session.setMirrorSelector(settings.getMirrorSelector());
	session.setAuthenticationSelector(settings.getAuthenticationSelector());
	session.setProxySelector(settings.getProxySelector());
}
 
Example #4
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 #5
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 #6
Source File: DependencyResolver.java    From spring-init with Apache License 2.0 5 votes vote down vote up
private ProjectBuildingRequest getProjectBuildingRequest(Properties properties)
		throws NoLocalRepositoryManagerException {
	DefaultProjectBuildingRequest projectBuildingRequest = new DefaultProjectBuildingRequest();
	DefaultRepositorySystemSession session = createSession(properties);
	projectBuildingRequest.setRepositoryMerging(RepositoryMerging.REQUEST_DOMINANT);
	projectBuildingRequest.setRemoteRepositories(mavenRepositories(properties));
	projectBuildingRequest.getRemoteRepositories()
			.addAll(mavenRepositories(settings));
	projectBuildingRequest.setRepositorySession(session);
	projectBuildingRequest.setProcessPlugins(false);
	projectBuildingRequest.setBuildStartTime(new Date());
	projectBuildingRequest.setUserProperties(properties);
	projectBuildingRequest.setSystemProperties(System.getProperties());
	return projectBuildingRequest;
}
 
Example #7
Source File: DependencyResolver.java    From spring-cloud-function with Apache License 2.0 5 votes vote down vote up
private ProjectBuildingRequest getProjectBuildingRequest(Properties properties)
		throws NoLocalRepositoryManagerException {
	DefaultProjectBuildingRequest projectBuildingRequest = new DefaultProjectBuildingRequest();
	DefaultRepositorySystemSession session = createSession(properties);
	projectBuildingRequest.setRepositoryMerging(RepositoryMerging.REQUEST_DOMINANT);
	projectBuildingRequest.setRemoteRepositories(mavenRepositories(properties));
	projectBuildingRequest.getRemoteRepositories()
			.addAll(mavenRepositories(this.settings));
	projectBuildingRequest.setRepositorySession(session);
	projectBuildingRequest.setProcessPlugins(false);
	projectBuildingRequest.setBuildStartTime(new Date());
	projectBuildingRequest.setUserProperties(properties);
	projectBuildingRequest.setSystemProperties(System.getProperties());
	return projectBuildingRequest;
}