From af5bab224ef6c304444301d2eeebaac889e37478 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Thu, 25 Feb 2010 00:06:04 +0000 Subject: [PATCH] add prefix attribute to loadproperties task + more tests git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@916051 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 4 +- docs/manual/CoreTasks/loadproperties.html | 7 ++- .../tools/ant/taskdefs/LoadProperties.java | 14 ++++++ .../antunit/taskdefs/loadproperties-test.xml | 44 +++++++++++++++++++ 4 files changed, 67 insertions(+), 2 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 3dbdba6e4..c8ded0296 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -52,7 +52,9 @@ Other changes: Bugzilla Report 48755. * 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 ====================================== diff --git a/docs/manual/CoreTasks/loadproperties.html b/docs/manual/CoreTasks/loadproperties.html index 0f253c25c..11d68c5cd 100644 --- a/docs/manual/CoreTasks/loadproperties.html +++ b/docs/manual/CoreTasks/loadproperties.html @@ -72,6 +72,12 @@ filter.

to a <path> defined elsewhere.. No + + prefix + Prefix to apply to loaded properties; + a "." is appended to the prefix if not specified. Since Ant 1.8.1 + No +

Parameters specified as nested elements

@@ -124,4 +130,3 @@ on the fly and load the contents as Ant properties. - diff --git a/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java b/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java index 964d1db69..4357c42dc 100644 --- a/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java +++ b/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java @@ -60,6 +60,11 @@ public class LoadProperties extends Task { * Encoding to use for input; defaults to the platform's default encoding. */ private String encoding = null; + + /** + * Prefix for loaded properties. + */ + private String prefix = null; /** * Set the file to load. @@ -127,6 +132,14 @@ public class LoadProperties extends Task { 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 * @@ -174,6 +187,7 @@ public class LoadProperties extends Task { Property propertyTask = new Property(); propertyTask.bindToOwner(this); + propertyTask.setPrefix(prefix); propertyTask.addProperties(props); } } catch (final IOException ioe) { diff --git a/src/tests/antunit/taskdefs/loadproperties-test.xml b/src/tests/antunit/taskdefs/loadproperties-test.xml index fbb1c0e9e..15ae9a0e2 100644 --- a/src/tests/antunit/taskdefs/loadproperties-test.xml +++ b/src/tests/antunit/taskdefs/loadproperties-test.xml @@ -97,6 +97,50 @@ http.@SERVER@ = ${server} value="http://${server1.http.server}:${server1.http.port}"/> + + + + + + + + + + + + foo=foo +bar=bar +baz=${foo} ${bar} + + + + + + + + + + + + + + foo=foo +bar=bar +baz=${foo} ${bar} + + + + + + + + + + + + + #tpfr.a=a