| Method from org.apache.tools.ant.ProjectHelper Detail: |
public static BuildException addLocationToBuildException(BuildException ex,
Location newLocation) {
if (ex.getLocation() == null || ex.getMessage() == null) {
return ex;
}
String errorMessage
= "The following error occurred while executing this line:"
+ System.getProperty("line.separator")
+ ex.getLocation().toString()
+ ex.getMessage();
if (newLocation == null) {
return new BuildException(errorMessage, ex);
}
return new BuildException(errorMessage, ex, newLocation);
}
Add location to build exception. |
public static void addText(Project project,
Object target,
String text) throws BuildException {
if (text == null) {
return;
}
if (target instanceof TypeAdapter) {
target = ((TypeAdapter) target).getProxy();
}
IntrospectionHelper.getHelper(project, target.getClass()).addText(project, target, text);
}
Adds the content of #PCDATA sections to an element. |
public static void addText(Project project,
Object target,
char[] buf,
int start,
int count) throws BuildException {
addText(project, target, new String(buf, start, count));
}
Adds the content of #PCDATA sections to an element. |
public boolean canParseAntlibDescriptor(Resource r) {
return false;
}
Whether this instance of ProjectHelper can parse an Antlib
descriptor given by the URL and return its content as an
UnknownElement ready to be turned into an Antlib task.
This method should not try to parse the content of the
descriptor, the URL is only given as an argument to allow
subclasses to decide whether they can support a given URL
scheme or not.
Subclasses that return true in this method must also
override
parseAntlibDescriptor .
This implementation returns false. |
public boolean canParseBuildFile(Resource buildFile) {
return true;
}
Check if the helper supports the kind of file. Some basic check on the
extension's file should be done here. |
public static void configure(Object target,
AttributeList attrs,
Project project) throws BuildException {
if (target instanceof TypeAdapter) {
target = ((TypeAdapter) target).getProxy();
}
IntrospectionHelper ih = IntrospectionHelper.getHelper(project, target.getClass());
for (int i = 0, length = attrs.getLength(); i < length; i++) {
// reflect these into the target
String value = replaceProperties(project, attrs.getValue(i), project.getProperties());
try {
ih.setAttribute(project, target, attrs.getName(i).toLowerCase(Locale.ENGLISH), value);
} catch (BuildException be) {
// id attribute must be set externally
if (!attrs.getName(i).equals("id")) {
throw be;
}
}
}
} Deprecated! since - 1.6.x.
Use IntrospectionHelper for each property.
Configures an object using an introspection handler. |
public static void configureProject(Project project,
File buildFile) throws BuildException {
FileResource resource = new FileResource(buildFile);
ProjectHelper helper = ProjectHelperRepository.getInstance().getProjectHelperForBuildFile(resource);
project.addReference(PROJECTHELPER_REFERENCE, helper);
helper.parse(project, buildFile);
}
Configures the project with the contents of the specified build file. |
public static String extractNameFromComponentName(String componentName) {
int index = componentName.lastIndexOf(':');
if (index == -1) {
return componentName;
}
return componentName.substring(index + 1);
}
extract the element name from a component name |
public static String extractUriFromComponentName(String componentName) {
if (componentName == null) {
return "";
}
int index = componentName.lastIndexOf(':');
if (index == -1) {
return "";
}
return componentName.substring(0, index);
}
extract a uri from a component name |
public static String genComponentName(String uri,
String name) {
if (uri == null || uri.equals("") || uri.equals(ANT_CORE_URI)) {
return name;
}
return uri + ":" + name;
}
Map a namespaced {uri,name} to an internal string format.
For BC purposes the names from the ant core uri will be
mapped to "name", other names will be mapped to
uri + ":" + name. |
public static ClassLoader getContextClassLoader() {
return LoaderUtils.isContextLoaderAvailable() ? LoaderUtils.getContextClassLoader() : null;
} Deprecated! since - 1.6.x.
Use LoaderUtils.getContextClassLoader()
JDK1.1 compatible access to the context class loader. Cut & paste from JAXP. |
public static String getCurrentPrefixSeparator() {
return (String) prefixSeparator.get();
}
|
public static String getCurrentTargetPrefix() {
return (String) targetPrefix.get();
}
|
public String getDefaultBuildFile() {
return Main.DEFAULT_BUILD_FILENAME;
}
The file name of the build script to be parsed if none specified on the command line |
public List getExtensionStack() {
return extensionStack;
}
Extension stack.
Used to keep track of targets that extend extension points. |
public Vector getImportStack() {
return importStack;
}
Import stack.
Used to keep track of imported files. Error reporting should
display the import path. |
public static ProjectHelper getProjectHelper() {
return (ProjectHelper) ProjectHelperRepository.getInstance().getHelpers().next();
}
Get the first project helper found in the classpath |
public static boolean isInIncludeMode() {
return inIncludeMode.get() == Boolean.TRUE;
}
Whether the current file should be read in include as opposed
to import mode.
In include mode included targets are only known by their
prefixed names and their depends lists get rewritten so that
all dependencies get the prefix as well.
In import mode imported targets are known by an adorned as
well as a prefixed name and the unadorned target may be
overwritten in the importing build file. The depends list of
the imported targets is not modified at all. |
public void parse(Project project,
Object source) throws BuildException {
throw new BuildException("ProjectHelper.parse() must be implemented "
+ "in a helper plugin " + this.getClass().getName());
}
Parses the project file, configuring the project as it goes. |
public UnknownElement parseAntlibDescriptor(Project containingProject,
Resource source) {
throw new BuildException("can't parse antlib descriptors");
}
Parse the given URL as an antlib descriptor and return the
content as something that can be turned into an Antlib task. |
public static void parsePropertyString(String value,
Vector fragments,
Vector propertyRefs) throws BuildException {
PropertyHelper.parsePropertyStringDefault(value, fragments, propertyRefs);
} Deprecated! since - 1.6.x.
Use PropertyHelper.
|
public static String replaceProperties(Project project,
String value) throws BuildException {
// needed since project properties are not accessible
return project.replaceProperties(value);
} Deprecated! since - 1.6.x.
Use project.replaceProperties().
Replaces ${xxx} style constructions in the given value with
the string value of the corresponding properties. |
public static String replaceProperties(Project project,
String value,
Hashtable keys) throws BuildException {
PropertyHelper ph = PropertyHelper.getPropertyHelper(project);
return ph.replaceProperties(null, value, keys);
} Deprecated! since - 1.6.x.
Use PropertyHelper.
Replaces ${xxx} style constructions in the given value
with the string value of the corresponding data types. |
public static void setCurrentPrefixSeparator(String sep) {
prefixSeparator.set(sep);
}
Sets the separator between the prefix and the target name. |
public static void setCurrentTargetPrefix(String prefix) {
targetPrefix.set(prefix);
}
Sets the prefix to prepend to imported target names. |
public static void setInIncludeMode(boolean includeMode) {
inIncludeMode.set(includeMode ? Boolean.TRUE : Boolean.FALSE);
}
Sets whether the current file should be read in include as
opposed to import mode. |
public static void storeChild(Project project,
Object parent,
Object child,
String tag) {
IntrospectionHelper ih = IntrospectionHelper.getHelper(project, parent.getClass());
ih.storeElement(project, parent, child, tag);
}
Stores a configured child element within its parent object. |