You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Clifton Craig <cc...@gbg.com> on 2006/01/21 20:21:18 UTC

Copy a directory list

I'm having trouble doing something that I think should be really simple. I have a comma separated list of directories that I want to copy to a destination. I want those directories and everything in them to copy. When I use the copy task I get only the directories and not their contents. Eg. I have:

prj1
|
*---lib
    |
    *---default
    |   |
    |   *---default.jar
    *---debug
    |   |
    |   *---debug.jar
    *---prod
        |
        *---prod.jar

I code: <copy todir="${build.deploy.target}">
            <fileset dir="${build.lib.dir}" includes="${confs-to-deploy}"/>
        </copy>
where build.lib.dir = prj1/lib and confs-to-deploy = "default,debug,prod". I get the default, debug, and prod folders created in my build.deploy.target directory but they are all empty. How can I get the directories along with their contents?
--------------------------------------------------- 
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
ccc@icsaward.com
ccraig@gbg.com

Re: Copy a directory list

Posted by Clifton Craig <cc...@gbg.com>.
Sorry Matt, I don't believe I read your reply correctly. I'll go back and 
re-read then post again. Thanx!

On Monday 23 January 2006 3:29 pm, Matt Benson wrote:
> --- Clifton Craig <cc...@gbg.com> wrote:
>
> [SNIP]
>
> > ;) I must clarify that
> > my tone was not intended as a heated tone. It is
> > hard to express or
> > interperet tone in text so let me assure you all
> > that I'm not angry at
> > anybody.
>
> Okay, sorry for the misinterpretation... :)
>
> [SNIP]
>
> > I don't like the idea of
> > hacking patternset syntax into a property if there
> > is no such tool to take
> > care of this for me. My feeling is that once you
> > have to start reading a
> > property into a file and back into a property you've
> > taken a wrong step
> > somewhere and things should be able to be done
> > better.
>
> Agreed; I hate temp files, and many of the changes I
> have made in Ant can be traced back to that simple
> fact.
>
> >  My take away from all
> > of this is that there is no such way to easily copy
> > a list of folders
> > separated by commas and include their contents.
> > Simple is being defined as
> > not requiring the list be swapped to disk, not
> > requiring third party
> > extensions installed to the base, and not requiiring
> > custom ant tasks or
> > procedural logic as each of these approaches involve
> > additional functionality
> > that is not part of the base set.
>
> Hmm... my solution involved nothing but built-in Ant.
> Pathconvert was used to turn your list of directories
> into a patternset.  The most "foreign" material used
> was a regexp mapper... which should be included w/o
> add-ons if you're using JDK>= 1.4 ... what more do you
> want?  ;)
>
> -Matt
>
> [SNIP]
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org

-- 
------------------------------------------------- 
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
ccc@icsaward.com
ccraig@gbg.com

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


Re: Copy a directory list

Posted by Clifton Craig <cc...@gbg.com>.
Matt,

You bastard! Why won't you shut up??!!! ;) Thanx all the same for the boiled 
down example.
--------------------------------------------------- 
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
ccc@icsaward.com
ccraig@gbg.com

