use of org.eclipse.aether.repository.LocalRepository in project bazel by bazelbuild.
the class MavenConnector method newRepositorySystemSession.
public RepositorySystemSession newRepositorySystemSession(RepositorySystem system) {
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
LocalRepository localRepo = new LocalRepository(localRepositoryPath);
session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
session.setTransferListener(new AbstractTransferListener() {
});
session.setRepositoryListener(new AbstractRepositoryListener() {
});
return session;
}
use of org.eclipse.aether.repository.LocalRepository in project spring-boot by spring-projects.
the class ModifiedClassPathRunner method resolveCoordinates.
private List<URL> resolveCoordinates(String[] coordinates) throws Exception {
DefaultServiceLocator serviceLocator = MavenRepositorySystemUtils.newServiceLocator();
serviceLocator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
serviceLocator.addService(TransporterFactory.class, HttpTransporterFactory.class);
RepositorySystem repositorySystem = serviceLocator.getService(RepositorySystem.class);
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
LocalRepository localRepository = new LocalRepository(System.getProperty("user.home") + "/.m2/repository");
session.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(session, localRepository));
CollectRequest collectRequest = new CollectRequest(null, Arrays.asList(new RemoteRepository.Builder("central", "default", "http://central.maven.org/maven2").build()));
collectRequest.setDependencies(createDependencies(coordinates));
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null);
DependencyResult result = repositorySystem.resolveDependencies(session, dependencyRequest);
List<URL> resolvedArtifacts = new ArrayList<URL>();
for (ArtifactResult artifact : result.getArtifactResults()) {
resolvedArtifacts.add(artifact.getArtifact().getFile().toURI().toURL());
}
return resolvedArtifacts;
}
use of org.eclipse.aether.repository.LocalRepository in project BIMserver by opensourceBIM.
the class MavenPluginRepository method newRepositorySystemSession.
private DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system, Path localRepoFile) {
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
LocalRepository localRepo = new LocalRepository(localRepoFile.toFile());
LocalRepositoryManager manager = system.newLocalRepositoryManager(session, localRepo);
session.setLocalRepositoryManager(manager);
return session;
}
use of org.eclipse.aether.repository.LocalRepository in project fabric8 by jboss-fuse.
the class AetherBasedResolver method createSession.
public DefaultRepositorySystemSession createSession(LocalRepository repo) {
DefaultRepositorySystemSession session = newRepositorySystemSession();
if (repo != null) {
session.setLocalRepositoryManager(m_repoSystem.newLocalRepositoryManager(session, repo));
} else {
File local;
if (m_config.getLocalRepository() != null) {
local = m_config.getLocalRepository().getFile();
} else {
local = new File(System.getProperty("user.home"), ".m2/repository");
}
LocalRepository localRepo = new LocalRepository(local);
session.setLocalRepositoryManager(m_repoSystem.newLocalRepositoryManager(session, localRepo));
}
session.setMirrorSelector(m_mirrorSelector);
session.setProxySelector(m_proxySelector);
String updatePolicy = m_config.getGlobalUpdatePolicy();
if (null != updatePolicy) {
session.setUpdatePolicy(updatePolicy);
}
String checksumPolicy = m_config.getGlobalChecksumPolicy();
if (null != checksumPolicy) {
session.setChecksumPolicy(checksumPolicy);
}
for (Server server : m_settings.getServers()) {
if (server.getConfiguration() != null && ((Xpp3Dom) server.getConfiguration()).getChild("httpHeaders") != null) {
addServerConfig(session, server);
}
}
// org.eclipse.aether.transport.wagon.WagonTransporter.connectWagon() sets connection timeout
// as max of connection timeout and request timeout taken from aether session config
// but on the other hand, request timeout is used in org.eclipse.aether.connector.basic.PartialFile.Factory
//
// because real socket read timeout is used again (correctly) in
// org.ops4j.pax.url.mvn.internal.wagon.ConfigurableHttpWagon.execute() - directly from wagon configuration
// (from org.apache.maven.wagon.AbstractWagon.getReadTimeout()), we explicitly configure aether session
// config with: PartialFile.Factory timeout == connection timeout
int defaultTimeut = m_config.getTimeout();
Integer timeout = m_config.getProperty(ServiceConstants.PROPERTY_SOCKET_CONNECTION_TIMEOUT, defaultTimeut, Integer.class);
session.setConfigProperty(ConfigurationProperties.CONNECT_TIMEOUT, timeout);
session.setConfigProperty(ConfigurationProperties.REQUEST_TIMEOUT, timeout);
session.setConfigProperty("aether.updateCheckManager.sessionState", "no");
session.setOffline(m_config.isOffline());
// - this is required for correct SNAPSHOT handling
if (repo != null) {
RemoteRepository remoteRepository = defaultRepositories.get(repo.getBasedir());
session.getData().set(SmartMetadataResolver.DEFAULT_REPOSITORY, null, remoteRepository);
}
boolean updateReleases = m_config.getProperty(ServiceConstants.PROPERTY_UPDATE_RELEASES, false, Boolean.class);
session.setConfigProperty(SmartLocalRepositoryManagerFactory.PROPERTY_UPDATE_RELEASES, updateReleases);
return session;
}
use of org.eclipse.aether.repository.LocalRepository in project fabric8 by jboss-fuse.
the class AetherBasedResolver method selectDefaultRepositories.
List<LocalRepository> selectDefaultRepositories() {
List<LocalRepository> list = new ArrayList<LocalRepository>();
List<MavenRepositoryURL> urls = Collections.emptyList();
try {
urls = m_config.getDefaultRepositories();
} catch (MalformedURLException exc) {
LOG.error("invalid repository URLs", exc);
}
for (MavenRepositoryURL r : urls) {
if (r.isMulti()) {
addLocalSubDirs(list, r.getFile());
} else {
addLocalRepo(list, r);
}
}
return list;
}
Aggregations