Search in sources :

Example 1 with SimpleLocalRepositoryManager

use of org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager 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 2 with SimpleLocalRepositoryManager

use of org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager in project maven-dependency-plugin by apache.

the class TestIncludeExcludeUnpackMojo method setUp.

protected void setUp() throws Exception {
    // required for mojo lookups to work
    super.setUp("unpack", true, false);
    File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-test/plugin-config.xml");
    mojo = (UnpackMojo) lookupMojo("unpack", testPom);
    mojo.setOutputDirectory(new File(this.testDir, "outputDirectory"));
    // mojo.silent = true;
    // it needs to get the archivermanager
    // stubFactory.setUnpackableFile( mojo.getArchiverManager() );
    // i'm using one file repeatedly to archive so I can test the name
    // programmatically.
    stubFactory.setSrcFile(new File(getBasedir() + File.separatorChar + PACKED_FILE_PATH));
    Artifact artifact = stubFactory.createArtifact("test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null);
    ArtifactItem item = stubFactory.getArtifactItem(artifact);
    List<ArtifactItem> list = new ArrayList<ArtifactItem>(1);
    list.add(item);
    assertNotNull(mojo);
    assertNotNull(mojo.getProject());
    mojo.setArchiverManager((ArchiverManager) lookup(ArchiverManager.ROLE));
    mojo.setMarkersDirectory(new File(this.testDir, "markers"));
    mojo.setArtifactItems(list);
    MavenSession session = newMavenSession(mojo.getProject());
    setVariableValueToObject(mojo, "session", session);
    DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) session.getRepositorySession();
    repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManager(stubFactory.getWorkingDir()));
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) SimpleLocalRepositoryManager(org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) ArrayList(java.util.ArrayList) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Example 3 with SimpleLocalRepositoryManager

use of org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager in project maven-dependency-plugin by apache.

the class TestGetMojo method setUp.

protected void setUp() throws Exception {
    // required for mojo lookups to work
    super.setUp("markers", false);
    File testPom = new File(getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml");
    assert testPom.exists();
    mojo = (GetMojo) lookupMojo("get", testPom);
    assertNotNull(mojo);
    LegacySupport legacySupport = lookup(LegacySupport.class);
    legacySupport.setSession(newMavenSession(new MavenProjectStub()));
    DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) legacySupport.getRepositorySession();
    repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManager(testDir.getAbsolutePath()));
    setVariableValueToObject(mojo, "session", legacySupport.getSession());
}
Also used : LegacySupport(org.apache.maven.plugin.LegacySupport) SimpleLocalRepositoryManager(org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager) MavenProjectStub(org.apache.maven.plugin.testing.stubs.MavenProjectStub) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) File(java.io.File)

Example 4 with SimpleLocalRepositoryManager

use of org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager in project maven-dependency-plugin by apache.

the class TestCopyMojo method setUp.

protected void setUp() throws Exception {
    super.setUp("copy", false, false);
    File testPom = new File(getBasedir(), "target/test-classes/unit/copy-test/plugin-config.xml");
    mojo = (CopyMojo) lookupMojo("copy", testPom);
    mojo.setOutputDirectory(new File(this.testDir, "outputDirectory"));
    mojo.setSilent(true);
    assertNotNull(mojo);
    assertNotNull(mojo.getProject());
    // MavenProject project = mojo.getProject();
    // init classifier things
    MavenSession session = newMavenSession(mojo.getProject());
    setVariableValueToObject(mojo, "session", session);
    DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) session.getRepositorySession();
    repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManager(stubFactory.getWorkingDir()));
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) SimpleLocalRepositoryManager(org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) File(java.io.File)

Example 5 with SimpleLocalRepositoryManager

use of org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager in project maven-dependency-plugin by apache.

the class TestClassifierTypeTranslator method setUp.

protected void setUp() throws Exception {
    super.setUp("classifiertype-translator", false);
    artifactHandlerManager = new DefaultArtifactHandlerManager();
    this.setVariableValueToObject(artifactHandlerManager, "artifactHandlers", new HashMap());
    artifactFactory = new DefaultArtifactFactory();
    this.setVariableValueToObject(artifactFactory, "artifactHandlerManager", artifactHandlerManager);
    artifactRepository = new StubArtifactRepository(null);
    DependencyArtifactStubFactory factory = new DependencyArtifactStubFactory(null, false);
    artifacts = factory.getMixedArtifacts();
    repoManager = lookup(RepositoryManager.class);
    MavenSession session = newMavenSession(new MavenProjectStub());
    buildingRequest = session.getProjectBuildingRequest();
    DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) session.getRepositorySession();
    repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManager(stubFactory.getWorkingDir()));
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) SimpleLocalRepositoryManager(org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager) DefaultArtifactFactory(org.apache.maven.artifact.factory.DefaultArtifactFactory) MavenProjectStub(org.apache.maven.plugin.testing.stubs.MavenProjectStub) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) HashMap(java.util.HashMap) StubArtifactRepository(org.apache.maven.plugin.testing.stubs.StubArtifactRepository) RepositoryManager(org.apache.maven.shared.repository.RepositoryManager) SimpleLocalRepositoryManager(org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager) DefaultArtifactHandlerManager(org.apache.maven.artifact.handler.manager.DefaultArtifactHandlerManager) DependencyArtifactStubFactory(org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory)

Aggregations

SimpleLocalRepositoryManager (org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager)49 File (java.io.File)44 MavenSession (org.apache.maven.execution.MavenSession)30 MavenRepositorySystemSession (org.apache.maven.repository.internal.MavenRepositorySystemSession)29 ProjectBuildingRequest (org.apache.maven.project.ProjectBuildingRequest)28 DefaultRepositorySystemSession (org.sonatype.aether.util.DefaultRepositorySystemSession)20 LegacySupport (org.apache.maven.plugin.LegacySupport)16 MavenProject (org.apache.maven.project.MavenProject)16 Artifact (org.apache.maven.artifact.Artifact)11 DefaultProjectBuildingRequest (org.apache.maven.project.DefaultProjectBuildingRequest)9 ArchetypeGenerationRequest (org.apache.maven.archetype.ArchetypeGenerationRequest)7 ArrayList (java.util.ArrayList)6 ArchetypeManager (org.apache.maven.archetype.ArchetypeManager)6 ArchetypeCatalog (org.apache.maven.archetype.catalog.ArchetypeCatalog)6 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)6 HashMap (java.util.HashMap)5 Properties (java.util.Properties)5 ArchetypeGenerationResult (org.apache.maven.archetype.ArchetypeGenerationResult)5 Archetype (org.apache.maven.archetype.catalog.Archetype)5 MavenArtifactRepository (org.apache.maven.artifact.repository.MavenArtifactRepository)5