Search in sources :

Example 6 with DefaultRepositoryCache

use of org.eclipse.aether.DefaultRepositoryCache in project maven-resolver by apache.

the class HttpTransporterTest method testConnectionReuse.

@Test
public void testConnectionReuse() throws Exception {
    httpServer.addSslConnector();
    session.setCache(new DefaultRepositoryCache());
    for (int i = 0; i < 3; i++) {
        newTransporter(httpServer.getHttpsUrl());
        GetTask task = new GetTask(URI.create("repo/file.txt"));
        transporter.get(task);
        assertEquals("test", task.getDataString());
    }
    PoolStats stats = ((ConnPoolControl<?>) ((HttpTransporter) transporter).getState().getConnectionManager()).getTotalStats();
    assertEquals(stats.toString(), 1, stats.getAvailable());
}
Also used : ConnPoolControl(org.apache.http.pool.ConnPoolControl) GetTask(org.eclipse.aether.spi.connector.transport.GetTask) DefaultRepositoryCache(org.eclipse.aether.DefaultRepositoryCache) PoolStats(org.apache.http.pool.PoolStats) Test(org.junit.Test)

Example 7 with DefaultRepositoryCache

use of org.eclipse.aether.DefaultRepositoryCache in project oracle-bedrock by coherence-community.

the class Maven method perform.

/**
 * Performs the specified {@link RepositorySystemOperation} against the Maven repository
 * using the settings defined by the profile.
 *
 * @throws RepositoryException when an exception occurs interacting with the repository
 */
private void perform(RepositorySystemOperation operation, OptionsByType optionsByType) throws RepositoryException {
    // obtain the PlatformSeparators
    PlatformSeparators separators = optionsByType.get(PlatformSeparators.class);
    // define the global settings location if it's not defined
    if (globalSettingsFile == null) {
        // determine the location of the Maven Home
        String mavenHome = System.getenv("M2_HOME");
        globalSettingsFile = new File(System.getProperty("maven.home", mavenHome != null ? mavenHome : ""), "conf" + separators.getFileSeparator() + "settings.xml");
    }
    // define the user settings location if it's not defined
    if (userSettingsFile == null) {
        userSettingsFile = new File(System.getProperty("user.home") + separators.getFileSeparator() + ".m2" + separators.getFileSeparator() + "settings.xml");
    }
    // define the scope (if it's not defined)
    if (scope == null || scope.isEmpty()) {
        this.scope = JavaScopes.RUNTIME;
    }
    // acquire the Maven Settings for the profile
    Settings settings = getSettings(optionsByType);
    // ----- establish the repository system using the settings -----
    RepositorySystem system = newRepositorySystem();
    // ----- establish the session for the repository system -----
    DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
    session.setOffline(isOffline == null ? false : isOffline);
    session.setCache(new DefaultRepositoryCache());
    // define the local repository
    File localRepositoryLocation = new File(System.getProperty("user.home") + separators.getFileSeparator() + ".m2" + separators.getFileSeparator() + "repository");
    LocalRepository localRepo = new LocalRepository(localRepositoryLocation);
    session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
    // ----- establish the remote repositories to use from the settings -----
    Map<String, org.apache.maven.settings.Profile> profiles = settings.getProfilesAsMap();
    ArrayList<RemoteRepository> remoteRepositories = new ArrayList<>(20);
    for (String profileName : settings.getActiveProfiles()) {
        for (Repository repo : profiles.get(profileName).getRepositories()) {
            RemoteRepository remoteRepository = new RemoteRepository.Builder(repo.getId(), "default", repo.getUrl()).build();
            remoteRepositories.add(remoteRepository);
        }
    }
    // perform the operation
    operation.perform(system, session, remoteRepositories, scope);
}
Also used : PlatformSeparators(com.oracle.bedrock.runtime.options.PlatformSeparators) LocalRepository(org.eclipse.aether.repository.LocalRepository) ArrayList(java.util.ArrayList) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) Profile(com.oracle.bedrock.runtime.Profile) DefaultRepositoryCache(org.eclipse.aether.DefaultRepositoryCache) RepositorySystem(org.eclipse.aether.RepositorySystem) LocalRepository(org.eclipse.aether.repository.LocalRepository) Repository(org.apache.maven.settings.Repository) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) File(java.io.File) Settings(org.apache.maven.settings.Settings)

Example 8 with DefaultRepositoryCache

use of org.eclipse.aether.DefaultRepositoryCache in project SmallMind by zenbones.

the class MavenRepository method generateSession.

public DefaultRepositorySystemSession generateSession() {
    DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
    session.setOffline(offline);
    session.setCache(new DefaultRepositoryCache());
    session.setConfigProperties(configProps);
    if ((profileList != null) && (!profileList.isEmpty())) {
        for (Profile profile : settings.getProfiles()) {
            session.setUserProperties(profile.getProperties());
        }
    }
    session.setProxySelector(proxySelector);
    session.setMirrorSelector(mirrorSelector);
    session.setAuthenticationSelector(authenticationSelector);
    session.setLocalRepositoryManager(getLocalRepoMan(settings, REPOSITORY_SYSTEM, session));
    return session;
}
Also used : DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) Profile(org.apache.maven.settings.Profile) DefaultRepositoryCache(org.eclipse.aether.DefaultRepositoryCache)

Aggregations

DefaultRepositoryCache (org.eclipse.aether.DefaultRepositoryCache)8 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)5 File (java.io.File)2 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 Settings (org.apache.maven.settings.Settings)2 LocalRepository (org.eclipse.aether.repository.LocalRepository)2 GetTask (org.eclipse.aether.spi.connector.transport.GetTask)2 AuthenticationBuilder (org.eclipse.aether.util.repository.AuthenticationBuilder)2 Test (org.junit.Test)2 FilteringZipDependencySelector (com.google.cloud.tools.opensource.dependencies.FilteringZipDependencySelector)1 NonTestDependencySelector (com.google.cloud.tools.opensource.dependencies.NonTestDependencySelector)1 Profile (com.oracle.bedrock.runtime.Profile)1 PlatformSeparators (com.oracle.bedrock.runtime.options.PlatformSeparators)1 BootstrapMavenOptions (io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptions)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ConnPoolControl (org.apache.http.pool.ConnPoolControl)1 PoolStats (org.apache.http.pool.PoolStats)1