On Monday 23 January 2006 3:37 pm, Matt Benson wrote:
> Just because I'm a bastard who can't shut up, I'll
> even boil my example (which may have been obscured by
> setup and testing) down to a macro:
>
> <macrodef name="copydirs">
>   <attribute name="dir" />
>   <attribute name="includes" />
>   <attribute name="todir" />
>   <sequential>
>     <pathconvert property="converted@{includes}"
> pathsep=",">
>       <path>
>         <dirset dir="@{dir}" includes="@{includes}" />
>       </path>
>       <chainedmapper>
>         <globmapper from="@{dir}/*" to="*"
>                     handledirsep="true" />
>         <regexpmapper from="^.*$" to="\0/**" />
>       </chainedmapper>
>     </pathconvert>
>     <copy todir="@{todir}">
>       <fileset dir="@{dir}"
> includes="${converted@{includes}}" />
>     </copy>
>   </sequential>
> </macrodef>
>
> best I can do for now, until we have local properties
> for macrodefs.
>
> -Matt
>
> --- Matt Benson <gu...@yahoo.com> wrote:
> > --- Clifton Craig <cc...@gbg.com> wrote:
> >
> > [SNIP]
> >
> > > ;) I must clarify that
> > > my tone was not intended as a heated tone. It is
> > > hard to express or
> > > interperet tone in text so let me assure you all
> > > that I'm not angry at
> > > anybody.
> >
> > Okay, sorry for the misinterpretation... :)
> >
> > [SNIP]
> >
> > > I don't like the idea of
> > > hacking patternset syntax into a property if there
> > > is no such tool to take
> > > care of this for me. My feeling is that once you
> > > have to start reading a
> > > property into a file and back into a property
> >
> > you've
> >
> > > taken a wrong step
> > > somewhere and things should be able to be done
> > > better.
> >
> > Agreed; I hate temp files, and many of the changes I
> > have made in Ant can be traced back to that simple
> > fact.
> >
> > >  My take away from all
> > > of this is that there is no such way to easily
> >
> > copy
> >
> > > a list of folders
> > > separated by commas and include their contents.
> > > Simple is being defined as
> > > not requiring the list be swapped to disk, not
> > > requiring third party
> > > extensions installed to the base, and not
> >
> > requiiring
> >
> > > custom ant tasks or
> > > procedural logic as each of these approaches
> >
> > involve
> >
> > > additional functionality
> > > that is not part of the base set.
> >
> > Hmm... my solution involved nothing but built-in
> > Ant.
> > Pathconvert was used to turn your list of
> > directories
> > into a patternset.  The most "foreign" material used
> > was a regexp mapper... which should be included w/o
> > add-ons if you're using JDK>= 1.4 ... what more do
> > you
> > want?  ;)
> >
> > -Matt
> >
> > [SNIP]
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> > protection around
> > http://mail.yahoo.com
>
> ---------------------------------------------------------------------
>
> > To unsubscribe, e-mail:
> > user-unsubscribe@ant.apache.org
> > For additional commands, e-mail:
> > user-help@ant.apache.org
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> 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: Copy a directory list

Posted by Matt Benson <gu...@yahoo.com>.
Just because I'm a bastard who can't shut up, I'll
even boil my example (which may have been obscured by
setup and testing) down to a macro:

<macrodef name="copydirs">
  <attribute name="dir" />
  <attribute name="includes" />
  <attribute name="todir" />
  <sequential>
    <pathconvert property="converted@{includes}"
pathsep=",">
      <path>
        <dirset dir="@{dir}" includes="@{includes}" />
      </path>
      <chainedmapper>
        <globmapper from="@{dir}/*" to="*"
                    handledirsep="true" />
        <regexpmapper from="^.*$" to="\0/**" />
      </chainedmapper>
    </pathconvert>
    <copy todir="@{todir}">
      <fileset dir="@{dir}"
includes="${converted@{includes}}" />
    </copy>
  </sequential>
</macrodef>

best I can do for now, until we have local properties
for macrodefs.

-Matt

--- Matt Benson <gu...@yahoo.com> wrote:

> 
> 
> --- Clifton Craig <cc...@gbg.com> wrote:
> 
> [SNIP]
> > ;) I must clarify that 
> > my tone was not intended as a heated tone. It is
> > hard to express or 
> > interperet tone in text so let me assure you all
> > that I'm not angry at 
> > anybody.
> 
> Okay, sorry for the misinterpretation... :)
> 
> [SNIP]
> > I don't like the idea of 
> > hacking patternset syntax into a property if there
> > is no such tool to take 
> > care of this for me. My feeling is that once you
> > have to start reading a 
> > property into a file and back into a property
> you've
> > taken a wrong step 
> > somewhere and things should be able to be done
> > better.
> 
> Agreed; I hate temp files, and many of the changes I
> have made in Ant can be traced back to that simple
> fact.
> 
> >  My take away from all 
> > of this is that there is no such way to easily
> copy
> > a list of folders 
> > separated by commas and include their contents.
> > Simple is being defined as 
> > not requiring the list be swapped to disk, not
> > requiring third party 
> > extensions installed to the base, and not
> requiiring
> > custom ant tasks or 
> > procedural logic as each of these approaches
> involve
> > additional functionality 
> > that is not part of the base set. 
> 
> Hmm... my solution involved nothing but built-in
> Ant. 
> Pathconvert was used to turn your list of
> directories
> into a patternset.  The most "foreign" material used
> was a regexp mapper... which should be included w/o
> add-ons if you're using JDK>= 1.4 ... what more do
> you
> want?  ;)
> 
> -Matt
> 
> [SNIP]
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: Copy a directory list

