Methods Summary |
---|
public void | add(org.apache.tools.ant.types.Path path)Adds a nested path
if (path == this) {
throw circularReference();
}
if (path.getProject() == null) {
path.setProject(getProject());
}
add((ResourceCollection) path);
|
public void | add(ResourceCollection c)Add a nested ResourceCollection .
checkChildrenAllowed();
if (c == null) {
return;
}
if (union == null) {
union = new Union();
union.setProject(getProject());
union.setCache(false);
}
union.add(c);
setChecked(false);
|
public void | addDirset(DirSet dset)Adds a nested <dirset> element.
if (dset.getProject() == null) {
dset.setProject(getProject());
}
add(dset);
|
public void | addExisting(org.apache.tools.ant.types.Path source)Adds the components on the given path which exist to this
Path. Components that don't exist aren't added.
addExisting(source, false);
|
public void | addExisting(org.apache.tools.ant.types.Path source, boolean tryUserDir)Same as addExisting, but support classpath behavior if tryUserDir
is true. Classpaths are relative to user dir, not the project base.
That used to break jspc test
String[] list = source.list();
File userDir = (tryUserDir) ? new File(System.getProperty("user.dir"))
: null;
for (int i = 0; i < list.length; i++) {
File f = resolveFile(getProject(), list[i]);
// probably not the best choice, but it solves the problem of
// relative paths in CLASSPATH
if (tryUserDir && !f.exists()) {
f = new File(userDir, list[i]);
}
if (f.exists()) {
setLocation(f);
} else {
log("dropping " + f + " from path as it doesn't exist",
Project.MSG_VERBOSE);
}
}
|
public void | addExtdirs(org.apache.tools.ant.types.Path extdirs)Emulation of extdirs feature in java >= 1.2.
This method adds all files in the given
directories (but not in sub-directories!) to the classpath,
so that you don't have to specify them all one by one.
if (extdirs == null) {
String extProp = System.getProperty("java.ext.dirs");
if (extProp != null) {
extdirs = new Path(getProject(), extProp);
} else {
return;
}
}
String[] dirs = extdirs.list();
for (int i = 0; i < dirs.length; i++) {
File dir = resolveFile(getProject(), dirs[i]);
if (dir.exists() && dir.isDirectory()) {
FileSet fs = new FileSet();
fs.setDir(dir);
fs.setIncludes("*");
addFileset(fs);
}
}
|
public void | addFilelist(FileList fl)Adds a nested <filelist> element.
if (fl.getProject() == null) {
fl.setProject(getProject());
}
add(fl);
|
public void | addFileset(FileSet fs)Adds a nested <fileset> element.
if (fs.getProject() == null) {
fs.setProject(getProject());
}
add(fs);
|
public void | addJavaRuntime()Add the Java Runtime classes to this Path instance.
if (JavaEnvUtils.isKaffe()) {
// newer versions of Kaffe (1.1.1+) won't have this,
// but this will be sorted by FileSet anyway.
File kaffeShare = new File(System.getProperty("java.home")
+ File.separator + "share"
+ File.separator + "kaffe");
if (kaffeShare.isDirectory()) {
FileSet kaffeJarFiles = new FileSet();
kaffeJarFiles.setDir(kaffeShare);
kaffeJarFiles.setIncludes("*.jar");
addFileset(kaffeJarFiles);
}
} else if ("GNU libgcj".equals(System.getProperty("java.vm.name"))) {
addExisting(systemBootClasspath);
}
if (System.getProperty("java.vendor").toLowerCase(Locale.US).indexOf("microsoft") >= 0) {
// XXX is this code still necessary? is there any 1.2+ port?
// Pull in *.zip from packages directory
FileSet msZipFiles = new FileSet();
msZipFiles.setDir(new File(System.getProperty("java.home")
+ File.separator + "Packages"));
msZipFiles.setIncludes("*.ZIP");
addFileset(msZipFiles);
} else {
// JDK 1.2+ seems to set java.home to the JRE directory.
addExisting(new Path(null,
System.getProperty("java.home")
+ File.separator + "lib"
+ File.separator + "rt.jar"));
// Just keep the old version as well and let addExisting
// sort it out.
addExisting(new Path(null,
System.getProperty("java.home")
+ File.separator + "jre"
+ File.separator + "lib"
+ File.separator + "rt.jar"));
// Sun's and Apple's 1.4 have JCE and JSSE in separate jars.
String[] secJars = {"jce", "jsse"};
for (int i = 0; i < secJars.length; i++) {
addExisting(new Path(null,
System.getProperty("java.home")
+ File.separator + "lib"
+ File.separator + secJars[i] + ".jar"));
addExisting(new Path(null,
System.getProperty("java.home")
+ File.separator + ".."
+ File.separator + "Classes"
+ File.separator + secJars[i] + ".jar"));
}
// IBM's 1.4 has rt.jar split into 4 smaller jars and a combined
// JCE/JSSE in security.jar.
String[] ibmJars
= {"core", "graphics", "security", "server", "xml"};
for (int i = 0; i < ibmJars.length; i++) {
addExisting(new Path(null,
System.getProperty("java.home")
+ File.separator + "lib"
+ File.separator + ibmJars[i] + ".jar"));
}
// Added for MacOS X
addExisting(new Path(null,
System.getProperty("java.home")
+ File.separator + ".."
+ File.separator + "Classes"
+ File.separator + "classes.jar"));
addExisting(new Path(null,
System.getProperty("java.home")
+ File.separator + ".."
+ File.separator + "Classes"
+ File.separator + "ui.jar"));
}
|
public void | append(org.apache.tools.ant.types.Path other)Append the contents of the other Path instance to this.
if (other == null) {
return;
}
add(other);
|
protected ResourceCollection | assertFilesystemOnly(ResourceCollection rc)Verify the specified ResourceCollection is filesystem-only.
if (rc != null && !(rc.isFilesystemOnly())) {
throw new BuildException(getDataTypeName()
+ " allows only filesystem resources.");
}
return rc;
|
public java.lang.Object | clone()Clone this Path.
try {
Path result = (Path) super.clone();
result.union = union == null ? union : (Union) union.clone();
return result;
} catch (CloneNotSupportedException e) {
throw new BuildException(e);
}
|
private org.apache.tools.ant.types.Path | concatSpecialPath(java.lang.String defValue, org.apache.tools.ant.types.Path p)Concatenates a class path in the order specified by the
${build.sysclasspath} property - using the supplied value if
${build.sysclasspath} has not been set.
Path result = new Path(getProject());
String order = defValue;
if (getProject() != null) {
String o = getProject().getProperty("build.sysclasspath");
if (o != null) {
order = o;
}
}
if (order.equals("only")) {
// only: the developer knows what (s)he is doing
result.addExisting(p, true);
} else if (order.equals("first")) {
// first: developer could use a little help
result.addExisting(p, true);
result.addExisting(this);
} else if (order.equals("ignore")) {
// ignore: don't trust anyone
result.addExisting(this);
} else {
// last: don't trust the developer
if (!order.equals("last")) {
log("invalid value for build.sysclasspath: " + order,
Project.MSG_WARN);
}
result.addExisting(this);
result.addExisting(p, true);
}
return result;
|
public org.apache.tools.ant.types.Path | concatSystemBootClasspath(java.lang.String defValue)Concatenates the system boot class path in the order specified
by the ${build.sysclasspath} property - using the supplied
value if ${build.sysclasspath} has not been set.
return concatSpecialPath(defValue, Path.systemBootClasspath);
|
public org.apache.tools.ant.types.Path | concatSystemClasspath()Concatenates the system class path in the order specified by
the ${build.sysclasspath} property - using "last" as
default value.
return concatSystemClasspath("last");
|
public org.apache.tools.ant.types.Path | concatSystemClasspath(java.lang.String defValue)Concatenates the system class path in the order specified by
the ${build.sysclasspath} property - using the supplied value
if ${build.sysclasspath} has not been set.
return concatSpecialPath(defValue, Path.systemClasspath);
|
public org.apache.tools.ant.types.Path | createPath()Creates a nested <path> element.
Path p = new Path(getProject());
add(p);
return p;
|
public org.apache.tools.ant.types.Path$PathElement | createPathElement()Creates the nested <pathelement> element.
if (isReference()) {
throw noChildrenAllowed();
}
PathElement pe = new PathElement();
add(pe);
return pe;
|
protected synchronized void | dieOnCircularReference(java.util.Stack stk, org.apache.tools.ant.Project p)Overrides the version of DataType to recurse on all DataType
child elements that may have been added.
if (isChecked()) {
return;
}
if (isReference()) {
super.dieOnCircularReference(stk, p);
} else {
if (union != null) {
stk.push(union);
invokeCircularReferenceCheck(union, stk, p);
stk.pop();
}
setChecked(true);
}
|
public synchronized boolean | isFilesystemOnly()Fulfill the ResourceCollection contract.
if (isReference()) {
return ((Path) getCheckedRef()).isFilesystemOnly();
}
dieOnCircularReference();
assertFilesystemOnly(union);
return true;
|
public final synchronized java.util.Iterator | iterator()Fulfill the ResourceCollection contract. The Iterator returned
will throw ConcurrentModificationExceptions if ResourceCollections
are added to this container while the Iterator is in use.
if (isReference()) {
return ((Path) getCheckedRef()).iterator();
}
dieOnCircularReference();
return union == null ? EMPTY_ITERATOR
: assertFilesystemOnly(union).iterator();
|
public java.lang.String[] | list()Returns all path elements defined by this and nested path objects.
if (isReference()) {
return ((Path) getCheckedRef()).list();
}
return assertFilesystemOnly(union) == null
? new String[0] : union.list();
|
private static java.io.File | resolveFile(org.apache.tools.ant.Project project, java.lang.String relativeName)Resolve a filename with Project's help - if we know one that is.
return FileUtils.getFileUtils().resolveFile(
(project == null) ? null : project.getBaseDir(), relativeName);
|
public void | setLocation(java.io.File location)Adds a element definition to the path.
checkAttributesAllowed();
createPathElement().setLocation(location);
|
public void | setPath(java.lang.String path)Parses a path definition and creates single PathElements.
checkAttributesAllowed();
createPathElement().setPath(path);
|
public void | setRefid(Reference r)Makes this instance in effect a reference to another Path instance.
You must not set another attribute or nest elements inside
this element if you make it a reference.
if (union != null) {
throw tooManyAttributes();
}
super.setRefid(r);
|
public synchronized int | size()Fulfill the ResourceCollection contract.
if (isReference()) {
return ((Path) getCheckedRef()).size();
}
dieOnCircularReference();
return union == null ? 0 : assertFilesystemOnly(union).size();
|
public java.lang.String | toString()Returns a textual representation of the path, which can be used as
CLASSPATH or PATH environment variable definition.
return isReference() ? getCheckedRef().toString()
: union == null ? "" : union.toString();
|
public static java.lang.String | translateFile(java.lang.String source)Returns its argument with all file separator characters
replaced so that they match the local OS conventions.
if (source == null) {
return "";
}
final StringBuffer result = new StringBuffer(source);
for (int i = 0; i < result.length(); i++) {
translateFileSep(result, i);
}
return result.toString();
|
protected static boolean | translateFileSep(java.lang.StringBuffer buffer, int pos)Translates occurrences at a position of / or \ to correct separator of the
current platform and returns whether it had to do a
replacement.
if (buffer.charAt(pos) == '/" || buffer.charAt(pos) == '\\") {
buffer.setCharAt(pos, File.separatorChar);
return true;
}
return false;
|
public static java.lang.String[] | translatePath(org.apache.tools.ant.Project project, java.lang.String source)Splits a PATH (with : or ; as separators) into its parts.
final Vector result = new Vector();
if (source == null) {
return new String[0];
}
PathTokenizer tok = new PathTokenizer(source);
StringBuffer element = new StringBuffer();
while (tok.hasMoreTokens()) {
String pathElement = tok.nextToken();
try {
element.append(resolveFile(project, pathElement).getPath());
} catch (BuildException e) {
project.log("Dropping path element " + pathElement
+ " as it is not valid relative to the project",
Project.MSG_VERBOSE);
}
for (int i = 0; i < element.length(); i++) {
translateFileSep(element, i);
}
result.addElement(element.toString());
element = new StringBuffer();
}
String[] res = new String[result.size()];
result.copyInto(res);
return res;
|