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());
}
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);
}
}
Aggregations