use of org.apache.tools.ant.types.FileList in project cayenne by apache.
the class CayenneGeneratorTaskCrossMapRelationshipsTest method testCrossDataMapRelationships.
/**
* Tests pairs generation with a cross-DataMap relationship.
*/
@Test
public void testCrossDataMapRelationships() throws Exception {
CayenneGeneratorTask task = new CayenneGeneratorTask();
task.setProject(new Project());
task.setTaskName("Test");
task.setLocation(Location.UNKNOWN_LOCATION);
// prepare destination directory
File destDir = new File(FileUtil.baseTestDirectory(), "cgen12");
// prepare destination directory
if (!destDir.exists()) {
assertTrue(destDir.mkdirs());
}
File map = new File(destDir, "cgen-dependent.map.xml");
ResourceUtil.copyResourceToFile("org/apache/cayenne/tools/cgen-dependent.map.xml", map);
File[] additionalMaps = new File[1];
additionalMaps[0] = new File(destDir, "cgen.map.xml");
ResourceUtil.copyResourceToFile("org/apache/cayenne/tools/cgen.map.xml", additionalMaps[0]);
FileList additionalMapsFilelist = new FileList();
additionalMapsFilelist.setDir(additionalMaps[0].getParentFile());
additionalMapsFilelist.setFiles(additionalMaps[0].getName());
Path additionalMapsPath = new Path(task.getProject());
additionalMapsPath.addFilelist(additionalMapsFilelist);
// setup task
task.setMap(map);
task.setAdditionalMaps(additionalMapsPath);
task.setMakepairs(true);
task.setOverwrite(false);
task.setMode("entity");
task.setIncludeEntities("MyArtGroup");
task.setDestDir(destDir);
task.setSuperpkg("org.apache.cayenne.testdo.cgen2.auto");
task.setUsepkgpath(true);
// run task
task.execute();
// check results
File a = new File(destDir, convertPath("org/apache/cayenne/testdo/cgen2/MyArtGroup.java"));
assertTrue(a.isFile());
assertContents(a, "MyArtGroup", "org.apache.cayenne.testdo.cgen2", "_MyArtGroup");
File _a = new File(destDir, convertPath("org/apache/cayenne/testdo/cgen2/auto/_MyArtGroup.java"));
assertTrue(_a.exists());
assertContents(_a, "_MyArtGroup", "org.apache.cayenne.testdo.cgen2.auto", "BaseDataObject");
assertContents(_a, "import org.apache.cayenne.testdo.testmap.ArtGroup;");
assertContents(_a, " ArtGroup getToParentGroup()");
assertContents(_a, "setToParentGroup(ArtGroup toParentGroup)");
}
use of org.apache.tools.ant.types.FileList in project closure-compiler by google.
the class CompileTask method getLastModifiedTime.
/**
* Returns the most recent modified timestamp of the file collection.
*
* Note: this must be combined into one method to account for both
* Path and FileList erasure types.
*
* @param fileLists Collection of FileList or Path
* @return Most recent modified timestamp
*/
private long getLastModifiedTime(List<?> fileLists) {
long lastModified = 0;
for (Object entry : fileLists) {
if (entry instanceof FileList) {
FileList list = (FileList) entry;
for (String fileName : list.getFiles(this.getProject())) {
File path = list.getDir(this.getProject());
File file = new File(path, fileName);
lastModified = Math.max(getLastModifiedTime(file), lastModified);
}
} else if (entry instanceof Path) {
Path path = (Path) entry;
for (String src : path.list()) {
File file = new File(src);
lastModified = Math.max(getLastModifiedTime(file), lastModified);
}
}
}
return lastModified;
}
use of org.apache.tools.ant.types.FileList in project closure-compiler by google.
the class CompileTask method findExternFiles.
private List<SourceFile> findExternFiles(CompilerOptions options) {
List<SourceFile> files = new ArrayList<>();
files.addAll(getBuiltinExterns(options));
for (FileList list : this.externFileLists) {
files.addAll(findJavaScriptFiles(list));
}
return files;
}