Posted by Matt Benson <gu...@yahoo.com>.

--- Clifton Craig <cc...@gbg.com> wrote:

[SNIP]
> ;) I must clarify that 
> my tone was not intended as a heated tone. It is
> hard to express or 
> interperet tone in text so let me assure you all
> that I'm not angry at 
> anybody.

Okay, sorry for the misinterpretation... :)

[SNIP]
> I don't like the idea of 
> hacking patternset syntax into a property if there
> is no such tool to take 
> care of this for me. My feeling is that once you
> have to start reading a 
> property into a file and back into a property you've
> taken a wrong step 
> somewhere and things should be able to be done
> better.

Agreed; I hate temp files, and many of the changes I
have made in Ant can be traced back to that simple
fact.

>  My take away from all 
> of this is that there is no such way to easily copy
> a list of folders 
> separated by commas and include their contents.
> Simple is being defined as 
> not requiring the list be swapped to disk, not
> requiring third party 
> extensions installed to the base, and not requiiring
> custom ant tasks or 
> procedural logic as each of these approaches involve
> additional functionality 
> that is not part of the base set. 

Hmm... my solution involved nothing but built-in Ant. 
Pathconvert was used to turn your list of directories
into a patternset.  The most "foreign" material used
was a regexp mapper... which should be included w/o
add-ons if you're using JDK>= 1.4 ... what more do you
want?  ;)

-Matt

[SNIP]

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: Copy a directory list

Posted by Clifton Craig <cc...@gbg.com>.
Embarassing! Ok, some I misspelt purest. (Or is that misspelled purist.) 
Admitting that I'm not the purest I sought out to be ;) I must clarify that 
my tone was not intended as a heated tone. It is hard to express or 
interperet tone in text so let me assure you all that I'm not angry at 
anybody. I mentioned my purism to convey that I am not in favor of using 
Antcontrib to coerce procedural logic into what should be a declarative build 
system. I take such a stance on that as I've made that mistake (and paid for 
it) the first time I used Ant. Back to the topic. I feel as though (or felt 
as though) there should be a simpler solution for what I'm trying to do. 
That's all. Nothing wrong with any of the responses I've received so far, I'm 
just looking for the cleanest solution for my new prestine build system. What 
I'm learning is that I may need to back track and take a whole different look 
at my current situation of no such solution exists. I don't like the idea of 
hacking patternset syntax into a property if there is no such tool to take 
care of this for me. My feeling is that once you have to start reading a 
property into a file and back into a property you've taken a wrong step 
somewhere and things should be able to be done better.  My take away from all 
of this is that there is no such way to easily copy a list of folders 
separated by commas and include their contents. Simple is being defined as 
not requiring the list be swapped to disk, not requiring third party 
extensions installed to the base, and not requiiring custom ant tasks or 
procedural logic as each of these approaches involve additional functionality 
that is not part of the base set. Once again not trying to sound "heated" but 
trying to clarify my position. It is also sometimes hard to not sound or be 
interpreted as "heated" when those who is help misunderstand the context of 
the question requiring the question be repeated for clarity. The fault, I 
suppose, lies entirely on me as I should be more specific when I post.
--------------------------------------------------- 
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
ccc@icsaward.com
ccraig@gbg.com

On Monday 23 January 2006 12:41 pm, Matt Benson wrote:
> --- Ken Gentle <j....@acm.org> wrote:
> > Just for the record, the word is "purist" - Mary,
> > Mother of Jesus, is
> > reported to have be "the purest".  :)
>
> Hmm.  Purism regarding use of the word "purist".  We
> may end up with another "misspelt is misspelled"
> argument on our hands.  I do agree your tone, CC, was
> getting a little heated.  Anyway, take a look at the
> attached, 100% pure Ant (1.6.5) buildfile to see some
> ideas you might have missed.
>
> HTH,
> Matt
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com

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


Re: Copy a directory list

