in src/main/org/apache/tools/ant/taskdefs/Property.java [501:578]
public void execute() throws BuildException {
if (getProject() == null) {
throw new IllegalStateException("project has not been set");
}
if (name != null) {
if (untypedValue == null && ref == null) {
throw new BuildException(
"You must specify value, location or refid with the name attribute",
getLocation());
}
} else {
if (url == null && file == null && resource == null
&& env == null && runtime == null) {
throw new BuildException(
"You must specify url, file, resource, environment or runtime when not using the name attribute",
getLocation());
}
}
if (url == null && file == null && resource == null && prefix != null) {
throw new BuildException(
"Prefix is only valid when loading from a url, file or resource",
getLocation());
}
if (name != null && untypedValue != null) {
if (relative) {
try {
File from =
untypedValue instanceof File ? (File) untypedValue
: new File(untypedValue.toString());
File to = basedir != null ? basedir : getProject().getBaseDir();
String relPath = FileUtils.getRelativePath(to, from);
relPath = relPath.replace('/', File.separatorChar);
addProperty(name, relPath);
} catch (Exception e) {
throw new BuildException(e, getLocation());
}
} else {
addProperty(name, untypedValue);
}
}
if (file != null) {
loadFile(file);
}
if (url != null) {
loadUrl(url);
}
if (resource != null) {
loadResource(resource);
}
if (env != null) {
loadEnvironment(env);
}
if (runtime != null) {
loadRuntime(runtime);
}
if (name != null && ref != null) {
try {
addProperty(name,
ref.getReferencedObject(getProject()).toString());
} catch (BuildException be) {
if (fallback != null) {
addProperty(name,
ref.getReferencedObject(fallback).toString());
} else {
throw be;
}
}
}
}