You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Rich Mauri <rm...@callidussoftware.com> on 2004/03/30 02:38:11 UTC

RE: [BULK] - Re: [BULK] - finding the absolute path of each file in a fileset

Somewhere you're defining deploy.dir as a property.

One way is to set another property using location= prior to the
replaceregexp task.
For example,

<antcall target="doregexp"/>

<target name=doregexp">
    <property name="deploy.absdir" location="${deploy.dir}"/>

    <replaceregexp byline="true" flags="gi">
      <regexp pattern="pattern1"/>
      <substitution expression="pattern2"/>
      <fileset dir="${deploy.absdir}/components">
          <include name="**/*.xsl"/>
      </fileset>
    </replaceregexp>
</target>


-----Original Message-----
From: Shakun Mahajan [mailto:shakun@customercaresolutions.com] 
Sent: Monday, March 29, 2004 4:32 PM
To: Ant Users List
Subject: [BULK] - Re: [BULK] - finding the absolute path of each file in
a fileset


Hi Rich,

Sorry could not understand you.
my regex is like this :-
  <replaceregexp byline="true" flags="gi">
    <regexp pattern="pattern1"/>
    <substitution expression="pattern2"/>
   <fileset dir="${deploy.dir}/components">
     <include name="**/*.xsl"/>
    </fileset>
  </replaceregexp>

I need to figure out the path of each .xsl file and do an appropriate
substitution. How can I utilize your suggestion here?

Regards,

Shakun

----- Original Message ----- 
From: "Rich Mauri" <rm...@callidussoftware.com>
To: "Ant Users List" <us...@ant.apache.org>
Sent: Monday, March 29, 2004 4:15 PM
Subject: RE: [BULK] - finding the absolute path of each file in a
fileset


> You can use property location trick for example:
>
> <property name="abspathtofile" location="${relpathtofile}"/>
>
> -----Original Message-----
> From: Shakun Mahajan [mailto:shakun@customercaresolutions.com]
> Sent: Monday, March 29, 2004 4:11 PM
> To: Ant Users List
> Subject: [BULK] - finding the absolute path of each file in a fileset
>
>
> Hi all,
>
> I am using Ant (1.5.3) provided with Eclipse(2.1.3).
>
> After I deploy, I need to change a few files by replacing the paths of

> the included files. I have used the Ant task "Replaceregexp" to do the

> replace. However, for a particular case, I need to know the absolute 
> path of the file in the filesystem(For e.g. for a file "xyz.txt", 
> which is included in the fileset, I want to know the absolute path). 
> This information will help me to extract the required the portion and 
> do the replace(the substitution regular expression depends on the file

> path).
>
> Is there a way to do it in Ant ?
>
> Regards,
> Shakun
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org



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



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


Re:THANKS- finding the absolute path of each file in a fileset

Posted by Shakun Mahajan <sh...@customercaresolutions.com>.
hi all,

I would like to sincerely thank Rich, Daniel and Matt for all your
suggestions especially about the Ant-Contrib project. I was contemplating
writing an Ant task to do this w/o knowing the full available
functionalities.

here's the solution I got:-

<target name="A">
  <sequential>
      <foreach target="matchFile" param="fileName" inheritAll="true"
inheritRefs="true">
       <path id="xslFiles" >
        <fileset dir="${deploy.dir}/components">
         <include name="**/*.xsl"/>
        </fileset>
       </path>
      </foreach>
   </sequential>
 </target>

 <target name="matchFile">
  <replaceregexp flags="gi" file="${fileName}">
   <regexp pattern="regex pattern1"/>
   <substitution expression="regexpattern2${fileName}"/>
  </replaceregexp>
 </target>

Thanks again !

Regards,
Shakun



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


Re: [BULK] - Re: [BULK] - finding the absolute path of each file in a fileset

Posted by Daniel Blaukopf <bl...@netbeans.org>.
Hi Shakun,

You could try defining a macro for your replaceregexp task, and then 
using the ant-contrib library to execute the macro once for each file in 
the fileset.

Daniel

Rich Mauri wrote:

>Somewhere you're defining deploy.dir as a property.
>
>One way is to set another property using location= prior to the
>replaceregexp task.
>For example,
>
><antcall target="doregexp"/>
>
><target name=doregexp">
>    <property name="deploy.absdir" location="${deploy.dir}"/>
>
>    <replaceregexp byline="true" flags="gi">
>      <regexp pattern="pattern1"/>
>      <substitution expression="pattern2"/>
>      <fileset dir="${deploy.absdir}/components">
>          <include name="**/*.xsl"/>
>      </fileset>
>    </replaceregexp>
></target>
>
>
>-----Original Message-----
>From: Shakun Mahajan [mailto:shakun@customercaresolutions.com] 
>Sent: Monday, March 29, 2004 4:32 PM
>To: Ant Users List
>Subject: [BULK] - Re: [BULK] - finding the absolute path of each file in
>a fileset
>
>
>Hi Rich,
>
>Sorry could not understand you.
>my regex is like this :-
>  <replaceregexp byline="true" flags="gi">
>    <regexp pattern="pattern1"/>
>    <substitution expression="pattern2"/>
>   <fileset dir="${deploy.dir}/components">
>     <include name="**/*.xsl"/>
>    </fileset>
>  </replaceregexp>
>
>I need to figure out the path of each .xsl file and do an appropriate
>substitution. How can I utilize your suggestion here?
>
>Regards,
>
>Shakun
>
>----- Original Message ----- 
>From: "Rich Mauri" <rm...@callidussoftware.com>
>To: "Ant Users List" <us...@ant.apache.org>
>Sent: Monday, March 29, 2004 4:15 PM
>Subject: RE: [BULK] - finding the absolute path of each file in a
>fileset
>
>
>  
>
>>You can use property location trick for example:
>>
>><property name="abspathtofile" location="${relpathtofile}"/>
>>
>>-----Original Message-----
>>From: Shakun Mahajan [mailto:shakun@customercaresolutions.com]
>>Sent: Monday, March 29, 2004 4:11 PM
>>To: Ant Users List
>>Subject: [BULK] - finding the absolute path of each file in a fileset
>>
>>
>>Hi all,
>>
>>I am using Ant (1.5.3) provided with Eclipse(2.1.3).
>>
>>After I deploy, I need to change a few files by replacing the paths of
>>    
>>
>
>  
>
>>the included files. I have used the Ant task "Replaceregexp" to do the
>>    
>>
>
>  
>
>>replace. However, for a particular case, I need to know the absolute 
>>path of the file in the filesystem(For e.g. for a file "xyz.txt", 
>>which is included in the fileset, I want to know the absolute path). 
>>This information will help me to extract the required the portion and 
>>do the replace(the substitution regular expression depends on the file
>>    
>>
>
>  
>
>>path).
>>
>>Is there a way to do it in Ant ?
>>
>>Regards,
>>Shakun
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>For additional commands, e-mail: user-help@ant.apache.org
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>
>  
>



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