Posted by Clifton Craig <cc...@gbg.com>.
Matt,
That's not bad! Thanx for the tip. I haven't tried it yet but I'm sure it will 
most likely work. I'll work that into my build once I fix an unrelated bug 
that was dropped into my lap a moment ago. Thanx again.
--------------------------------------------------- 
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
ccc@icsaward.com
ccraig@gbg.com

On Monday 23 January 2006 12:41 pm, Matt Benson wrote:
> --- Ken Gentle <j....@acm.org> wrote:
> > Just for the record, the word is "purist" - Mary,
> > Mother of Jesus, is
> > reported to have be "the purest".  :)
>
> Hmm.  Purism regarding use of the word "purist".  We
> may end up with another "misspelt is misspelled"
> argument on our hands.  I do agree your tone, CC, was
> getting a little heated.  Anyway, take a look at the
> attached, 100% pure Ant (1.6.5) buildfile to see some
> ideas you might have missed.
>
> HTH,
> Matt
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com

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


Re: Copy a directory list

Posted by Matt Benson <gu...@yahoo.com>.

--- Ken Gentle <j....@acm.org> wrote:

> Just for the record, the word is "purist" - Mary,
> Mother of Jesus, is 
> reported to have be "the purest".  :)

Hmm.  Purism regarding use of the word "purist".  We
may end up with another "misspelt is misspelled"
argument on our hands.  I do agree your tone, CC, was
getting a little heated.  Anyway, take a look at the
attached, 100% pure Ant (1.6.5) buildfile to see some
ideas you might have missed.

HTH,
Matt


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Copy a directory list

Posted by Ken Gentle <j....@acm.org>.
Just for the record, the word is "purist" - Mary, Mother of Jesus, is 
reported to have be "the purest".  :)

Um, Clifton, the first solution I showed you is 100%, pure, core 
ANT.  It does involve a file read.  I have a similar issue in my 
current project that necessitates writing properties to a file so 
that they can be read back in as tokens.  A bit of a pain, but a 
macrodef and preset def handle it quite well.

scriptdef is 100% pure ant as well; do it in your scripting language 
of choice and hand it back.

There are ways around this problem.  They are workarounds.

I wish I had such tools to work around bugs (and I mean DEFECTS in 
IDEA) - ant is really, amazingly, quite flexible.

         Ken


