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());
}
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);
}
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;
}
Aggregations