Re: finding the absolute path of each file in a fileset

Posted by Matt Benson <gu...@yahoo.com>.
Shakun:  I think using a <mapper> with your <copy>
task might actually serve your purposes better.

-Matt


__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

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


Re: finding the absolute path of each file in a fileset

Posted by Shakun Mahajan <sh...@customercaresolutions.com>.
Hi Rich,

Thanks for your quick response. I do get your suggested usage of the
"location" attribute.
Now my scenario is like this.

lets assume
deploy.dir = d:\deploy\
and now,
deploy.absdir = d:\deploy\

under this directory I have the following structure
components
|
|----module1
|        |------1.xml
|        |------1.xsl
|
|----module2
|        |------2.xml
|        |------2.xsl

and so on.
and my fileset now contains
d:\deploy\components\module1\1.xsl, d:\deploy\components\module2\2.xsl,  and
so on.

I want my regex to add the file path information inside the file i.e.,
1.xsl should contain "components\module1\1.xsl", 2.xsl should contain
"components\module2\2.xsl" and so on.
I should be able to specify this path inside the substitution regex.

Is there a way for Ant to handle this ?

Regards,
Shakun

----- Original Message ----- 
From: "Rich Mauri" <rm...@callidussoftware.com>
To: "Ant Users List" <us...@ant.apache.org>
Sent: Monday, March 29, 2004 4:38 PM
Subject: RE: [BULK] - Re: [BULK] - finding the absolute path of each file in
a fileset


> Somewhere you're defining deploy.dir as a property.
>
> One way is to set another property using location= prior to the
> replaceregexp task.
> For example,
>
> <antcall target="doregexp"/>
>
> <target name=doregexp">
>     <property name="deploy.absdir" location="${deploy.dir}"/>
>
>     <replaceregexp byline="true" flags="gi">
>       <regexp pattern="pattern1"/>
>       <substitution expression="pattern2"/>
>       <fileset dir="${deploy.absdir}/components">
>           <include name="**/*.xsl"/>
>       </fileset>
>     </replaceregexp>
> </target>
>
>
> -----Original Message-----
> From: Shakun Mahajan [mailto:shakun@customercaresolutions.com]
> Sent: Monday, March 29, 2004 4:32 PM
> To: Ant Users List
> Subject: [BULK] - Re: [BULK] - finding the absolute path of each file in
> a fileset
>
>
> Hi Rich,
>
> Sorry could not understand you.
> my regex is like this :-
>   <replaceregexp byline="true" flags="gi">
>     <regexp pattern="pattern1"/>
>     <substitution expression="pattern2"/>
>    <fileset dir="${deploy.dir}/components">
>      <include name="**/*.xsl"/>
>     </fileset>
>   </replaceregexp>
>
> I need to figure out the path of each .xsl file and do an appropriate
> substitution. How can I utilize your suggestion here?
>
> Regards,
>
> Shakun
>
> ----- Original Message ----- 
> From: "Rich Mauri" <rm...@callidussoftware.com>
> To: "Ant Users List" <us...@ant.apache.org>
> Sent: Monday, March 29, 2004 4:15 PM
> Subject: RE: [BULK] - finding the absolute path of each file in a
> fileset
>
>
> > You can use property location trick for example:
> >
> > <property name="abspathtofile" location="${relpathtofile}"/>
> >
> > -----Original Message-----
> > From: Shakun Mahajan [mailto:shakun@customercaresolutions.com]
> > Sent: Monday, March 29, 2004 4:11 PM
> > To: Ant Users List
> > Subject: [BULK] - finding the absolute path of each file in a fileset
> >
> >
> > Hi all,
> >
> > I am using Ant (1.5.3) provided with Eclipse(2.1.3).
> >
> > After I deploy, I need to change a few files by replacing the paths of
>
> > the included files. I have used the Ant task "Replaceregexp" to do the
>
> > replace. However, for a particular case, I need to know the absolute
> > path of the file in the filesystem(For e.g. for a file "xyz.txt",
> > which is included in the fileset, I want to know the absolute path).
> > This information will help me to extract the required the portion and
> > do the replace(the substitution regular expression depends on the file
>
> > path).
> >
> > Is there a way to do it in Ant ?
> >
> > Regards,
> > Shakun
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org



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