Search in sources :

Example 1 with InstallFileMojo

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());
}
Also used : InstallFileMojo(org.apache.maven.plugins.install.InstallFileMojo) Model(org.apache.maven.model.Model) Reader(java.io.Reader) MavenXpp3Reader(org.apache.maven.model.io.xpp3.MavenXpp3Reader) MavenXpp3Reader(org.apache.maven.model.io.xpp3.MavenXpp3Reader) File(java.io.File)

Example 2 with InstallFileMojo

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());
}
Also used : InstallFileMojo(org.apache.maven.plugins.install.InstallFileMojo) File(java.io.File)

Example 3 with InstallFileMojo

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);
}
Also used : InstallFileMojo(org.apache.maven.plugins.install.InstallFileMojo) File(java.io.File)

Example 4 with InstallFileMojo

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());
}
Also used : InstallFileMojo(org.apache.maven.plugins.install.InstallFileMojo) File(java.io.File)

Example 5 with InstallFileMojo

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());
}
Also used : InstallFileMojo(org.apache.maven.plugins.install.InstallFileMojo) File(java.io.File)

Aggregations

File (java.io.File)7 InstallFileMojo (org.apache.maven.plugins.install.InstallFileMojo)7 Reader (java.io.Reader)1 Map (java.util.Map)1 Model (org.apache.maven.model.Model)1 MavenXpp3Reader (org.apache.maven.model.io.xpp3.MavenXpp3Reader)1