At 09:03 2006-01-23, you wrote:
>See, herein lies the problem. I'm not open to Ant-contrib. I'm what you might
>call a purest. I believe that this should be possible using vanilla Ant
>declarative syntax. I refuse to muddy up my build with forced procedural
>logic when it doesn't need to be included. I don't have the list in a file
>nor do I want it in a file. The idea is that the caller should not need to be
>exposed to patternset syntax and should only need to pass in a list
>(separated by commas), of configurations to deploy. The configurations are
>coincident with the names of subfolders containing the projects dependencies.
>The target in question needs to take the list of configurations and deploy
>from all of the subfolders indicated by the list. I could make it such that
>the list didn't tie directly to the folder naming scheme, rather it specified
>individual target names to invoke, but in the interest of doing the simplest
>thing that works I'm trying to incrementally work my way towards that point
>if it is at all necessary.
>---------------------------------------------------
>Clifton C. Craig, Software Engineer
>Intelligent Computer Systems -  A Division of GBG
>ccc@icsaward.com
>ccraig@gbg.com
>
>On Sunday 22 January 2006 12:50 am, Ken Gentle wrote:
> > At 15:57 2006-01-21, you wrote:
> > > >       Here is the error: the includes attribute should contain patterns
> > > > matching the file names you want copied.
> > > > The patterns only match the directories.
> > > >       Try: includes="**/*.jar""
> > >
> > >Tommy,
> > >
> > >I know where the error is my real problem is the property friving
> > >the selector
> > >needs to be a comma separated list which describes the configurations to
> > >deploy. I want to use that value to drive the copy. In other words
> > > changing the comma separated values to resemble a patternset pattern is
> > > not an option. So that leaves me with few options. I can define some
> > > custom task to do a regex replace on the property value appending "/**/*"
> > > sequences on each entry or I can use beanshell with a script task to  do
> > > the same. Neither of those options are what I consider appealing. I
> > > thought I might be overlooking some simple functionality in Ant when I
> > > ran into the problem but it just doesn't seem to easy to copy directories
> > > specified in a CSV list without exposing patternset syntax to the creator
> > > of the list.
> >
> > This will load the file and do the replacements:
> >
> > <project default="default">
> >    <target name="default">
> >      <loadfile srcfile="confs-to-deploy.csv"
> > property="confs-to-deploy-pattern">
> >        <filterchain>
> >          <tokenfilter>
> >            <linetokenizer/>
> >            <replaceregex pattern="([^,]+),?"
> >                          flags="g"
> >                          replace="\1/** "/>
> >          </tokenfilter>
> >        </filterchain>
> >
> >      </loadfile>
> >      <echo>${confs-to-deploy-pattern}</echo>
> >    </target>
> > </project>
> >
> > kgentle@ALPHA $ ant -f prop-regex.xml
> > Buildfile: prop-regex.xml
> >
> > default:
> >       [echo] default/** debug/** prod/**
> >
> > BUILD SUCCESSFUL
> > Total time: 0 seconds
> >
> >
> > Or if you already have the property and you're open to AntContrib
> > tasks, you can use the PropertyRegex to do the replacements:
> >
> > <project default="default">
> >    <taskdef resource="net/sf/antcontrib/antlib.xml">
> >      <classpath>
> >        <pathelement
> > location="../lib/build/ant-contrib-1.0b2/lib/ant-contrib.jar"/>
> >      </classpath>
> >    </taskdef>
> >
> >    <target name="default">
> >      <property name="confs-to-deploy" value="default,debug,prod"/>
> >      <propertyregex property="confs-to-deploy-pattern"
> >                     input="${confs-to-deploy}"
> >                     regexp="([^,]+),?"
> >                     replace="\1/** " />
> >      <echo>${confs-to-deploy-pattern}</echo>
> >    </target>
> > </project>
> >
> > kgentle@ALPHA $ ant -f prop-regex.xml
> > Buildfile: prop-regex.xml
> >
> > default:
> >       [echo] default/** debug/** prod/**
> >
> > BUILD SUCCESSFUL
> > Total time: 0 seconds
> >
> > >---------------------------------------------------
> > >Clifton C. Craig, Software Engineer
> > >Intelligent Computer Systems -  A Division of GBG
> > >ccc@icsaward.com
> > >ccraig@gbg.com
> > >
> > >---------------------------------------------------------------------
> > >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: Copy a directory list

Posted by Clifton Craig <cc...@gbg.com>.
See, herein lies the problem. I'm not open to Ant-contrib. I'm what you might 
call a purest. I believe that this should be possible using vanilla Ant 
declarative syntax. I refuse to muddy up my build with forced procedural 
logic when it doesn't need to be included. I don't have the list in a file 
nor do I want it in a file. The idea is that the caller should not need to be 
exposed to patternset syntax and should only need to pass in a list 
(separated by commas), of configurations to deploy. The configurations are 
coincident with the names of subfolders containing the projects dependencies. 
The target in question needs to take the list of configurations and deploy 
from all of the subfolders indicated by the list. I could make it such that 
the list didn't tie directly to the folder naming scheme, rather it specified 
individual target names to invoke, but in the interest of doing the simplest 
thing that works I'm trying to incrementally work my way towards that point 
if it is at all necessary.
--------------------------------------------------- 
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
ccc@icsaward.com
ccraig@gbg.com

On Sunday 22 January 2006 12:50 am, Ken Gentle wrote:
> At 15:57 2006-01-21, you wrote:
> > >       Here is the error: the includes attribute should contain patterns
> > > matching the file names you want copied.
> > > The patterns only match the directories.
> > >       Try: includes="**/*.jar""
> >
> >Tommy,
> >
> >I know where the error is my real problem is the property friving
> >the selector
> >needs to be a comma separated list which describes the configurations to
> >deploy. I want to use that value to drive the copy. In other words
> > changing the comma separated values to resemble a patternset pattern is
> > not an option. So that leaves me with few options. I can define some
> > custom task to do a regex replace on the property value appending "/**/*"
> > sequences on each entry or I can use beanshell with a script task to  do
> > the same. Neither of those options are what I consider appealing. I
> > thought I might be overlooking some simple functionality in Ant when I
> > ran into the problem but it just doesn't seem to easy to copy directories
> > specified in a CSV list without exposing patternset syntax to the creator
> > of the list.
>
> This will load the file and do the replacements:
>
> <project default="default">
>    <target name="default">
>      <loadfile srcfile="confs-to-deploy.csv"
> property="confs-to-deploy-pattern">
>        <filterchain>
>          <tokenfilter>
>            <linetokenizer/>
>            <replaceregex pattern="([^,]+),?"
>                          flags="g"
>                          replace="\1/** "/>
>          </tokenfilter>
>        </filterchain>
>
>      </loadfile>
>      <echo>${confs-to-deploy-pattern}</echo>
>    </target>
> </project>
>
> kgentle@ALPHA $ ant -f prop-regex.xml
> Buildfile: prop-regex.xml
>
> default:
>       [echo] default/** debug/** prod/**
>
> BUILD SUCCESSFUL
> Total time: 0 seconds
>
>
> Or if you already have the property and you're open to AntContrib
> tasks, you can use the PropertyRegex to do the replacements:
>
> <project default="default">
>    <taskdef resource="net/sf/antcontrib/antlib.xml">
>      <classpath>
>        <pathelement
> location="../lib/build/ant-contrib-1.0b2/lib/ant-contrib.jar"/>
>      </classpath>
>    </taskdef>
>
>    <target name="default">
>      <property name="confs-to-deploy" value="default,debug,prod"/>
>      <propertyregex property="confs-to-deploy-pattern"
>                     input="${confs-to-deploy}"
>                     regexp="([^,]+),?"
>                     replace="\1/** " />
>      <echo>${confs-to-deploy-pattern}</echo>
>    </target>
> </project>
>
> kgentle@ALPHA $ ant -f prop-regex.xml
> Buildfile: prop-regex.xml
>
> default:
>       [echo] default/** debug/** prod/**
>
> BUILD SUCCESSFUL
> Total time: 0 seconds
>
> >---------------------------------------------------
> >Clifton C. Craig, Software Engineer
> >Intelligent Computer Systems -  A Division of GBG
> >ccc@icsaward.com
> >ccraig@gbg.com
> >
> >---------------------------------------------------------------------
> >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: Copy a directory list

Posted by Tommy Nordgren <to...@chello.se>.
On Jan 21, 2006, at 9:57 PM, Clifton Craig wrote:

>> 	Here is the error: the includes attribute should contain patterns
>> matching the file names you want copied.
>> The patterns only match the directories.
>> 	Try: includes="**/*.jar""
>
	You might be able to use patterns of the form : **/dirname/**/*.jar
	This will match any jarfile contained in a subdirectory of the  
