Search in sources :

Example 1 with MavenRepositorySystemSession

use of org.apache.maven.repository.internal.MavenRepositorySystemSession in project storm by apache.

the class Booter method newRepositorySystemSession.

public static RepositorySystemSession newRepositorySystemSession(RepositorySystem system, String localRepoPath) {
    MavenRepositorySystemSession session = new MavenRepositorySystemSession();
    LocalRepository localRepo = new LocalRepository(new File(localRepoPath).getAbsolutePath());
    session.setLocalRepositoryManager(system.newLocalRepositoryManager(localRepo));
    return session;
}
Also used : LocalRepository(org.sonatype.aether.repository.LocalRepository) MavenRepositorySystemSession(org.apache.maven.repository.internal.MavenRepositorySystemSession) File(java.io.File)

Example 2 with MavenRepositorySystemSession

use of org.apache.maven.repository.internal.MavenRepositorySystemSession in project zeppelin by apache.

the class Booter method newRepositorySystemSession.

public static RepositorySystemSession newRepositorySystemSession(RepositorySystem system, String localRepoPath) {
    Validate.notNull(localRepoPath, "localRepoPath should have a value");
    MavenRepositorySystemSession session = new MavenRepositorySystemSession();
    LocalRepository localRepo = new LocalRepository(resolveLocalRepoPath(localRepoPath));
    session.setLocalRepositoryManager(system.newLocalRepositoryManager(localRepo));
    return session;
}
Also used : LocalRepository(org.sonatype.aether.repository.LocalRepository) MavenRepositorySystemSession(org.apache.maven.repository.internal.MavenRepositorySystemSession)

Example 3 with MavenRepositorySystemSession

use of org.apache.maven.repository.internal.MavenRepositorySystemSession in project sonatype-aether by sonatype.

the class Aether method newSession.

private RepositorySystemSession newSession() {
    MavenRepositorySystemSession session = new MavenRepositorySystemSession();
    session.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(localRepository));
    session.setTransferListener(new ConsoleTransferListener());
    session.setRepositoryListener(new ConsoleRepositoryListener());
    return session;
}
Also used : ConsoleRepositoryListener(demo.util.ConsoleRepositoryListener) ConsoleTransferListener(demo.util.ConsoleTransferListener) MavenRepositorySystemSession(org.apache.maven.repository.internal.MavenRepositorySystemSession)

Example 4 with MavenRepositorySystemSession

use of org.apache.maven.repository.internal.MavenRepositorySystemSession in project maven-plugins by apache.

the class JavadocReportTest method testTaglets.

/**
     * Method to test the taglet artifact configuration
     *
     * @throws Exception if any
     */
public void testTaglets() throws Exception {
    // ----------------------------------------------------------------------
    // taglet-test: check if a taglet is used
    // ----------------------------------------------------------------------
    File testPom = new File(unit, "taglet-test/taglet-test-plugin-config.xml");
    JavadocReport mojo = lookupMojo(testPom);
    MavenSession session = spy(newMavenSession(mojo.project));
    ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class);
    when(buildingRequest.getRemoteRepositories()).thenReturn(mojo.project.getRemoteArtifactRepositories());
    when(session.getProjectBuildingRequest()).thenReturn(buildingRequest);
    MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
    repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManager(localRepo));
    when(buildingRequest.getRepositorySession()).thenReturn(repositorySession);
    when(session.getRepositorySession()).thenReturn(repositorySession);
    LegacySupport legacySupport = lookup(LegacySupport.class);
    legacySupport.setSession(session);
    setVariableValueToObject(mojo, "session", session);
    mojo.execute();
    File apidocs = new File(getBasedir(), "target/test/unit/taglet-test/target/site/apidocs");
    assertTrue(new File(apidocs, "index.html").exists());
    File appFile = new File(apidocs, "taglet/test/App.html");
    assertTrue(appFile.exists());
    String appString = readFile(appFile);
    assertTrue(appString.contains("<b>To Do:</b>"));
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) ProjectBuildingRequest(org.apache.maven.project.ProjectBuildingRequest) SimpleLocalRepositoryManager(org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager) LegacySupport(org.apache.maven.plugin.LegacySupport) MavenRepositorySystemSession(org.apache.maven.repository.internal.MavenRepositorySystemSession) File(java.io.File)

Example 5 with MavenRepositorySystemSession

use of org.apache.maven.repository.internal.MavenRepositorySystemSession in project maven-plugins by apache.

the class DeployFileMojoTest method testDeployIfArtifactIsNotJar.

public void testDeployIfArtifactIsNotJar() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/deploy-file-artifact-not-jar/plugin-config.xml");
    mojo = (DeployFileMojo) lookupMojo("deploy-file", testPom);
    MockitoAnnotations.initMocks(this);
    assertNotNull(mojo);
    ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class);
    when(session.getProjectBuildingRequest()).thenReturn(buildingRequest);
    MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
    repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManager(LOCAL_REPO));
    when(buildingRequest.getRepositorySession()).thenReturn(repositorySession);
    String groupId = (String) getVariableValueFromObject(mojo, "groupId");
    String artifactId = (String) getVariableValueFromObject(mojo, "artifactId");
    String version = (String) getVariableValueFromObject(mojo, "version");
    assertEquals("org.apache.maven.test", groupId);
    assertEquals("maven-deploy-file-test", artifactId);
    assertEquals("1.0", version);
    mojo.execute();
    File file = new File(remoteRepo, "deploy-file-artifact-not-jar/" + groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + ".zip");
    assertTrue(file.exists());
}
Also used : ProjectBuildingRequest(org.apache.maven.project.ProjectBuildingRequest) SimpleLocalRepositoryManager(org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager) MavenRepositorySystemSession(org.apache.maven.repository.internal.MavenRepositorySystemSession) File(java.io.File)

Aggregations

MavenRepositorySystemSession (org.apache.maven.repository.internal.MavenRepositorySystemSession)18 File (java.io.File)14 ProjectBuildingRequest (org.apache.maven.project.ProjectBuildingRequest)13 SimpleLocalRepositoryManager (org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager)13 MavenSession (org.apache.maven.execution.MavenSession)7 LegacySupport (org.apache.maven.plugin.LegacySupport)6 ArtifactRepositoryStub (org.apache.maven.plugins.deploy.stubs.ArtifactRepositoryStub)4 MavenProject (org.apache.maven.project.MavenProject)4 ArrayList (java.util.ArrayList)3 LocalRepository (org.sonatype.aether.repository.LocalRepository)3 ConsoleRepositoryListener (demo.util.ConsoleRepositoryListener)1 ConsoleTransferListener (demo.util.ConsoleTransferListener)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 DefaultMavenExecutionRequest (org.apache.maven.execution.DefaultMavenExecutionRequest)1 DefaultMavenExecutionResult (org.apache.maven.execution.DefaultMavenExecutionResult)1 MavenExecutionRequest (org.apache.maven.execution.MavenExecutionRequest)1 MavenExecutionResult (org.apache.maven.execution.MavenExecutionResult)1 Model (org.apache.maven.model.Model)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1