use of org.apache.maven.plugins.install.InstallFileMojo in project maven-plugins by apache.
the class InstallFileMojoTest method testInstallFileWithGeneratePom.
public void testInstallFileWithGeneratePom() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/install-file-test-generatePom/plugin-config.xml");
InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom);
assertNotNull(mojo);
setVariableValueToObject(mojo, "session", createMavenSession());
assignValuesForParameter(mojo);
mojo.execute();
File installedArtifact = new File(getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + "." + packaging);
assertTrue((Boolean) getVariableValueFromObject(mojo, "generatePom"));
assertTrue(installedArtifact.exists());
File installedPom = new File(getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + "." + "pom");
Model model;
Reader reader = null;
try {
reader = ReaderFactory.newXmlReader(installedPom);
model = new MavenXpp3Reader().read(reader);
reader.close();
reader = null;
} finally {
IOUtil.close(reader);
}
assertEquals("4.0.0", model.getModelVersion());
assertEquals((String) getVariableValueFromObject(mojo, "groupId"), model.getGroupId());
assertEquals(artifactId, model.getArtifactId());
assertEquals(version, model.getVersion());
assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size());
}
use of org.apache.maven.plugins.install.InstallFileMojo in project maven-plugins by apache.
the class InstallFileMojoTest method testInstallFileWithPomFile.
public void testInstallFileWithPomFile() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/install-file-with-pomFile-test/plugin-config.xml");
InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom);
assertNotNull(mojo);
setVariableValueToObject(mojo, "session", createMavenSession());
assignValuesForParameter(mojo);
mojo.execute();
File pomFile = (File) getVariableValueFromObject(mojo, "pomFile");
assertTrue(pomFile.exists());
File installedArtifact = new File(getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + "." + packaging);
assertTrue(installedArtifact.exists());
File installedPom = new File(getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + "." + "pom");
assertTrue(installedPom.exists());
assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size());
}
use of org.apache.maven.plugins.install.InstallFileMojo in project maven-plugins by apache.
the class InstallFileMojoTest method testInstallFileTestEnvironment.
public void testInstallFileTestEnvironment() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/install-file-basic-test/plugin-config.xml");
InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom);
setVariableValueToObject(mojo, "session", createMavenSession());
assertNotNull(mojo);
}
use of org.apache.maven.plugins.install.InstallFileMojo in project maven-plugins by apache.
the class InstallFileMojoTest method testBasicInstallFile.
public void testBasicInstallFile() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/install-file-basic-test/plugin-config.xml");
InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom);
assertNotNull(mojo);
setVariableValueToObject(mojo, "session", createMavenSession());
assignValuesForParameter(mojo);
mojo.execute();
File pomFile = (File) getVariableValueFromObject(mojo, "pomFile");
org.codehaus.plexus.util.FileUtils.forceDelete(pomFile);
File installedArtifact = new File(getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + "." + packaging);
assertTrue(installedArtifact.exists());
assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size());
}
use of org.apache.maven.plugins.install.InstallFileMojo in project maven-plugins by apache.
the class InstallFileMojoTest method testInstallFileWithClassifier.
public void testInstallFileWithClassifier() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/install-file-with-classifier/plugin-config.xml");
InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom);
assertNotNull(mojo);
setVariableValueToObject(mojo, "session", createMavenSession());
assignValuesForParameter(mojo);
assertNotNull(classifier);
mojo.execute();
File pomFile = (File) getVariableValueFromObject(mojo, "pomFile");
org.codehaus.plexus.util.FileUtils.forceDelete(pomFile);
File installedArtifact = new File(getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + "-" + classifier + "." + packaging);
assertTrue(installedArtifact.exists());
assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size());
}
Aggregations