directory dirname.
> Tommy,
>
> I know where the error is my real problem is the property friving  
> the selector
> needs to be a comma separated list which describes the  
> configurations to
> deploy. I want to use that value to drive the copy. In other words  
> changing
> the comma separated values to resemble a patternset pattern is not  
> an option.
> So that leaves me with few options. I can define some custom task  
> to do a
> regex replace on the property value appending "/**/*" sequences on  
> each entry
> or I can use beanshell with a script task to  do the same. Neither  
> of those
> options are what I consider appealing. I thought I might be  
> overlooking some
> simple functionality in Ant when I ran into the problem but it just  
> doesn't
> seem to easy to copy directories specified in a CSV list without  
> exposing
> patternset syntax to the creator of the list.
> ---------------------------------------------------
> Clifton C. Craig, Software Engineer
> Intelligent Computer Systems -  A Division of GBG
> ccc@icsaward.com
> ccraig@gbg.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>

"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"


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


Re: Copy a directory list

Posted by Frank Harnack <ha...@mail05.harlau.de>.
Another ant-contrib solution may be using the for task:

    <taskdef name="for" classname="net.sf.antcontrib.logic.For"/>

    <property name="build.lib.dir" value="prj1/lib"/>
    <property name="confs-to-deploy" value="default,debug,prod"/>
    <property name="build.deploy.target" value="prj1/deploy"/>

    <for list="${confs-to-deploy}" param="dir">
        <sequential>
            <copy todir="${build.deploy.target}/@{dir}">
                <fileset dir="${build.lib.dir}/@{dir}" includes="**/*"/>
            </copy>
        </sequential>
    </for>

