use of org.apache.tools.ant.types.Path in project ant by apache.
the class Depend method getCheckClassPath.
/**
* Get the classpath for dependency checking.
*
* This method removes the dest dirs if it is given from the dependency classpath
*/
private Path getCheckClassPath() {
if (dependClasspath == null) {
return null;
}
Set<Resource> dependNotInDest = new LinkedHashSet<>();
dependClasspath.forEach(dependNotInDest::add);
destPath.forEach(dependNotInDest::remove);
Path p;
if (dependNotInDest.isEmpty()) {
p = null;
} else {
p = new Path(getProject());
dependNotInDest.forEach(p::add);
}
log("Classpath without dest dir is " + p, Project.MSG_DEBUG);
return p;
}
use of org.apache.tools.ant.types.Path in project ant by apache.
the class Find method execute.
public void execute() {
validate();
// find all files
for (Path path : paths) {
for (String includedFile : path.list()) {
String filename = includedFile.replace('\\', '/');
filename = filename.substring(filename.lastIndexOf("/") + 1);
if (file.equals(filename) && !foundFiles.contains(includedFile)) {
foundFiles.add(includedFile);
}
}
}
// create the return value (list/single)
String rv = null;
if (!foundFiles.isEmpty()) {
if (delimiter == null) {
// only the first
rv = foundFiles.get(0);
} else {
// create list
StringBuilder list = new StringBuilder();
for (String file : foundFiles) {
if (list.length() > 0)
list.append(delimiter);
list.append(file);
}
rv = list.toString();
}
}
// create the property
if (rv != null)
getProject().setNewProperty(location, rv);
}
use of org.apache.tools.ant.types.Path in project narayana by jbosstm.
the class ClasspathBuilder method createClasspath.
public Path createClasspath() {
Path c = new Path(project);
_paths.add(c);
return (c);
}
use of org.apache.tools.ant.types.Path in project narayana by jbosstm.
the class ClasspathBuilder method execute.
public void execute() throws BuildException {
if (_filename == null) {
throw new BuildException("No filename specified to store built classpath!");
}
if (_paths.size() > 0) {
try {
for (int filenameCount = 0; filenameCount < _filename.length; filenameCount++) {
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(_filename[filenameCount], !_clear)));
for (int count = 0; count < _paths.size(); count++) {
Object obj = _paths.get(count);
if (obj instanceof Path) {
Path path = (Path) obj;
String[] paths = path.list();
for (int pathCount = 0; pathCount < paths.length; pathCount++) {
out.write(paths[pathCount] + "\n");
}
}
}
out.close();
}
} catch (java.io.IOException e) {
throw new BuildException("Failed to update file (reason: " + e + ")");
}
} else if (_clear) {
/**
* If a request to clear the file has been made but no entries have been
* given then we need to delete the classpath builder file.
*/
for (int filenameCount = 0; filenameCount < _filename.length; filenameCount++) {
new File(_filename[filenameCount]).delete();
}
}
if (_property != null) {
putClasspathInProperty(_filename, _property);
}
}
use of org.apache.tools.ant.types.Path in project ci.ant by WASdev.
the class CompileJSPs method createAppXML.
private void createAppXML(File serverDir) throws FileNotFoundException {
if (srcdir != null) {
// TODO write the loose application xml.
File appsDir = new File(serverDir, "apps");
appsDir.mkdirs();
PrintStream ps = new PrintStream(new File(appsDir, "fake.war.xml"));
ps.println("<archive>");
ps.println(" <dir targetInArchive=\"/\" sourceOnDisk=\"" + srcdir.getAbsolutePath() + "\"/>");
Path p = new Path(getProject(), classpath);
if (classpathRef != null) {
Path path = (Path) getProject().getReference(classpathRef);
p.add(path);
}
String[] cp = p.toString().split(File.pathSeparator);
for (String entry : cp) {
File f = new File(entry);
String basename = f.getName();
if (f.isFile() && f.exists() && f.getName().endsWith(".jar")) {
ps.println(" <file targetInArchive=\"/WEB-INF/lib/" + basename + "\" sourceOnDisk=\"" + f.getAbsolutePath() + "\"/>");
} else if (f.isDirectory() && f.exists()) {
// TODO: What if basename is NOT "classes"?
ps.println(" <dir targetInArchive=\"/WEB-INF/classes\" sourceOnDisk=\"" + f.getAbsolutePath() + "\"/>");
}
}
ps.println("</archive>");
ps.close();
}
}
Aggregations