Search in sources :

Example 31 with SimpleLocalRepositoryManager

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

the class TestCopyDependenciesMojo2 method setUp.

protected void setUp() throws Exception {
    // required for mojo lookups to work
    super.setUp("copy-dependencies", true);
    File testPom = new File(getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml");
    mojo = (CopyDependenciesMojo) lookupMojo("copy-dependencies", testPom);
    mojo.outputDirectory = new File(this.testDir, "outputDirectory");
    // mojo.silent = true;
    assertNotNull(mojo);
    assertNotNull(mojo.getProject());
    MavenProject project = mojo.getProject();
    Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts();
    Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
    artifacts.addAll(directArtifacts);
    project.setArtifacts(artifacts);
    project.setDependencyArtifacts(directArtifacts);
    mojo.markersDirectory = new File(this.testDir, "markers");
    LegacySupport legacySupport = lookup(LegacySupport.class);
    MavenSession session = newMavenSession(project);
    setVariableValueToObject(mojo, "session", session);
    legacySupport.setSession(session);
    DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) legacySupport.getRepositorySession();
    repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManager(testDir.getAbsolutePath()));
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) LegacySupport(org.apache.maven.plugin.LegacySupport) SimpleLocalRepositoryManager(org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager) MavenProject(org.apache.maven.project.MavenProject) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Example 32 with SimpleLocalRepositoryManager

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

the class TestUnpackDependenciesMojo method setUp.

protected void setUp() throws Exception {
    // required for mojo lookups to work
    super.setUp("unpack-dependencies", true, false);
    File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-dependencies-test/plugin-config.xml");
    mojo = (UnpackDependenciesMojo) lookupMojo("unpack-dependencies", testPom);
    mojo.outputDirectory = new File(this.testDir, "outputDirectory");
    mojo.setUseJvmChmod(true);
    // 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 + UNPACKABLE_FILE_PATH));
    assertNotNull(mojo);
    assertNotNull(mojo.getProject());
    MavenProject project = mojo.getProject();
    MavenSession session = newMavenSession(project);
    setVariableValueToObject(mojo, "session", session);
    DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) session.getRepositorySession();
    repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManager(stubFactory.getWorkingDir()));
    Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts();
    Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
    artifacts.addAll(directArtifacts);
    project.setArtifacts(artifacts);
    project.setDependencyArtifacts(directArtifacts);
    mojo.markersDirectory = new File(this.testDir, "markers");
    ArtifactHandlerManager manager = lookup(ArtifactHandlerManager.class);
    setVariableValueToObject(mojo, "artifactHandlerManager", manager);
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) SimpleLocalRepositoryManager(org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager) MavenProject(org.apache.maven.project.MavenProject) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) ArtifactHandlerManager(org.apache.maven.artifact.handler.manager.ArtifactHandlerManager) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Example 33 with SimpleLocalRepositoryManager

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

the class TestUnpackMojo method setUp.

protected void setUp() throws Exception {
    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.setMarkersDirectory(new File(this.testDir, "markers"));
    mojo.setSilent(true);
    assertNotNull(mojo);
    assertNotNull(mojo.getProject());
    // MavenProject project = mojo.getProject();
    // init classifier things
    // 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 + "target/test-classes/unit/unpack-dependencies-test/test.txt"));
    mojo.setUseJvmChmod(true);
    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 34 with SimpleLocalRepositoryManager

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

the class TestCopyDependenciesMojo method setUp.

protected void setUp() throws Exception {
    // required for mojo lookups to work
    super.setUp("copy-dependencies", true, false);
    File testPom = new File(getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml");
    mojo = (CopyDependenciesMojo) lookupMojo("copy-dependencies", testPom);
    mojo.outputDirectory = new File(this.testDir, "outputDirectory");
    // mojo.silent = true;
    assertNotNull(mojo);
    assertNotNull(mojo.getProject());
    MavenProject project = mojo.getProject();
    MavenSession session = newMavenSession(project);
    setVariableValueToObject(mojo, "session", session);
    DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) session.getRepositorySession();
    repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManager(stubFactory.getWorkingDir()));
    Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts();
    Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
    artifacts.addAll(directArtifacts);
    project.setArtifacts(artifacts);
    project.setDependencyArtifacts(directArtifacts);
    mojo.markersDirectory = new File(this.testDir, "markers");
    ArtifactHandlerManager manager = lookup(ArtifactHandlerManager.class);
    setVariableValueToObject(mojo, "artifactHandlerManager", manager);
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) SimpleLocalRepositoryManager(org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager) MavenProject(org.apache.maven.project.MavenProject) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) ArtifactHandlerManager(org.apache.maven.artifact.handler.manager.ArtifactHandlerManager) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Example 35 with SimpleLocalRepositoryManager

use of org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager in project maven-plugins 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)

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