git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@916051 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -52,7 +52,9 @@ Other changes: | |||||
| Bugzilla Report 48755. | Bugzilla Report 48755. | ||||
| * Add removeKeepExtension option to NetRexxC task. | * Add removeKeepExtension option to NetRexxC task. | ||||
| Bugzilla Report 48788. | |||||
| Bugzilla Report 48788. | |||||
| * Add prefix attribute to loadproperties task. | |||||
| Changes from Ant 1.8.0RC1 TO Ant 1.8.0 | Changes from Ant 1.8.0RC1 TO Ant 1.8.0 | ||||
| ====================================== | ====================================== | ||||
| @@ -72,6 +72,12 @@ filter.</p> | |||||
| to a <code><path></code> defined elsewhere..</td> | to a <code><path></code> defined elsewhere..</td> | ||||
| <td align="center" valign="top">No</td> | <td align="center" valign="top">No</td> | ||||
| </tr> | </tr> | ||||
| <tr> | |||||
| <td valign="top">prefix</td> | |||||
| <td valign="top">Prefix to apply to loaded properties; | |||||
| a "." is appended to the prefix if not specified. <em>Since Ant 1.8.1</em></td> | |||||
| <td align="center" valign="top">No</td> | |||||
| </tr> | |||||
| </table> | </table> | ||||
| <h3>Parameters specified as nested elements</h3> | <h3>Parameters specified as nested elements</h3> | ||||
| @@ -124,4 +130,3 @@ on the fly and load the contents as Ant properties. | |||||
| </body> | </body> | ||||
| </html> | </html> | ||||
| @@ -60,6 +60,11 @@ public class LoadProperties extends Task { | |||||
| * Encoding to use for input; defaults to the platform's default encoding. | * Encoding to use for input; defaults to the platform's default encoding. | ||||
| */ | */ | ||||
| private String encoding = null; | private String encoding = null; | ||||
| /** | |||||
| * Prefix for loaded properties. | |||||
| */ | |||||
| private String prefix = null; | |||||
| /** | /** | ||||
| * Set the file to load. | * Set the file to load. | ||||
| @@ -127,6 +132,14 @@ public class LoadProperties extends Task { | |||||
| return getRequiredJavaResource().getClasspath(); | return getRequiredJavaResource().getClasspath(); | ||||
| } | } | ||||
| /** | |||||
| * Set the prefix to load these properties under. | |||||
| * @param prefix to set | |||||
| */ | |||||
| public void setPrefix(String prefix) { | |||||
| this.prefix = prefix; | |||||
| } | |||||
| /** | /** | ||||
| * load Ant properties from the source file or resource | * load Ant properties from the source file or resource | ||||
| * | * | ||||
| @@ -174,6 +187,7 @@ public class LoadProperties extends Task { | |||||
| Property propertyTask = new Property(); | Property propertyTask = new Property(); | ||||
| propertyTask.bindToOwner(this); | propertyTask.bindToOwner(this); | ||||
| propertyTask.setPrefix(prefix); | |||||
| propertyTask.addProperties(props); | propertyTask.addProperties(props); | ||||
| } | } | ||||
| } catch (final IOException ioe) { | } catch (final IOException ioe) { | ||||
| @@ -97,6 +97,50 @@ http.@SERVER@ = ${server} | |||||
| value="http://${server1.http.server}:${server1.http.port}"/> | value="http://${server1.http.server}:${server1.http.port}"/> | ||||
| </target> | </target> | ||||
| <target name="testLineCommentsWithoutFiltering"> | |||||
| <loadproperties> | |||||
| <string value="#foo=bar" /> | |||||
| </loadproperties> | |||||
| <au:assertFalse> | |||||
| <isset property="foo" /> | |||||
| </au:assertFalse> | |||||
| </target> | |||||
| <target name="testPrefixAttributeProperties"> | |||||
| <loadproperties prefix="prefixFromAttribute."> | |||||
| <string>foo=foo | |||||
| bar=bar | |||||
| baz=${foo} ${bar} | |||||
| </string> | |||||
| </loadproperties> | |||||
| <au:assertTrue> | |||||
| <and> | |||||
| <equals arg1="foo" arg2="${prefixFromAttribute.foo}" /> | |||||
| <equals arg1="bar" arg2="${prefixFromAttribute.bar}" /> | |||||
| <equals arg1="foo bar" arg2="${prefixFromAttribute.baz}" /> | |||||
| </and> | |||||
| </au:assertTrue> | |||||
| </target> | |||||
| <target name="testSelfContainedPrefixFilterFailure" | |||||
| description="Show why the prefix attribute is needed"> | |||||
| <loadproperties> | |||||
| <string>foo=foo | |||||
| bar=bar | |||||
| baz=${foo} ${bar} | |||||
| </string> | |||||
| <filterchain> | |||||
| <prefixlines prefix="prefixFromFilter." /> | |||||
| </filterchain> | |||||
| </loadproperties> | |||||
| <au:assertTrue> | |||||
| <and> | |||||
| <equals arg1="$${foo} $${bar}" arg2="${prefixFromFilter.baz}" /> | |||||
| <isset property="prefixFromFilter." /> | |||||
| </and> | |||||
| </au:assertTrue> | |||||
| </target> | |||||
| <target name="write properties.tmp" depends="setUp"> | <target name="write properties.tmp" depends="setUp"> | ||||
| <echo file="${properties.tmp}"> | <echo file="${properties.tmp}"> | ||||
| #tpfr.a=a | #tpfr.a=a | ||||