Search in sources :

Example 1 with InvokerMojo

use of org.apache.maven.plugins.invoker.InvokerMojo in project maven-plugins by apache.

the class InterpolationTest method testProfilesWithNoFile.

public void testProfilesWithNoFile() throws Exception {
    InvokerMojo invokerMojo = new InvokerMojo();
    setVariableValueToObject(invokerMojo, "profiles", Arrays.asList("zloug"));
    setVariableValueToObject(invokerMojo, "settings", new Settings());
    String dirPath = getBasedir() + File.separatorChar + "src" + File.separatorChar + "test" + File.separatorChar + "resources" + File.separatorChar + "unit" + File.separatorChar + "profiles-from-file";
    List<String> profiles = invokerMojo.getProfiles(new File(dirPath));
    assertTrue(profiles.contains("zloug"));
    assertEquals(1, profiles.size());
}
Also used : InvokerMojo(org.apache.maven.plugins.invoker.InvokerMojo) File(java.io.File) Settings(org.apache.maven.settings.Settings)

Example 2 with InvokerMojo

use of org.apache.maven.plugins.invoker.InvokerMojo in project maven-plugins by apache.

the class InterpolationTest method testPomInterpolation.

public void testPomInterpolation() throws Exception {
    Reader reader = null;
    File interpolatedPomFile;
    try {
        InvokerMojo invokerMojo = new InvokerMojo();
        setVariableValueToObject(invokerMojo, "project", buildMavenProjectStub());
        setVariableValueToObject(invokerMojo, "settings", new Settings());
        Properties properties = new Properties();
        properties.put("foo", "bar");
        properties.put("version", "2.0-SNAPSHOT");
        setVariableValueToObject(invokerMojo, "filterProperties", properties);
        String dirPath = getBasedir() + File.separatorChar + "src" + File.separatorChar + "test" + File.separatorChar + "resources" + File.separatorChar + "unit" + File.separatorChar + "interpolation";
        interpolatedPomFile = new File(getBasedir(), "target/interpolated-pom.xml");
        invokerMojo.buildInterpolatedFile(new File(dirPath, "pom.xml"), interpolatedPomFile);
        reader = ReaderFactory.newXmlReader(interpolatedPomFile);
        String content = IOUtil.toString(reader);
        assertTrue(content.indexOf("<interpolateValue>bar</interpolateValue>") > 0);
        reader.close();
        reader = null;
        // recreate it to test delete if exists before creation
        invokerMojo.buildInterpolatedFile(new File(dirPath, "pom.xml"), interpolatedPomFile);
        reader = ReaderFactory.newXmlReader(interpolatedPomFile);
        content = IOUtil.toString(reader);
        assertTrue(content.indexOf("<interpolateValue>bar</interpolateValue>") > 0);
        reader.close();
        reader = null;
    } finally {
        IOUtil.close(reader);
    }
}
Also used : InvokerMojo(org.apache.maven.plugins.invoker.InvokerMojo) Reader(java.io.Reader) Properties(java.util.Properties) File(java.io.File) Settings(org.apache.maven.settings.Settings)

Aggregations

File (java.io.File)2 InvokerMojo (org.apache.maven.plugins.invoker.InvokerMojo)2 Settings (org.apache.maven.settings.Settings)2 Reader (java.io.Reader)1 Properties (java.util.Properties)1