Attribute "destfile" defines a file to send the properties to. This can be processed as a standard property file later.
Attribute "prefix" defines a prefix which is used to filter the properties only those properties starting with this prefix will be echoed.
By default, the "failonerror" attribute is enabled. If an error occurs while writing the properties to a file, and this attribute is enabled, then a BuildException will be thrown. If disabled, then IO errors will be reported as a log statement, but no error will be thrown.
Examples:
<echoproperties />Report the current properties to the log.
<echoproperties destfile="my.properties" />Report the current properties to the file "my.properties", and will fail the build if the file could not be created or written to.
<echoproperties destfile="my.properties" failonerror="false" prefix="ant" />Report all properties beginning with 'ant' to the file "my.properties", and will log a message if the file could not be created or written to, but will still allow the build to continue.
Modifier and Type | Class and Description |
---|---|
public static class | EchoProperties.FormatAttribute
A enumerated type for the format attribute. |
private static class | EchoProperties.Tuple
a tuple for the sort list. |
Modifier and Type | Field and Description |
---|---|
private static final String | ATTR_NAME
name attribute for property, testcase and testsuite elements. |
private static final String | ATTR_VALUE
value attribute for property elements. |
private File | destfile
File object pointing to the output file. |
private boolean | failonerror
If this is true, then errors generated during file output will become build errors, and if false, then such errors will be logged, but not thrown. |
private String | |
private File | inFile
the input file. |
private String | |
private static final String | PROPERTIES
the properties element. |
private static final String | PROPERTY
the property element. |
private List | |
private String |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public void | |
private OutputStream | |
public void | |
private static DocumentBuilder | Returns: The DocumentBuilder instanceUses the DocumentBuilderFactory to get a DocumentBuilder instance. |
protected void | jdkSaveProperties(Properties
the properties to record props, OutputStream record the properties to this output stream os, String prepend this header to the property output header)JDK 1.2 allows for the safer method
|
protected void | saveProperties(Hashtable<Object, Object>
propfile to save allProps, OutputStream output stream os)Send the key/value pairs in the hashtable to the given output stream. |
public void | |
public void | setFailOnError(boolean
true if IO exceptions are reported as build
exceptions, or false if IO exceptions are ignored.If true, the task will fail if an error occurs writing the properties file, otherwise errors are just logged. |
public void | setFormat(EchoProperties.
an enumerated eaFormatAttribute valueSet the output format - xml or text. |
public void | |
public void | |
public void | |
private List | |
protected void | xmlSaveProperties(Properties
the properties to save props, OutputStream the output stream to write to (Note this gets closed) os)Output the properties as xml output. |
ATTR_NAME | back to summary |
---|---|
private static final String ATTR_NAME name attribute for property, testcase and testsuite elements. |
ATTR_VALUE | back to summary |
---|---|
private static final String ATTR_VALUE value attribute for property elements. |
destfile | back to summary |
---|---|
private File destfile File object pointing to the output file. If this is null, then we output to the project log, not to a file. |
failonerror | back to summary |
---|---|
private boolean failonerror If this is true, then errors generated during file output will become build errors, and if false, then such errors will be logged, but not thrown. |
format | back to summary |
---|---|
private String format |
inFile | back to summary |
---|---|
private File inFile the input file. |
prefix | back to summary |
---|---|
private String prefix |
PROPERTIES | back to summary |
---|---|
private static final String PROPERTIES the properties element. |
PROPERTY | back to summary |
---|---|
private static final String PROPERTY the property element. |
propertySets | back to summary |
---|---|
private List<PropertySet> propertySets |
regex | back to summary |
---|---|
private String regex
|
EchoProperties | back to summary |
---|---|
public EchoProperties() |
addPropertyset | back to summary |
---|---|
public void addPropertyset(PropertySet ps) A set of properties to write.
|
createOutputStream | back to summary |
---|---|
private OutputStream createOutputStream() throws IOException |
execute | back to summary |
---|---|
public void execute() throws BuildException Overrides org. Run the task.
|
getDocumentBuilder | back to summary |
---|---|
private static DocumentBuilder getDocumentBuilder() Uses the DocumentBuilderFactory to get a DocumentBuilder instance.
|
jdkSaveProperties | back to summary |
---|---|
protected void jdkSaveProperties(Properties props, OutputStream os, String header) throws IOException JDK 1.2 allows for the safer method
|
saveProperties | back to summary |
---|---|
protected void saveProperties(Hashtable<Object, Object> allProps, OutputStream os) throws IOException, BuildException Send the key/value pairs in the hashtable to the given output stream.
Only those properties matching the
|
setDestfile | back to summary |
---|---|
public void setDestfile(File destfile) Set a file to store the property output. If this is never specified, then the output will be sent to the Ant log.
|
setFailOnError | back to summary |
---|---|
public void setFailOnError(boolean failonerror) If true, the task will fail if an error occurs writing the properties file, otherwise errors are just logged.
|
setFormat | back to summary |
---|---|
public void setFormat(EchoProperties. Set the output format - xml or text.
|
setPrefix | back to summary |
---|---|
public void setPrefix(String prefix) If the prefix is set, then only properties which start with this
prefix string will be recorded. If regex is not set and if this
is never set, or it is set to an empty string or For example, if the attribute is set as: <echoproperties prefix="ant." />then the property "ant.home" will be recorded, but "ant-example" will not.
|
setRegex | back to summary |
---|---|
public void setRegex(String regex) If the regex is set, then only properties whose names match it
will be recorded. If prefix is not set and if this is never set,
or it is set to an empty string or For example, if the attribute is set as: <echoproperties prefix=".*ant.*" />then the properties "ant.home" and "user.variant" will be recorded, but "ant-example" will not.
|
setSrcfile | back to summary |
---|---|
public void setSrcfile(File file) Sets the input file.
|
sortProperties | back to summary |
---|---|
private List |
xmlSaveProperties | back to summary |
---|---|
protected void xmlSaveProperties(Properties props, OutputStream os) throws IOException Output the properties as xml output.
|
Modifier and Type | Field and Description |
---|---|
private String[] |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public String[] | Returns: accepted valuesImplements abstract org. |
formats | back to summary |
---|---|
private String[] formats |
FormatAttribute | back to summary |
---|---|
public FormatAttribute() |
getValues | back to summary |
---|---|
public String[] getValues() Implements abstract org. Doc from org. This is the only method a subclass needs to implement.
|
Modifier and Type | Method and Description |
---|---|
public int | Returns: a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.the Object to be compared. oImplements java. |
public boolean | equals(Object
the reference object with which to compare. o)Overrides java. |
public int |
Tuple | back to summary |
---|---|
private Tuple(String key, String value) |
compareTo | back to summary |
---|---|
public int compareTo(EchoProperties. Implements java. Compares this object with the specified object for order.
|
equals | back to summary |
---|---|
public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. |
hashCode | back to summary |
---|---|
public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
|