Optional Task Proposal <propertyformatter>
Bug#22889 (http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22889) got me
thinking about this. At first I knocked up a quick change to allow uppercase
and lowercase with a format attribute for <property>. Then I was thinking, a
better place for this is in it's own task. So I decided to write it as it's
own task. I used the Jakarta Commons Lang project for the StringUtils and
WordUtils, since it offered a few methods that I wanted. Such as swapcase,
without re-inventing the wheel.
I figure this is best left as a optional task, since it has the requirement
on Jakarta Commons Lang. I have not yet created any tests for this, yet, but
plan on it. I also plan on fleshing out the documentation more, to include
more examples. There are quite a few other methods that StringUtils and
WordUtils offer that I would like to include, but will take a bit more time
thinking out how I should implement them.
Currently this tasks implements the following "formats": "trim", "strip",
"deletewhitespace", "chomp", "chop", "uppercase", "lowercase", "swapcase",
"capitalize", "uncapitalize", "reverse", "catitalizewords",
"capipalizewordsfully", "uncapitalizewords".
For a more detailed explanation for what each of these "formats" do, see the
documentation, and the Jakarta Commons Lang project for StringUtils and
WordUtils.
Just a note, I am not a Java programmer normally, so any hints to my code
will be appreciated. Since this all wrappers Jakarta Commons Lang stuff, all
the heavy lifted is done there. Also, I hope I got the dependency checking
right in build.xml.
All constructive criticism welcome.
-- Larry
? docs/manual/OptionalTasks/propertyformatter.html
? src/main/org/apache/tools/ant/taskdefs/optional/PropertyFormatter.java
Index: build.xml
===================================================================
RCS file: /home/cvspublic/ant/build.xml,v
retrieving revision 1.392
diff -u -r1.392 build.xml
--- build.xml 3 Sep 2003 10:01:29 -0000 1.392
+++ build.xml 5 Sep 2003 01:53:17 -0000
@@ -277,6 +277,10 @@
<filename name="${optional.package}/net/TelnetTask*"/>
</or>
</selector>
+
+ <selector id="needs.commons.lang">
+ <filename name="${optional.package}/PropertyFormatter*"/>
+ </selector>
<selector id="needs.starteam">
<or>
@@ -410,6 +414,9 @@
<available property="commons.net.present"
classname="org.apache.commons.net.ftp.FTPClient"
classpathref="classpath"/>
+ <available property="commons.lang.present"
+ classname="org.apache.commons.lang.StringUtils"
+ classpathref="classpath"/>
<available property="starteam.present"
classname="com.starbase.util.Platform"
classpathref="classpath"/>
@@ -630,6 +637,7 @@
unless="ejb.DDCreator.present"/>
<selector refid="needs.weblogic.server" unless="ejb.wls.present"/>
<selector refid="needs.commons.net" unless="commons.net.present"/>
+ <selector refid="needs.commons.lang"
unless="commons.lang.present"/>
<selector refid="needs.starteam" unless="starteam.present"/>
<selector refid="needs.vaj" unless="vaj.present"/>
<selector refid="needs.antlr" unless="antlr.present"/>
@@ -805,6 +813,7 @@
<selector refid="needs.weblogic.ddcreator"/>
<selector refid="needs.weblogic.server"/>
<selector refid="needs.commons.net"/>
+ <selector refid="needs.commons.lang"/>
<selector refid="needs.starteam"/>
<selector refid="needs.vaj"/>
<selector refid="needs.antlr"/>
@@ -917,6 +926,12 @@
basedir="${build.classes}"
manifest="${manifest.tmp}">
<selector refid="needs.commons.net"/>
+ </jar>
+
+ <jar destfile="${build.lib}/${optional.jars.prefix}-commons-lang.jar"
+ basedir="${build.classes}"
+ manifest="${manifest.tmp}">
+ <selector refid="needs.commons.lang"/>
</jar>
<jar destfile="${build.lib}/${optional.jars.prefix}-starteam.jar"
Index: docs/manual/install.html
===================================================================
RCS file: /home/cvspublic/ant/docs/manual/install.html,v
retrieving revision 1.59
diff -u -r1.59 install.html
--- docs/manual/install.html 3 Sep 2003 07:58:04 -0000 1.59
+++ docs/manual/install.html 5 Sep 2003 01:53:18 -0000
@@ -399,6 +399,12 @@
target="_top">http://jakarta.apache.org/commons/net/index.html</a></td>
</tr>
<tr>
+ <td>commons-lang.jar</td>
+ <td>propertyformatter</td>
+ <td><a href="http://jakarta.apache.org/commons/lang.html"
+ target="_top">http://jakarta.apache.org/commons/lang.html</a></td>
+ </tr>
+ <tr>
<td>bcel.jar</td>
<td>classfileset data type,
JavaClassHelper used by the ClassConstants filter reader and
Index: docs/manual/optionaltasklist.html
===================================================================
RCS file: /home/cvspublic/ant/docs/manual/optionaltasklist.html,v
retrieving revision 1.39
diff -u -r1.39 optionaltasklist.html
--- docs/manual/optionaltasklist.html 23 Jul 2003 14:12:11 -0000 1.39
+++ docs/manual/optionaltasklist.html 5 Sep 2003 01:53:18 -0000
@@ -51,6 +51,7 @@
<a href="OptionalTasks/netrexxc.html">NetRexxC</a><br>
<a href="OptionalTasks/perforce.html">Perforce Tasks</a><br>
<a href="OptionalTasks/propertyfile.html">PropertyFile</a><br>
+<a href="OptionalTasks/propertyformatter.html">PropertyFormatter</a><br>
<a href="OptionalTasks/pvcstask.html">Pvcs</a><br>
<a href="OptionalTasks/renameextensions.html"><i>RenameExtensions</i></a><br>
<a href="OptionalTasks/replaceregexp.html">ReplaceRegExp</a><br>
Index: src/main/org/apache/tools/ant/taskdefs/defaults.properties
===================================================================
RCS file:
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties,v
retrieving revision 1.152
diff -u -r1.152 defaults.properties
--- src/main/org/apache/tools/ant/taskdefs/defaults.properties 14 Aug 2003
12:46:01 -0000 1.152
+++ src/main/org/apache/tools/ant/taskdefs/defaults.properties 5 Sep 2003
01:53:28 -0000
@@ -196,6 +196,7 @@
jsharpc=org.apache.tools.ant.taskdefs.optional.dotnet.JSharp
rexec=org.apache.tools.ant.taskdefs.optional.net.RExecTask
scriptdef=org.apache.tools.ant.taskdefs.optional.script.ScriptDef
+propertyformatter=org.apache.tools.ant.taskdefs.optional.PropertyFormatter
# deprecated ant tasks (kept for back compatibility)
starteam=org.apache.tools.ant.taskdefs.optional.scm.AntStarTeamCheckOut
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]