Search in sources :

Example 1 with AttachedArtifactStub0

use of org.apache.maven.plugins.install.stubs.AttachedArtifactStub0 in project maven-plugins by apache.

the class InstallMojoTest method testBasicInstallWithAttachedArtifacts.

public void testBasicInstallWithAttachedArtifacts() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/basic-install-test-with-attached-artifacts/" + "plugin-config.xml");
    AbstractInstallMojo mojo = (AbstractInstallMojo) lookupMojo("install", testPom);
    assertNotNull(mojo);
    MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project");
    updateMavenProject(project);
    setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project));
    setVariableValueToObject(mojo, "session", createMavenSession());
    List<Artifact> attachedArtifacts = project.getAttachedArtifacts();
    mojo.execute();
    String packaging = project.getPackaging();
    String groupId;
    for (Object attachedArtifact1 : attachedArtifacts) {
        AttachedArtifactStub0 attachedArtifact = (AttachedArtifactStub0) attachedArtifact1;
        groupId = dotToSlashReplacer(attachedArtifact.getGroupId());
        File installedArtifact = new File(getBasedir(), LOCAL_REPO + groupId + "/" + attachedArtifact.getArtifactId() + "/" + attachedArtifact.getVersion() + "/" + attachedArtifact.getArtifactId() + "-" + attachedArtifact.getVersion() + "." + packaging);
        assertTrue(installedArtifact.getPath() + " does not exist", installedArtifact.exists());
    }
    assertEquals(13, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size());
}
Also used : MavenProject(org.apache.maven.project.MavenProject) AbstractInstallMojo(org.apache.maven.plugins.install.AbstractInstallMojo) AttachedArtifactStub0(org.apache.maven.plugins.install.stubs.AttachedArtifactStub0) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Aggregations

File (java.io.File)1 Artifact (org.apache.maven.artifact.Artifact)1 AbstractInstallMojo (org.apache.maven.plugins.install.AbstractInstallMojo)1 AttachedArtifactStub0 (org.apache.maven.plugins.install.stubs.AttachedArtifactStub0)1 MavenProject (org.apache.maven.project.MavenProject)1