Regards

Frank

Quoting Ken Gentle <j....@acm.org>:

> At 15:57 2006-01-21, you wrote:
> > >       Here is the error: the includes attribute should contain patterns
> > > matching the file names you want copied.
> > > The patterns only match the directories.
> > >       Try: includes="**/*.jar""
> >
> >Tommy,
> >
> >I know where the error is my real problem is the property friving
> >the selector
> >needs to be a comma separated list which describes the configurations to
> >deploy. I want to use that value to drive the copy. In other words changing
> >the comma separated values to resemble a patternset pattern is not an
> option.
> >So that leaves me with few options. I can define some custom task to do a
> >regex replace on the property value appending "/**/*" sequences on each
> entry
> >or I can use beanshell with a script task to  do the same. Neither of those
> >options are what I consider appealing. I thought I might be overlooking some
> >simple functionality in Ant when I ran into the problem but it just doesn't
> >seem to easy to copy directories specified in a CSV list without exposing
> >patternset syntax to the creator of the list.
>
> This will load the file and do the replacements:
>
> <project default="default">
>    <target name="default">
>      <loadfile srcfile="confs-to-deploy.csv"
> property="confs-to-deploy-pattern">
>        <filterchain>
>          <tokenfilter>
>            <linetokenizer/>
>            <replaceregex pattern="([^,]+),?"
>                          flags="g"
>                          replace="\1/** "/>
>          </tokenfilter>
>        </filterchain>
>
>      </loadfile>
>      <echo>${confs-to-deploy-pattern}</echo>
>    </target>
> </project>
>
> kgentle@ALPHA $ ant -f prop-regex.xml
> Buildfile: prop-regex.xml
>
> default:
>       [echo] default/** debug/** prod/**
>
> BUILD SUCCESSFUL
> Total time: 0 seconds
>
>
> Or if you already have the property and you're open to AntContrib
> tasks, you can use the PropertyRegex to do the replacements:
>
> <project default="default">
>    <taskdef resource="net/sf/antcontrib/antlib.xml">
>      <classpath>
>        <pathelement
> location="../lib/build/ant-contrib-1.0b2/lib/ant-contrib.jar"/>
>      </classpath>
>    </taskdef>
>
>    <target name="default">
>      <property name="confs-to-deploy" value="default,debug,prod"/>
>      <propertyregex property="confs-to-deploy-pattern"
>                     input="${confs-to-deploy}"
>                     regexp="([^,]+),?"
>                     replace="\1/** " />
>      <echo>${confs-to-deploy-pattern}</echo>
>    </target>
> </project>
>
> kgentle@ALPHA $ ant -f prop-regex.xml
> Buildfile: prop-regex.xml
>
> default:
>       [echo] default/** debug/** prod/**
>
> BUILD SUCCESSFUL
> Total time: 0 seconds
>
> >---------------------------------------------------
> >Clifton C. Craig, Software Engineer
> >Intelligent Computer Systems -  A Division of GBG
> >ccc@icsaward.com
> >ccraig@gbg.com
> >
> >---------------------------------------------------------------------
> >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: Copy a directory list

Posted by Ken Gentle <j....@acm.org>.
At 15:57 2006-01-21, you wrote:
> >       Here is the error: the includes attribute should contain patterns
> > matching the file names you want copied.
> > The patterns only match the directories.
> >       Try: includes="**/*.jar""
>
>Tommy,
>
>I know where the error is my real problem is the property friving 
>the selector
>needs to be a comma separated list which describes the configurations to
>deploy. I want to use that value to drive the copy. In other words changing
>the comma separated values to resemble a patternset pattern is not an option.
>So that leaves me with few options. I can define some custom task to do a
>regex replace on the property value appending "/**/*" sequences on each entry
>or I can use beanshell with a script task to  do the same. Neither of those
>options are what I consider appealing. I thought I might be overlooking some
>simple functionality in Ant when I ran into the problem but it just doesn't
>seem to easy to copy directories specified in a CSV list without exposing
>patternset syntax to the creator of the list.

This will load the file and do the replacements:

