True, I could execute a simple groovy script using java.util.regex via the ant 
<exec> task.  I was able to get the 'sh -c' option working, as suggested 
previously, but I'll keep this in mind.

-- Jeff



On Aug 16, 2012, at 7:55 AM, Martin Gainty wrote:

> 
> Good Advice from the Employees at Lexmark!
> 
> I found java.util.regex package is quite useful for regular expression 
> matching ..here is a simple example you can use
> java.util.regex.Pattern p = java.util.regex.Pattern.compile("a*b");
> java.util.regex.Matcher m = p.matcher("aaaaab");
> boolean b = m.matches();Information available at
> http://docs.oracle.com/javase/6/docs/api/
> 
> if brevity is your strength you may consider combining java.util.Pattern and 
> Matcher in a one line statement such as
> boolean b = Pattern.matches("a*b", "aaaaab");Then create your custom taskdef 
> with a Class which extends org.apache.tools.ant.Task
> http://ant.apache.org/manual/develop.html
> 
> HTH
> Martin 
> ______________________________________________ 
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
> 
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
> sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
> oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich 
> dem Austausch von Informationen und entfaltet keine rechtliche 
> Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen 
> wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
> destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
> l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci 
> est interdite. Ce message sert à l'information seulement et n'aura pas 
> n'importe quel effet légalement obligatoire. Étant donné que les email 
> peuvent facilement être sujets à la manipulation, nous ne pouvons accepter 
> aucune responsabilité pour le contenu fourni.
> 
> 
>> Date: Thu, 16 Aug 2012 07:51:39 -0400
>> Subject: Re: Trying to execute 'grep'
>> From: hput...@lexmark.com
>> To: user@ant.apache.org
>> 
>> Jeff,
>> You might be able to do this natively within ant
>> 
>> This is how it could work for a single file:
>> <target name="test-failure-check">
>>  <local name="error.found"/>
>>  <loadfile property="error.found"
>> srcfile="${home.dir}/runtime/logs/test-results/file.xml">
>> <filterchain>
>> <linecontainsregexp>
>> <regexp pattern="failure"/>
>> </linecontainsregexp>
>> </filterchain>
>>  </loadfile>
>>  <fail message="Unit test failure(s)" unless="error.found"/>
>> </target>
>> 
>> Doing this this with *.xml is left as an exercise for the reader :-)
>> 
>> Harold
>> 
>> On Wed, Aug 15, 2012 at 6:56 PM, Jeff Lowery <jef...@mavericklabel.com>wrote:
>> 
>>> Have the following target:
>>> 
>>> <target name="test-failure-check">
>>>                <exec executable="grep">
>>>                        <arg line="failure
>>> ${home.dir}/runtime/logs/test-results/*.xml" />
>>>                        <redirector outputproperty="grep.out" />
>>>                </exec>
>>>                <echo message="grep.out='${grep.out}'" />
>>> 
>>>                <fail message="Unit test failure(s)">
>>>                        <condition>
>>>                                <not>
>>>                                        <equals arg1="${grep.out}" arg2=""
>>> />
>>>                                </not>
>>>                        </condition>
>>>                </fail>
>>> </target>
>>> 
>>> and getting the following echo:
>>> 
>>> [echo] grep.out='grep:
>>> /Users/jeff.l/Documents/workspace/homedir/runtime/logs/test-results/*.xml:
>>> No such file or directory'
>>> 
>>> yet if I execute "grep failure
>>> /Users/jeff.l/Documents/workspace/homedir/runtime/logs/test-results/*.xml",
>>> from the command line, I get results back.
>>> 
>>> 
>>> -- Jeff
>>> 
>>> 
>>> 
>>> 
>> 
>> 
>> -- 
>> Harold PUTMAN
>> Web Technology Specialist
>> *Lexmark International, Inc. <http://www.lexmark.com>*
>> 740 W New Circle Rd.
>> Lexington, KY 40550
>> +1(859) 232-2839
>> hput...@lexmark.com
>                                         

Reply via email to