ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Weintraub" <qazw...@gmail.com>
Subject Re: an input for ant arg.
Date Thu, 10 Jan 2008 18:07:45 GMT
What about creating a <loadfile> task with a few <filtersets>?
Loadfile places the content of a file into a property. The
<filterchain> acts on the contents of that file. I load the file
input.sql into the property ${sql.line}. But, I add three filter
chains. The first filters out all lines except the one I am looking
for. The second transforms that line by removing the beginning and
trailing ends of the line, leaving only the middle you want.  I also
had to add one more to strip out the linefeed on the end of the line.

<project name="test" default="test" basedir=".">
    <target name="test">
        <loadfile
            srcfile="input.sql"
            property="sql.line">
            <filterchain>
                <linecontainsregexp>
                    <regexp pattern="where keyp_clientid in .*--Second Wave"/>
                </linecontainsregexp>
                <tokenfilter>
                    <filetokenizer/>
                        <replaceregex pattern="^where keyp_clientid in
.*(\(.*\)).*$" replace="\1"/>
                </tokenfilter>
                <striplinebreaks/>
            </filterchain>
        </loadfile>
        <echo message="Line is &quot;${sql.line}&quot;"/>
    </target>
</project>

What's nice about this is that it depends upon no operating specific
<exec> tasks, or outside ant tasks.

On Jan 9, 2008 5:00 PM, Chun Ji <CJi@pro-unlimited.com> wrote:
>
> Hi all,
>
> I have a file: "input.sql" which contans a line as:
> "
> ...
> where keyp_clientid in (7,32,113,33) --Second Wave
> ..
> ",
>
> And I need this " (7, 32, 113, 33)" as an input string to excute a java class, and that
is command line I use on my linux box, and it works,
> "
> java Test `grep "^where keyp_clientid in" input.sql | awk '{print $4}'`
>
> ".
>
>
>
> Now the question is how can I use this command line in an Ant Makefile to get the same
results? Here is what I did in my "build.xml" and it fails:
> "
> ...
>    <target name="migration">
>       <exec executable="java" dir=".">
>             <arg line="..."/>
>           <arg line="Test `grep "^where keyp_clientid in" input.sql | awk '{print
$4}'` "/>
>       </exec>
>       <xslt .../>
>    </target>
> ...
> "
> The error msg is: Element type "arg" must be followed by either attribute specifications,
">" or "/>"
>
>
>
> So what should I do to solve this issue ? Any comments is welcome!
>
>
>
> thanks a lot,
>
>
>
> Chun
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>



-- 
--
David Weintraub
qazwart@gmail.com

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


Mime
View raw message