use of org.apache.maven.plugins.install.AbstractInstallMojo in project maven-plugins by apache.
the class InstallMojoTest method testInstallTestEnvironment.
public void testInstallTestEnvironment() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/basic-install-test/plugin-config.xml");
AbstractInstallMojo mojo = (AbstractInstallMojo) lookupMojo("install", testPom);
assertNotNull(mojo);
}
use of org.apache.maven.plugins.install.AbstractInstallMojo 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());
}
use of org.apache.maven.plugins.install.AbstractInstallMojo in project maven-plugins by apache.
the class InstallMojoTest method testUpdateReleaseParamSetToTrue.
public void testUpdateReleaseParamSetToTrue() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/configured-install-test/plugin-config.xml");
AbstractInstallMojo mojo = (AbstractInstallMojo) lookupMojo("install", testPom);
assertNotNull(mojo);
File file = new File(getBasedir(), "target/test-classes/unit/configured-install-test/target/" + "maven-install-test-1.0-SNAPSHOT.jar");
MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project");
updateMavenProject(project);
setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project));
setVariableValueToObject(mojo, "session", createMavenSession());
artifact = (InstallArtifactStub) project.getArtifact();
artifact.setFile(file);
mojo.execute();
assertTrue(artifact.isRelease());
assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size());
}
use of org.apache.maven.plugins.install.AbstractInstallMojo in project maven-plugins by apache.
the class InstallMojoTest method testBasicInstall.
public void testBasicInstall() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/basic-install-test/plugin-config.xml");
AbstractInstallMojo mojo = (AbstractInstallMojo) lookupMojo("install", testPom);
assertNotNull(mojo);
File file = new File(getBasedir(), "target/test-classes/unit/basic-install-test/target/" + "maven-install-test-1.0-SNAPSHOT.jar");
MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project");
updateMavenProject(project);
setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project));
setVariableValueToObject(mojo, "session", createMavenSession());
artifact = (InstallArtifactStub) project.getArtifact();
artifact.setFile(file);
mojo.execute();
String groupId = dotToSlashReplacer(artifact.getGroupId());
File installedArtifact = new File(getBasedir(), LOCAL_REPO + groupId + "/" + artifact.getArtifactId() + "/" + artifact.getVersion() + "/" + artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getArtifactHandler().getExtension());
assertTrue(installedArtifact.exists());
assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size());
}
use of org.apache.maven.plugins.install.AbstractInstallMojo in project maven-plugins by apache.
the class InstallMojoTest method testInstallIfArtifactFileIsNull.
public void testInstallIfArtifactFileIsNull() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/basic-install-test/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());
artifact = (InstallArtifactStub) project.getArtifact();
artifact.setFile(null);
assertNull(artifact.getFile());
try {
mojo.execute();
fail("Did not throw mojo execution exception");
} catch (MojoExecutionException e) {
//expected
}
assertFalse(new File(LOCAL_REPO).exists());
}
Aggregations