From ba37bf7991e099b567f8cd5a09178893ff55bb9c Mon Sep 17 00:00:00 2001 From: Conor MacNeill Date: Sun, 4 Feb 2001 10:40:07 +0000 Subject: [PATCH] enhancement to the optional task PropertyFile. Operations can now be applied to all types. The now and never operations have become values for the = operation. Submitted by: Thomas Christen git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268576 13f79535-47bb-0310-9956-ffa450edef68 --- docs/propertyfile.html | 62 ++- .../ant/taskdefs/optional/PropertyFile.java | 527 ++++++++++++------ 2 files changed, 403 insertions(+), 186 deletions(-) diff --git a/docs/propertyfile.html b/docs/propertyfile.html index 75cd861a9..37bab1d42 100644 --- a/docs/propertyfile.html +++ b/docs/propertyfile.html @@ -10,10 +10,11 @@

by

-

Version 1.0 - 2000/11/02

+

Version 1.1 - 2001/01/28


Table of Contents

The slashes conform to the expectations of the Properties class. The file will be stored in a manner so that each character is examined and escaped if necessary. Note that the original comment is now lost. Please keep this in mind when running this task against heavily commented properties files. It may be best to have a commented version in the source tree, copy it to a deployment area, and then run the modifications on the copy. Future versions of PropertyFile will hopefully eliminate this shortcoming.

@@ -103,10 +120,35 @@ The slashes conform to the expectations of the Properties class. The file will file="my.properties" comment"My properties" > <entry key="akey" value="avalue" /> - <entry key="adate" type="date" operation="now"/> + <entry key="adate" type="date" value="now"/> <entry key="anint" type="int" operation="+"/> + <entry key="formated.int" type="int" default="0013" operation="+" pattern="0000"/> + <entry key="formated.date" type="date" value="now" pattern="DDD HH:mm"/> </propertyfile> - - + +

+To produce dates relative from today : +

<propertyfile + file="my.properties" + comment"My properties" > + <entry key="formated.date-1" + type="date" default="now" pattern="DDD" + operation="-" value="1"/> + <entry key="formated.tomorrow" + type="date" default="now" pattern="DDD" + operation="+" value="1"/> +</propertyfile> +
+

+

+Concatenation of strings : +

<propertyfile + file="my.properties" + comment"My properties" > + <entry key="progress" default="" operation="+" value="."/> +</propertyfile> +
+Each time called, a "." will be appended to "progress" +

diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java b/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java index 7d75ed50b..89ecd21c5 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000 The Apache Software Foundation. All rights + * Copyright (c) 2000-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,10 +56,12 @@ package org.apache.tools.ant.taskdefs.optional; import org.apache.tools.ant.*; +import org.apache.tools.ant.types.*; import java.io.*; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.*; +import java.text.*; /** *PropertyFile task uses java.util.Properties to modify integer, String and @@ -69,7 +71,7 @@ import java.util.*; *The following is an example of its usage: *