Search in sources :

Example 6 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)

Example 7 with InstallFileMojo

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

the class InstallFileMojoTest method testInstallFileWithChecksum.

public void testInstallFileWithChecksum() throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/install-file-with-checksum/" + "plugin-config.xml");
    InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom);
    assertNotNull(mojo);
    setVariableValueToObject(mojo, "session", createMavenSession());
    assignValuesForParameter(mojo);
    boolean createChecksum = (Boolean) getVariableValueFromObject(mojo, "createChecksum");
    assertTrue(createChecksum);
    mojo.execute();
    String localPath = getBasedir() + "/" + LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version;
    File installedArtifact = new File(localPath + "." + "jar");
    //get the actual checksum of the artifact
    Map<String, Object> csums = ChecksumUtils.calc(file, Utils.CHECKSUM_ALGORITHMS);
    for (Map.Entry<String, Object> csum : csums.entrySet()) {
        Object actualSum = csum.getValue();
        File sum = new File(localPath + ".jar." + csum.getKey().toLowerCase().replace("-", ""));
        assertTrue(sum.exists());
        String generatedSum = FileUtils.fileRead(sum, "UTF-8");
        assertEquals(actualSum, generatedSum);
    }
    assertTrue(installedArtifact.exists());
    assertEquals(9, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size());
}
Also used : InstallFileMojo(org.apache.maven.plugins.install.InstallFileMojo) File(java.io.File) Map(java.util.Map)

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