Search in sources :

Example 31 with LocalRepository

use of org.eclipse.aether.repository.LocalRepository in project kie-wb-common by kiegroup.

the class MavenDependencyConfigExecutorTest method installArtifactLocally.

private void installArtifactLocally(final String groupId, final String artifactId, final String version) throws Exception {
    Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "pom", version);
    final Path pom = getPom(groupId, artifactId, version);
    pomArtifact = pomArtifact.setFile(pom.toFile());
    final InstallRequest installRequest = new InstallRequest();
    installRequest.addArtifact(pomArtifact);
    final DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    RepositorySystem system = locator.getService(RepositorySystem.class);
    final DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
    final LocalRepository localRepo = new LocalRepository(m2Folder);
    session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
    system.install(session, installRequest);
}
Also used : Path(java.nio.file.Path) RepositorySystem(org.eclipse.aether.RepositorySystem) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) InstallRequest(org.eclipse.aether.installation.InstallRequest) LocalRepository(org.eclipse.aether.repository.LocalRepository) DefaultServiceLocator(org.eclipse.aether.impl.DefaultServiceLocator) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Example 32 with LocalRepository

use of org.eclipse.aether.repository.LocalRepository in project spring-boot by spring-projects.

the class GrapeRootRepositorySystemSessionAutoConfiguration method configureLocalRepository.

private void configureLocalRepository(DefaultRepositorySystemSession session, RepositorySystem repositorySystem, String grapeRoot) {
    File repositoryDir = new File(grapeRoot, "repository");
    LocalRepository localRepository = new LocalRepository(repositoryDir);
    LocalRepositoryManager localRepositoryManager = repositorySystem.newLocalRepositoryManager(session, localRepository);
    session.setLocalRepositoryManager(localRepositoryManager);
}
Also used : LocalRepositoryManager(org.eclipse.aether.repository.LocalRepositoryManager) LocalRepository(org.eclipse.aether.repository.LocalRepository) File(java.io.File)

Example 33 with LocalRepository

use of org.eclipse.aether.repository.LocalRepository in project spring-boot by spring-projects.

the class DefaultRepositorySystemSessionAutoConfiguration method apply.

@Override
public void apply(DefaultRepositorySystemSession session, RepositorySystem repositorySystem) {
    if (session.getLocalRepositoryManager() == null) {
        LocalRepository localRepository = new LocalRepository(getM2RepoDirectory());
        LocalRepositoryManager localRepositoryManager = repositorySystem.newLocalRepositoryManager(session, localRepository);
        session.setLocalRepositoryManager(localRepositoryManager);
    }
    ProxySelector existing = session.getProxySelector();
    if (!(existing instanceof CompositeProxySelector)) {
        JreProxySelector fallback = new JreProxySelector();
        ProxySelector selector = (existing != null) ? new CompositeProxySelector(Arrays.asList(existing, fallback)) : fallback;
        session.setProxySelector(selector);
    }
}
Also used : ProxySelector(org.eclipse.aether.repository.ProxySelector) JreProxySelector(org.eclipse.aether.util.repository.JreProxySelector) LocalRepositoryManager(org.eclipse.aether.repository.LocalRepositoryManager) LocalRepository(org.eclipse.aether.repository.LocalRepository) JreProxySelector(org.eclipse.aether.util.repository.JreProxySelector)

Example 34 with LocalRepository

use of org.eclipse.aether.repository.LocalRepository in project meecrowave by apache.

the class MeecrowaveRunMojoTest method setupMojoExecution.

@Before
public void setupMojoExecution() throws Exception {
    final File moduleBase = jarLocation(MeecrowaveRunMojoTest.class).getParentFile().getParentFile();
    final File basedir = new File(moduleBase, "src/test/resources/" + getClass().getSimpleName());
    final File pom = new File(basedir, "pom.xml");
    final MavenExecutionRequest request = new DefaultMavenExecutionRequest();
    request.setBaseDirectory(basedir);
    final ProjectBuildingRequest configuration = request.getProjectBuildingRequest();
    final DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
    repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory().newInstance(repositorySession, new LocalRepository(new File(moduleBase, "target/fake"), "")));
    configuration.setRepositorySession(repositorySession);
    project = mojo.lookup(ProjectBuilder.class).build(pom, configuration).getProject();
    session = mojo.newMavenSession(project);
    try (final ServerSocket serverSocket = new ServerSocket(0)) {
        port = serverSocket.getLocalPort();
    }
    execution = mojo.newMojoExecution("run");
}
Also used : ProjectBuildingRequest(org.apache.maven.project.ProjectBuildingRequest) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) ProjectBuilder(org.apache.maven.project.ProjectBuilder) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) LocalRepository(org.eclipse.aether.repository.LocalRepository) SimpleLocalRepositoryManagerFactory(org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory) ServerSocket(java.net.ServerSocket) File(java.io.File) Before(org.junit.Before)

Example 35 with LocalRepository

use of org.eclipse.aether.repository.LocalRepository in project BIMserver by opensourceBIM.

the class MavenPluginRepository method newRepositorySystemSession.

private DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system, File localRepoFile, Settings settings) {
    DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
    if (!settings.getMirrors().isEmpty()) {
        DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector();
        for (Mirror mirror : settings.getMirrors()) {
            mirrorSelector.add(mirror.getId(), mirror.getUrl(), "default", true, mirror.getMirrorOf(), "*");
        }
        session.setMirrorSelector(mirrorSelector);
    }
    session.setProxySelector(proxySelector);
    LocalRepository localRepo = new LocalRepository(localRepoFile);
    session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
    return session;
}
Also used : DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) LocalRepository(org.eclipse.aether.repository.LocalRepository) DefaultMirrorSelector(org.eclipse.aether.util.repository.DefaultMirrorSelector) Mirror(org.apache.maven.settings.Mirror)

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