ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Golan Derazon <gdera...@mercury.com>
Subject RE: Adding a new Condition
Date Mon, 13 Dec 2004 20:50:09 GMT
Thanks for the fast and detailed reply.
It looks like the 'containsregexp' selector answers
my needs.
I will look into making the enhancements you suggested.



_______________________________	 
Golan Derazon,  gderazon@mercury.com
direct 972 - 3 - 5399780  fax 972 -3 -5331617	 
www.mercury.com	 
 

-----Original Message-----
From: Peter Reilly [mailto:peterreilly@apache.org] 
Sent: Monday, December 13, 2004 9:27 PM
To: Golan Derazon; Ant Developers List
Subject: Re: Adding a new Condition

Hi Golan,

Thanks for the condition.
To contribute to ant, one should always try the dev@ant.apache.org list to
show new tasks.
and user@ant.apache.org to test for user interest.

A new task/type may get into ant or into an associated project (like
ant-contrib), new tasks outside of core file activity will be difficult to
add.

A new condition has been added to ant cvs recently which will cover your
condition (at least the single file case) <isfileselected file="x.txt">
    <containsregexp expression="[4-6]\.[0-9]"/> </isfileselected>

However, containsregexp does not allow all the options provided by your
condition, and its documentation is a little lacking, so I think that it
would be nice to enchance the containsregexp selector and fix its
documentation.


Also, <isfileselected> could allow a fileset as nested element in the same
way as your condition, maybe with an attribute, like number selected, or
amount="some, all, any.

Peter


Golan Derazon wrote:

>Peter hi,
>
>I have written a new condition - fileregexp.
>
>"ReplaceRegExp is a directory based condition that checks whether a 
>given regular expression pattern is matched in a selected file or set of
files.
>The condition was created to enable waiting for an expression in a 
>file. For example, when waiting for an application to start in many 
>cases it is easy to wait for a specific message in the application's log
file. "
>
>It's the first time I contribute to an apache project and I'm not sure 
>how to proceed.
>If I understood correctly the next stage is to discuss the proposal in 
>a wider forum.
>Please instruct.
>
>Thank,
> 
>_______________________________	
>Golan Derazon,  gderazon@mercury.com
>direct 972 - 3 - 5399780  fax 972 -3 -5331617	
>www.mercury.com <http://www.mercury.com/> 	
> 
>
>
>
>______________________________________________________________________
>This email has been scanned by the MessageLabs Email Security System.
>For more information please visit http://www.messagelabs.com/email 
>______________________________________________________________________
>
>
> ----------------------------------------------------------------------
> --
>
>
>     FileRegExp
>
>
>       Description
>
> ReplaceRegExp is a directory based condition that checks the whether a 
> given regular expression pattern is matched in a selected file or set 
> of files.
> Condition was created to enable waiting for an expression in a file. 
> For example, when waiting for an application to start in many cases it 
> is easy to wait for a specific message in the application's log file.
>
> Similar to regexp type mappers
> <../CoreTypes/mapper.html#regexp-mapper> this task needs a supporting 
> regular expression library and an implementation of
> |org.apache.tools.ant.util.regexp.Regexp|. See details below
> <#implementation>.
>
>
>       Parameters
>
> *Attribute* 	*Description* 	*Required*
> file 	file in which the regular expression should be matched 	Yes if 
> no nested <fileset> is used
> match 	The regular expression pattern to match in the file(s) 	Yes
>   	  	 
> flags 	The flags to use when matching the regular expression. For
more 
> information, consult the Perl5 syntax
> g : Global replacement. Replace all occurences found i : Case 
> Insensitive. Do not consider case in the match m : Multiline. Treat 
> the string as multiple lines of input, using "^"
> and "$" as the start or end of any line, respectively, rather than 
> start or end of string.
> s : Singleline. Treat the string as a single line of input, using "." 
> to match any character, including a newline, which normally, it would 
> not match.
> 	No
>   	  	No
> encoding 	The encoding of the file. 	No - defaults to default JVM

> encoding
>
>
>       Examples
>
> <condition property="myProperty" value="true">
>      <fileregexp match="regexptomatch" file="fileToLookForMatch.txt" 
> flags="i"/>
> </condition>
>
> Creates the property myProperty and sets its value to true if 
> regexptomatch is matched in  fileToLookForMatch.txt.
>
>
>       Choice of regular expression implementation
>
> Ant comes with wrappers for the java.util.regex package of JDK 1.4 
> <http://java.sun.com/j2se/1.4/docs/api/java/util/regex/package-summary
> .html>, jakarta-regexp <http://jakarta.apache.org/regexp/> and 
> jakarta-ORO <http://jakarta.apache.org/oro/>, See installation 
> dependencies <../install.html#librarydependencies> concerning the 
> supporting libraries.
>
> The system property |ant.regexp.regexpimpl| governs which regular 
> expression implementation will be chosen. Possible values for this 
> property are :
>
>     * org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp
>     * org.apache.tools.ant.util.regexp.JakartaOroRegexp
>     * org.apache.tools.ant.util.regexp.JakartaRegexpRegexp
>
> It can also be another implementation of the interface
> |org.apache.tools.ant.util.regexp.Regexp|. If |ant.regexp.regexpimpl|
> is not defined, ant checks in the order Jdk14Regexp, JakartaOroRegexp, 
> JakartaRegexp for the availability of the corresponding library. The 
> first of these 3 which is found will be used.
>
> There are cross-platform issues for matches related to line 
> terminator. For example if you use $ to anchor your regular expression 
> on the end of a line the results might be very different depending on 
> both your platform and the regular expression library you use. It is 
> 'highly recommended' that you test your pattern on both Unix and 
> Windows platforms before you rely on it.
>
>     * Jakarta Oro defines a line terminator as '\n' and is consistent
>       with Perl.
>     * Jakarta RegExp uses a system-dependant line terminator.
>     * JDK 1.4 uses '\n', '\r\n', '\u0085', '\u2028', '\u2029' as a
>       default but is configured in the wrapper to use only '\n'
>       (UNIX_LINE)
>
> /We *strongly* recommend that you use Jakarta Oro./
>
>
>       Parameters specified as nested elements
>
> This condition supports a nested FileSet <../CoreTypes/fileset.html> 
> element.
>
>
>       Examples
>
> <condition property="myProperty" value="true">
>      <fileregexp match="regexptomatch">
>         <fileset dir=".">
>             <include name="*.log*"></include>
>         </fileset>
>     </fileregexp>
> </condition>
>
> Creates the property myProperty and sets its value to true if 
> regexptomatch is matched in  one of the files in the file set.
>
> ----------------------------------------------------------------------
> --
>
> Copyright (c) 2001-2004 The Apache Software Foundation. All rights
Reserved.
>

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message