|
|
@@ -43,69 +43,85 @@ import org.apache.tools.ant.types.EnumeratedAttribute; |
|
|
|
import org.apache.tools.ant.util.FileUtils; |
|
|
|
|
|
|
|
/** |
|
|
|
*Modifies settings in a property file. |
|
|
|
* Modifies settings in a property file. |
|
|
|
* |
|
|
|
* <p> |
|
|
|
*The following is an example of its usage: |
|
|
|
* <ul><target name="setState"><br> |
|
|
|
* <ul><property<br> |
|
|
|
* <ul>name="header"<br> |
|
|
|
* value="##Generated file - do not modify!"/><br> |
|
|
|
* <propertyfile file="apropfile.properties" comment="${header}"><br> |
|
|
|
* <entry key="product.version.major" type="int" value="5"/><br> |
|
|
|
* <entry key="product.version.minor" type="int" value="0"/><br> |
|
|
|
* <entry key="product.build.major" type="int" value="0" /><br> |
|
|
|
* <entry key="product.build.minor" type="int" operation="+" /><br> |
|
|
|
* <entry key="product.build.date" type="date" value="now" /><br> |
|
|
|
* <entry key="intSet" type="int" operation="=" value="681"/><br> |
|
|
|
* <entry key="intDec" type="int" operation="-"/><br> |
|
|
|
* <entry key="StringEquals" type="string" value="testValue"/><br> |
|
|
|
* </propertyfile><br></ul> |
|
|
|
* </target></ul><p> |
|
|
|
* <p>The following is an example of its usage:</p> |
|
|
|
* <pre> |
|
|
|
* <target name="setState"> |
|
|
|
* <property |
|
|
|
* name="header" |
|
|
|
* value="##Generated file - do not modify!"/> |
|
|
|
* <propertyfile file="apropfile.properties" comment="${header}"> |
|
|
|
* <entry key="product.version.major" type="int" value="5"/> |
|
|
|
* <entry key="product.version.minor" type="int" value="0"/> |
|
|
|
* <entry key="product.build.major" type="int" value="0" /> |
|
|
|
* <entry key="product.build.minor" type="int" operation="+" /> |
|
|
|
* <entry key="product.build.date" type="date" value="now" /> |
|
|
|
* <entry key="intSet" type="int" operation="=" value="681"/> |
|
|
|
* <entry key="intDec" type="int" operation="-"/> |
|
|
|
* <entry key="StringEquals" type="string" value="testValue"/> |
|
|
|
* </propertyfile> |
|
|
|
* </target> |
|
|
|
* </pre> |
|
|
|
* |
|
|
|
*The <propertyfile> task must have:<br> |
|
|
|
* <ul><li>file</li></ul> |
|
|
|
*Other parameters are:<br> |
|
|
|
* <ul><li>comment, key, operation, type and value (the final four being |
|
|
|
* eliminated shortly)</li></ul> |
|
|
|
* The <propertyfile> task must have: |
|
|
|
* <ul> |
|
|
|
* <li>file</li> |
|
|
|
* </ul> |
|
|
|
* Other parameters are: |
|
|
|
* <ul> |
|
|
|
* <li>comment</li> |
|
|
|
* <li>key</li> |
|
|
|
* <li>operation</li> |
|
|
|
* <li>type</li> |
|
|
|
* <li>value (the final four being eliminated shortly)</li> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
*The <entry> task must have:<br> |
|
|
|
* <ul><li>key</li></ul> |
|
|
|
*Other parameters are:<br> |
|
|
|
* <ul><li>operation</li> |
|
|
|
* <li>type</li> |
|
|
|
* <li>value</li> |
|
|
|
* <li>default</li> |
|
|
|
* <li>unit</li> |
|
|
|
* </ul> |
|
|
|
* The <entry> task must have: |
|
|
|
* <ul> |
|
|
|
* <li>key</li> |
|
|
|
* </ul> |
|
|
|
* Other parameters are: |
|
|
|
* <ul> |
|
|
|
* <li>operation</li> |
|
|
|
* <li>type</li> |
|
|
|
* <li>value</li> |
|
|
|
* <li>default</li> |
|
|
|
* <li>unit</li> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
*If type is unspecified, it defaults to string |
|
|
|
* If type is unspecified, it defaults to string. |
|
|
|
* |
|
|
|
*Parameter values:<br> |
|
|
|
* <ul><li>operation:</li> |
|
|
|
* <ul><li>"=" (set -- default)</li> |
|
|
|
* <li>"-" (dec)</li> |
|
|
|
* <li>"+" (inc)</li> |
|
|
|
* |
|
|
|
* <li>type:</li> |
|
|
|
* <ul><li>"int"</li> |
|
|
|
* <li>"date"</li> |
|
|
|
* <li>"string"</li></ul></ul> |
|
|
|
* |
|
|
|
* <li>value:</li> |
|
|
|
* <ul><li>holds the default value, if the property |
|
|
|
* Parameter values: |
|
|
|
* <ul> |
|
|
|
* <li>operation:</li> |
|
|
|
* <ul> |
|
|
|
* <li>"=" (set -- default)</li> |
|
|
|
* <li>"-" (dec)</li> |
|
|
|
* <li>"+" (inc)</li> |
|
|
|
* </ul> |
|
|
|
* <li>type:</li> |
|
|
|
* <ul> |
|
|
|
* <li>"int"</li> |
|
|
|
* <li>"date"</li> |
|
|
|
* <li>"string"</li> |
|
|
|
* </ul> |
|
|
|
* <li>value:</li> |
|
|
|
* <ul> |
|
|
|
* <li>holds the default value, if the property |
|
|
|
* was not found in property file</li> |
|
|
|
* <li>"now" In case of type "date", the |
|
|
|
* <li>"now" In case of type "date", the |
|
|
|
* value "now" will be replaced by the current |
|
|
|
* date/time and used even if a valid date was |
|
|
|
* found in the property file.</li></ul> |
|
|
|
* |
|
|
|
* found in the property file.</li> |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
*String property types can only use the "=" operation. |
|
|
|
*Int property types can only use the "=", "-" or "+" operations.<p> |
|
|
|
* <p>String property types can only use the "=" operation. |
|
|
|
* Int property types can only use the "=", "-" or "+" operations.<p> |
|
|
|
* |
|
|
|
*The message property is used for the property file header, with "\\" being |
|
|
|
*a newline delimiter character. |
|
|
|
* The message property is used for the property file header, with "\\" being |
|
|
|
* a newline delimiter character. |
|
|
|
* |
|
|
|
*/ |
|
|
|
public class PropertyFile extends Task { |
|
|
|