use of org.apache.maven.plugins.resources.stub.MavenProjectResourcesStub in project maven-plugins by apache.
the class ResourcesMojoTest method testPropertyFiles_Extra.
/**
* @throws Exception
*/
public void testPropertyFiles_Extra() throws Exception {
File testPom = new File(getBasedir(), defaultPomFilePath);
ResourcesMojo mojo = (ResourcesMojo) lookupMojo("resources", testPom);
MavenProjectResourcesStub project = new MavenProjectResourcesStub("resourcePropertyFiles_Extra");
List<Resource> resources = project.getBuild().getResources();
LinkedList<String> filterList = new LinkedList<String>();
assertNotNull(mojo);
project.addFile("extra.properties", "current working directory=${dir}");
project.addFile("filter.properties", "dir:testdir");
project.setResourceFiltering(0, true);
project.setupBuildEnvironment();
filterList.add(project.getResourcesDirectory() + "filter.properties");
// setVariableValueToObject(mojo,"encoding","UTF-8");
setVariableValueToObject(mojo, "project", project);
setVariableValueToObject(mojo, "resources", resources);
setVariableValueToObject(mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
setVariableValueToObject(mojo, "filters", filterList);
setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
mojo.execute();
String resourcesDir = project.getOutputDirectory();
String checkString = "current working directory=testdir";
assertContent(resourcesDir + "/extra.properties", checkString);
}
use of org.apache.maven.plugins.resources.stub.MavenProjectResourcesStub in project maven-plugins by apache.
the class TestResourcesTest method testTestResourceDirectoryCreation.
/**
* @throws Exception
*/
public void testTestResourceDirectoryCreation() throws Exception {
File testPom = new File(getBasedir(), defaultPomFilePath);
TestResourcesMojo mojo = (TestResourcesMojo) lookupMojo("testResources", testPom);
MavenProjectResourcesStub project = new MavenProjectResourcesStub("testResourceDirectoryStructure");
List<Resource> resources = project.getBuild().getResources();
assertNotNull(mojo);
project.addFile("file4.txt");
project.addFile("package/file3.nottest");
project.addFile("notpackage/file1.include");
project.addFile("package/test/file1.txt");
project.addFile("notpackage/test/file2.txt");
project.setupBuildEnvironment();
setVariableValueToObject(mojo, "project", project);
setVariableValueToObject(mojo, "resources", resources);
setVariableValueToObject(mojo, "outputDirectory", new File(project.getBuild().getTestOutputDirectory()));
setVariableValueToObject(mojo, "buildFilters", Collections.emptyList());
setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
mojo.execute();
String resorucesDir = project.getTestOutputDirectory();
assertTrue(FileUtils.fileExists(resorucesDir + "/file4.txt"));
assertTrue(FileUtils.fileExists(resorucesDir + "/package/file3.nottest"));
assertTrue(FileUtils.fileExists(resorucesDir + "/notpackage/file1.include"));
assertTrue(FileUtils.fileExists(resorucesDir + "/package/test"));
assertTrue(FileUtils.fileExists(resorucesDir + "/notpackage/test"));
}
Aggregations