Search in sources :

Example 1 with LocalRepository

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;
}
Also used : AbstractRepositoryListener(org.eclipse.aether.AbstractRepositoryListener) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) AbstractTransferListener(org.eclipse.aether.transfer.AbstractTransferListener) LocalRepository(org.eclipse.aether.repository.LocalRepository)

Example 2 with LocalRepository

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;
}
Also used : DependencyResult(org.eclipse.aether.resolution.DependencyResult) LocalRepository(org.eclipse.aether.repository.LocalRepository) ArrayList(java.util.ArrayList) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) DefaultServiceLocator(org.eclipse.aether.impl.DefaultServiceLocator) CollectRequest(org.eclipse.aether.collection.CollectRequest) URL(java.net.URL) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult) RepositorySystem(org.eclipse.aether.RepositorySystem) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) DependencyRequest(org.eclipse.aether.resolution.DependencyRequest)

Example 3 with LocalRepository

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;
}
Also used : DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) LocalRepositoryManager(org.eclipse.aether.repository.LocalRepositoryManager) LocalRepository(org.eclipse.aether.repository.LocalRepository)

Example 4 with LocalRepository

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;
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) Server(org.apache.maven.settings.Server) LocalRepository(org.eclipse.aether.repository.LocalRepository) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) File(java.io.File) JarFile(java.util.jar.JarFile) VersionConstraint(org.eclipse.aether.version.VersionConstraint)

Example 5 with LocalRepository

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;
}
Also used : MalformedURLException(java.net.MalformedURLException) LocalRepository(org.eclipse.aether.repository.LocalRepository) ArrayList(java.util.ArrayList) MavenRepositoryURL(io.fabric8.maven.util.MavenRepositoryURL)

Aggregations

LocalRepository (org.eclipse.aether.repository.LocalRepository)42 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)34 File (java.io.File)15 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)8 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 RepositorySystem (org.eclipse.aether.RepositorySystem)6 JarFile (java.util.jar.JarFile)5 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)5 SimpleLocalRepositoryManagerFactory (org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory)5 LocalRepositoryManager (org.eclipse.aether.repository.LocalRepositoryManager)5 MalformedURLException (java.net.MalformedURLException)4 LinkedList (java.util.LinkedList)4 Artifact (org.eclipse.aether.artifact.Artifact)4 DefaultServiceLocator (org.eclipse.aether.impl.DefaultServiceLocator)4 URL (java.net.URL)3 DefaultMavenExecutionRequest (org.apache.maven.execution.DefaultMavenExecutionRequest)3 MavenExecutionRequest (org.apache.maven.execution.MavenExecutionRequest)3 ArtifactResult (org.eclipse.aether.resolution.ArtifactResult)3 VersionConstraint (org.eclipse.aether.version.VersionConstraint)3