<project default="default">
   <target name="default">
     <loadfile srcfile="confs-to-deploy.csv" 
property="confs-to-deploy-pattern">
       <filterchain>
         <tokenfilter>
           <linetokenizer/>
           <replaceregex pattern="([^,]+),?"
                         flags="g"
                         replace="\1/** "/>
         </tokenfilter>
       </filterchain>

     </loadfile>
     <echo>${confs-to-deploy-pattern}</echo>
   </target>
</project>

kgentle@ALPHA $ ant -f prop-regex.xml
Buildfile: prop-regex.xml

default:
      [echo] default/** debug/** prod/**

BUILD SUCCESSFUL
Total time: 0 seconds


Or if you already have the property and you're open to AntContrib 
tasks, you can use the PropertyRegex to do the replacements:

<project default="default">
   <taskdef resource="net/sf/antcontrib/antlib.xml">
     <classpath>
       <pathelement 
location="../lib/build/ant-contrib-1.0b2/lib/ant-contrib.jar"/>
     </classpath>
   </taskdef>

   <target name="default">
     <property name="confs-to-deploy" value="default,debug,prod"/>
     <propertyregex property="confs-to-deploy-pattern"
                    input="${confs-to-deploy}"
                    regexp="([^,]+),?"
                    replace="\1/** " />
     <echo>${confs-to-deploy-pattern}</echo>
   </target>
</project>

kgentle@ALPHA $ ant -f prop-regex.xml
Buildfile: prop-regex.xml

default:
      [echo] default/** debug/** prod/**

BUILD SUCCESSFUL
Total time: 0 seconds

>---------------------------------------------------
>Clifton C. Craig, Software Engineer
>Intelligent Computer Systems -  A Division of GBG
>ccc@icsaward.com
>ccraig@gbg.com
>
>---------------------------------------------------------------------
>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: Copy a directory list

Posted by Clifton Craig <cc...@gbg.com>.
> 	Here is the error: the includes attribute should contain patterns
> matching the file names you want copied.
> The patterns only match the directories.
> 	Try: includes="**/*.jar""

Tommy,

I know where the error is my real problem is the property friving the selector 
needs to be a comma separated list which describes the configurations to 
deploy. I want to use that value to drive the copy. In other words changing 
the comma separated values to resemble a patternset pattern is not an option. 
So that leaves me with few options. I can define some custom task to do a 
regex replace on the property value appending "/**/*" sequences on each entry 
or I can use beanshell with a script task to  do the same. Neither of those 
options are what I consider appealing. I thought I might be overlooking some 
simple functionality in Ant when I ran into the problem but it just doesn't 
seem to easy to copy directories specified in a CSV list without exposing 
patternset syntax to the creator of the list. 
--------------------------------------------------- 
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
ccc@icsaward.com
ccraig@gbg.com

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


Re: Copy a directory list

Posted by Tommy Nordgren <to...@chello.se>.
On Jan 21, 2006, at 8:21 PM, Clifton Craig wrote:

> I'm having trouble doing something that I think should be really  
> simple. I have a comma separated list of directories that I want to  
> copy to a destination. I want those directories and everything in  
> them to copy. When I use the copy task I get only the directories  
> and not their contents. Eg. I have:
>
> prj1
> |
> *---lib
>     |
>     *---default
>     |   |
>     |   *---default.jar
>     *---debug
>     |   |
>     |   *---debug.jar
>     *---prod
>         |
>         *---prod.jar
>
> I code: <copy todir="${build.deploy.target}">
>             <fileset dir="${build.lib.dir}" includes="${confs-to- 
> deploy}"/>

	Here is the error: the includes attribute should contain patterns  
matching the file names you want copied.
The patterns only match the directories.
	Try: includes="**/*.jar""
>         </copy>
> where build.lib.dir = prj1/lib and confs-to-deploy =  
> "default,debug,prod". I get the default, debug, and prod folders  
> created in my build.deploy.target directory but they are all empty.  
> How can I get the directories along with their contents?
> ---------------------------------------------------
> Clifton C. Craig, Software Engineer
> Intelligent Computer Systems -  A Division of GBG
> ccc@icsaward.com
> ccraig@gbg.com

-------------------------------------
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
tommy.nordgren@chello.se




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