You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Patrick Martin <an...@gmail.com> on 2010/06/24 17:50:23 UTC

Copying a static list of files

Hello,

I want to copy a big number of files located on a remote server.
To avoid scanning the remote directory, I use a locally generated list
of absolute file names in a file called fileList.txt.

So my fileList.txt contains something like:
\\machine\share\dir1\dir2\file1.ext
\\machine\share\dir1\dir2\file with spaces.ext
\\machine\share\dir1\dir2\an other one.ext
\\machine\share\dir1\file3.ext

Now I want to copy some content of \\machine\share\dir1\dir2 in a
target folder (eg file*.ext).

I first thought of using filelist, but I get into problems with spaces
in file names.
<loadfile property="file.list" srcfile="fileList.txt">
	<filterchain>
		<!-- matching and removing prefix \\machine\share\dir1\dir2 -->
		.....
	</filterchain>
</loadfile>
<copy todir="target">
	<restrict>
		<filelist dir="\\machine\share\dir1\dir2" files="${file.list}" />
		<and>
			<or>
				<name name="${include.pattern.1}" />
				<name name="${include.pattern.2}" />
			</or>
			<not>
				<or>
					<name name="${exclude.pattern.1}" />
					<name name="${exclude.pattern.2}" />
				</or>
			</not>
		</and>
	</restrict>
</copy>

Then I tried to use the <files> resource collection with its
includesfile attribute, but I don't see how to specify the equivalent
of the <filelist> dir attribute. I even tried something with
<mappedresources>, without chance (nothing gets copied):
<copy todir="target">
	<restrict>
		<mappedresources>
			<files includesfile="fileList.txt" />
			<globmapper from="\\machine\share\dir1\dir2\*" to="*" handledirsep="true" />
		</mappedresources>
		<and>
			<or>
				<name name="${include.pattern.1}" />
				<name name="${include.pattern.2}" />
			</or>
			<not>
				<or>
					<name name="${exclude.pattern.1}" />
					<name name="${exclude.pattern.2}" />
				</or>
			</not>
		</and>
	</restrict>
</copy>

would anyone have an idea?

Thanks,

Patrick

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


Re: Copying a static list of files

Posted by Michael Ludwig <mi...@gmx.de>.
Martin Gainty schrieb am 24.06.2010 um 19:46 (-0400):
> 
> spaces are considered whitespace delimiters by every almost every
> parser on the planet so there are 2 workarounds 
> 1)use shortened name C:\Program Files becomes C:\PROGRA~1
> 2)use a fill character for the space e.g. C:\Program Files becomes
> C:\Program&nbsp;Files

I doubt the latter workaround is desirable, or even, for all practical
purposes, feasable ;-)

-- 
Michael Ludwig

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


RE: Copying a static list of files

Posted by Martin Gainty <mg...@hotmail.com>.
spaces are considered whitespace delimiters by every almost every parser on the planet so there are 2 workarounds 
1)use shortened name C:\Program Files becomes C:\PROGRA~1
2)use a fill character for the space e.g. C:\Program Files becomes C:\Program&nbsp;Files

 

Viel Gluck
Martin 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung

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.

 

> Date: Thu, 24 Jun 2010 23:17:50 +0200
> From: milu71@gmx.de
> To: user@ant.apache.org
> Subject: Re: Copying a static list of files
> 
> Patrick Martin schrieb am 24.06.2010 um 21:21 (+0200):
> > Sorry, I meant to say that "spaces in filenames are unfriendly with
> > filelist", not filesets....
> 
> Not sure I understand the problem you're facing, but <filelist>
> definitely works with filenames containing spaces, you just have
> to put them in a nested <file> element.
> 
> G:\dev\Ant :: more /t2 spacelist.txt
> G:\dev\Ant\dir with spaces\d r e i.txt
> G:\dev\Ant\dir with spaces\eins.txt
> G:\dev\Ant\dir with spaces\zwei.txt
> 
> G:\dev\Ant :: more /t2 spacelist.xml
> <!-- vim: set filetype=ant :-->
> <project>
> 
> <echo>Do &lt;loadfile> and &lt;filelist>
> work with spacy filenames?</echo>
> 
> <loadfile property="file.list" srcfile="spacelist.txt"/>
> <echo message="${file.list}"/>
> <echo> So it works using &lt;loadfile>.</echo>
> 
> <filelist id="space.list" dir="dir with spaces"
> files="eins.txt zwei.txt">
> <file name="d r e i.txt"/>
> </filelist>
> <pathconvert refid="space.list"
> pathsep="${line.separator}" property="space.prop"/>
> <echo message="${space.prop}"/>
> <echo> And it also works using &lt;filelist>.</echo>
> 
> </project>
> 
> G:\dev\Ant :: ant -f spacelist.xml
> Buildfile: G:\dev\Ant\spacelist.xml
> [echo] Do <loadfile> and <filelist>
> [echo] work with spacy filenames?
> [echo] G:\dev\Ant\dir with spaces\d r e i.txt
> [echo] G:\dev\Ant\dir with spaces\eins.txt
> [echo] G:\dev\Ant\dir with spaces\zwei.txt
> [echo] So it works using <loadfile>.
> [echo] G:\dev\Ant\dir with spaces\eins.txt
> [echo] G:\dev\Ant\dir with spaces\zwei.txt
> [echo] G:\dev\Ant\dir with spaces\d r e i.txt
> [echo] And it also works using <filelist>.
> 
> BUILD SUCCESSFUL
> 
> -- 
> Michael Ludwig
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
 		 	   		  
_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4

RE: Copying a static list of files

Posted by Martin Gainty <mg...@hotmail.com>.
Patrick-

 

why not have an init target which spawns a sed script to do regexp parsing and outputs regexp output to outputfile

then in your ant build.xml declare property that associates with the outputfile
and use that property as input to copy task

 

?
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: Sat, 26 Jun 2010 13:49:58 +0200
> Subject: Re: Copying a static list of files
> From: antuser@gmail.com
> To: user@ant.apache.org
> 
> Hello,
> 
> I thought that using fileset with the includesfile attribute would
> still trigger a source directory scan, which is what I want to avoid
> to begin with. Isn't that correct?
> 
> However, this <augment> task does sound very interesting to add <file
> name="..."/> elements to the filelist (avoiding the "space in
> filename" issue) or to add additional <name name="..."/> selectors in
> a <restrict> resource collection in order to simulate include and
> exclude patterns.
> Would it also work to add elements in a <firstmatchmapper> as
> suggested by Stefan ?
> 
> Thanks,
> 
> Patrick
> 
> On Fri, Jun 25, 2010 at 4:57 PM, Matt Benson <gu...@gmail.com> wrote:
> >
> > On Jun 25, 2010, at 9:48 AM, Stefan Bodewig wrote:
> >
> >> On 2010-06-25, Patrick Martin wrote:
> >>
> >>> I tried that but then, copy (verbose="true") tells me something like:
> >>> [copy] //host/share/dir1/dir2/one file.txt omitted as
> >>> //host/share/dir1/dir2/one file.txt is up to date.
> >>
> >>> So it means copy actually tried to copy the files over themselves ? It
> >>> did not take its "todir" attribute into account ?
> >>
> >> Yes, actually this is the surprising behavior if you sources are
> >> absolute paths.  I forgot about that myself, sorry.  See my other post
> >> about using mappers to turn the paths into relative paths again.
> >>
> >
> > Note that if your sources are relative paths to begin with, you have other
> > options.  Most simply and backward-compatibly if the list is in a
> > line-delimited file you can supply that file to <fileset>'s includesfile
> > attribute.  If for the sake of argument your list was in, say, a property or
> > read from a url, and you are simply too stubborn or resource-constrained to
> > write the includesfile to the filesystem, you could use a combination of the
> > <tokens> resourcecollection, antcontrib <for>, and the brand-spanking-new
> > <augment> task to loop over the lines (or other recognizable tokens) of your
> > list and add each as a separate include to your fileset.  Ain't that slick?
> >  ;P
> >
> > -Matt
> >
> >> Stefan
> >>
> >> ---------------------------------------------------------------------
> >> 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
> 
 		 	   		  
_________________________________________________________________
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1

Re: Copying a static list of files

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-06-26, Patrick Martin wrote:

> I thought that using fileset with the includesfile attribute would
> still trigger a source directory scan, which is what I want to avoid
> to begin with. Isn't that correct?

If neither of your patterns contain any wildcards DirectoryScanner
should only check for the existence of the files you've given.

> However, this <augment> task does sound very interesting to add <file
> name="..."/> ....
> Would it also work to add elements in a <firstmatchmapper> as
> suggested by Stefan ?

Likely.  <augment> can modify any reference, so it can modify a
reference to a mapper as well.

Stefan

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


Re: Copying a static list of files

Posted by Patrick Martin <an...@gmail.com>.
Hello,

I thought that using fileset with the includesfile attribute would
still trigger a source directory scan, which is what I want to avoid
to begin with. Isn't that correct?

However, this <augment> task does sound very interesting to add <file
name="..."/> elements to the filelist (avoiding the "space in
filename" issue) or to add additional <name name="..."/> selectors in
a <restrict> resource collection in order to simulate include and
exclude patterns.
Would it also work to add elements in a <firstmatchmapper> as
suggested by Stefan ?

Thanks,

Patrick

On Fri, Jun 25, 2010 at 4:57 PM, Matt Benson <gu...@gmail.com> wrote:
>
> On Jun 25, 2010, at 9:48 AM, Stefan Bodewig wrote:
>
>> On 2010-06-25, Patrick Martin wrote:
>>
>>> I tried that but then, copy (verbose="true") tells me something like:
>>> [copy] //host/share/dir1/dir2/one file.txt omitted as
>>> //host/share/dir1/dir2/one file.txt is up to date.
>>
>>> So it means copy actually tried to copy the files over themselves ? It
>>> did not take its "todir" attribute into account ?
>>
>> Yes, actually this is the surprising behavior if you sources are
>> absolute paths.  I forgot about that myself, sorry.  See my other post
>> about using mappers to turn the paths into relative paths again.
>>
>
> Note that if your sources are relative paths to begin with, you have other
> options.  Most simply and backward-compatibly if the list is in a
> line-delimited file you can supply that file to <fileset>'s includesfile
> attribute.  If for the sake of argument your list was in, say, a property or
> read from a url, and you are simply too stubborn or resource-constrained to
> write the includesfile to the filesystem, you could use a combination of the
> <tokens> resourcecollection, antcontrib <for>, and the brand-spanking-new
> <augment> task to loop over the lines (or other recognizable tokens) of your
> list and add each as a separate include to your fileset.  Ain't that slick?
>  ;P
>
> -Matt
>
>> Stefan
>>
>> ---------------------------------------------------------------------
>> 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: Copying a static list of files

Posted by Matt Benson <gu...@gmail.com>.
On Jun 25, 2010, at 9:48 AM, Stefan Bodewig wrote:

> On 2010-06-25, Patrick Martin wrote:
>
>> I tried that but then, copy (verbose="true") tells me something like:
>> [copy] //host/share/dir1/dir2/one file.txt omitted as
>> //host/share/dir1/dir2/one file.txt is up to date.
>
>> So it means copy actually tried to copy the files over  
>> themselves ? It
>> did not take its "todir" attribute into account ?
>
> Yes, actually this is the surprising behavior if you sources are
> absolute paths.  I forgot about that myself, sorry.  See my other post
> about using mappers to turn the paths into relative paths again.
>

Note that if your sources are relative paths to begin with, you have  
other options.  Most simply and backward-compatibly if the list is in  
a line-delimited file you can supply that file to <fileset>'s  
includesfile attribute.  If for the sake of argument your list was  
in, say, a property or read from a url, and you are simply too  
stubborn or resource-constrained to write the includesfile to the  
filesystem, you could use a combination of the <tokens>  
resourcecollection, antcontrib <for>, and the brand-spanking-new  
<augment> task to loop over the lines (or other recognizable tokens)  
of your list and add each as a separate include to your fileset.   
Ain't that slick?  ;P

-Matt

> Stefan
>
> ---------------------------------------------------------------------
> 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: Copying a static list of files

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-06-25, Patrick Martin wrote:

> I tried that but then, copy (verbose="true") tells me something like:
> [copy] //host/share/dir1/dir2/one file.txt omitted as
> //host/share/dir1/dir2/one file.txt is up to date.

> So it means copy actually tried to copy the files over themselves ? It
> did not take its "todir" attribute into account ?

Yes, actually this is the surprising behavior if you sources are
absolute paths.  I forgot about that myself, sorry.  See my other post
about using mappers to turn the paths into relative paths again.

Stefan

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


Re: Copying a static list of files

Posted by Patrick Martin <an...@gmail.com>.
I tried that but then, copy (verbose="true") tells me something like:
[copy] //host/share/dir1/dir2/one file.txt omitted as
//host/share/dir1/dir2/one file.txt is up to date.

So it means copy actually tried to copy the files over themselves ? It
did not take its "todir" attribute into account ?

On Fri, Jun 25, 2010 at 4:21 PM, Patrick Martin <an...@gmail.com> wrote:
> I still don't get how <copy> will know which basedir to take from the
> source files in order to recreate the correct folder structure in the
> "todir" folder.
> Let's say that my file list contains the full path:
>
> //host/share/dir1/dir2/one file.txt
> //host/share/dir1/dir2/two files.txt
> //host/share/dir1/three files.txt
>
> I loaded that in my property.
> Then:
> <copy todir="${target.dir}">
>  <resourcelist>
>    <propertyresource name="property-holding-list-of-files"/>
>  </resourcelist>
> </copy>
>
> How will copy know it should take files in //host/share/dir1 or in
> //host/share  for example?
>
> On Fri, Jun 25, 2010 at 4:08 PM, Stefan Bodewig <bo...@apache.org> wrote:
>> On 2010-06-25, Patrick Martin wrote:
>>
>>> This looks really promising! How do you use it with copy?
>>
>> <resourcelist> is a resource collection, you can use it everywhere where
>> Ant supports them.
>>
>> <http://ant.apache.org/manual/Types/resources.html#resourcelist>
>>
>> In particular you can use it as a nested element of <copy> directly.
>>
>>> where is the equivalent of the "dir" attribute of <fileset> or
>>> <filelist>?
>>
>> There is none.  Do you need one?
>>
>> If all your path's are relative to a common dir ${dir} and you have
>> those relative path inside a file "myfiles.txt" you'd do something like
>>
>> <copy ...>
>>  <resourcelist>
>>    <file file="myfiles.txt"/>
>>    <prefixlines prefix="${dir}/"/>
>>  </resourcelist>
>> </copy>
>>
>> to turn your relative paths into absolute paths.
>>
>> Stefan
>>
>> ---------------------------------------------------------------------
>> 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: Copying a static list of files

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-06-25, Patrick Martin wrote:

> I still don't get how <copy> will know which basedir to take from the
> source files in order to recreate the correct folder structure in the
> "todir" folder.
> Let's say that my file list contains the full path:

> //host/share/dir1/dir2/one file.txt
> //host/share/dir1/dir2/two files.txt
> //host/share/dir1/three files.txt

> I loaded that in my property.
> Then:
> <copy todir="${target.dir}">
>  <resourcelist>
>    <propertyresource name="property-holding-list-of-files"/>
>  </resourcelist>
> </copy>

> How will copy know it should take files in //host/share/dir1 or in
> //host/share  for example?

I see.  Throw in a <mapper> to strip the prefix again.

<copy todir="${target.dir}">
 <resourcelist>
   <propertyresource name="property-holding-list-of-files"/>
 </resourcelist>
 <globmapper from="//host/share/dir1/*" to="*"/>
</copy>

If there are different roots you want to copy from, you could use a
<firstmatchmapper> to wrap the alternatives.

Stefan

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


Re: Copying a static list of files

Posted by Patrick Martin <an...@gmail.com>.
I still don't get how <copy> will know which basedir to take from the
source files in order to recreate the correct folder structure in the
"todir" folder.
Let's say that my file list contains the full path:

//host/share/dir1/dir2/one file.txt
//host/share/dir1/dir2/two files.txt
//host/share/dir1/three files.txt

I loaded that in my property.
Then:
<copy todir="${target.dir}">
 <resourcelist>
   <propertyresource name="property-holding-list-of-files"/>
 </resourcelist>
</copy>

How will copy know it should take files in //host/share/dir1 or in
//host/share  for example?

On Fri, Jun 25, 2010 at 4:08 PM, Stefan Bodewig <bo...@apache.org> wrote:
> On 2010-06-25, Patrick Martin wrote:
>
>> This looks really promising! How do you use it with copy?
>
> <resourcelist> is a resource collection, you can use it everywhere where
> Ant supports them.
>
> <http://ant.apache.org/manual/Types/resources.html#resourcelist>
>
> In particular you can use it as a nested element of <copy> directly.
>
>> where is the equivalent of the "dir" attribute of <fileset> or
>> <filelist>?
>
> There is none.  Do you need one?
>
> If all your path's are relative to a common dir ${dir} and you have
> those relative path inside a file "myfiles.txt" you'd do something like
>
> <copy ...>
>  <resourcelist>
>    <file file="myfiles.txt"/>
>    <prefixlines prefix="${dir}/"/>
>  </resourcelist>
> </copy>
>
> to turn your relative paths into absolute paths.
>
> Stefan
>
> ---------------------------------------------------------------------
> 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: Copying a static list of files

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-06-25, Patrick Martin wrote:

> This looks really promising! How do you use it with copy?

<resourcelist> is a resource collection, you can use it everywhere where
Ant supports them.

<http://ant.apache.org/manual/Types/resources.html#resourcelist>

In particular you can use it as a nested element of <copy> directly.

> where is the equivalent of the "dir" attribute of <fileset> or
> <filelist>?

There is none.  Do you need one?

If all your path's are relative to a common dir ${dir} and you have
those relative path inside a file "myfiles.txt" you'd do something like

<copy ...>
  <resourcelist>
    <file file="myfiles.txt"/>
    <prefixlines prefix="${dir}/"/>
  </resourcelist>
</copy>

to turn your relative paths into absolute paths.

Stefan

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


Re: Copying a static list of files

Posted by Patrick Martin <an...@gmail.com>.
This looks really promising! How do you use it with copy? where is the
equivalent of the "dir" attribute of <fileset> or <filelist>?

On Fri, Jun 25, 2010 at 3:11 PM, Stefan Bodewig <bo...@apache.org> wrote:
> On 2010-06-25, Michael Ludwig wrote:
>
>> Patrick Martin schrieb am 25.06.2010 um 09:06 (+0200):
>
>>> Using embedded <file name="..."/> would work if i had the list of
>>> files upfront. But I only have it at runtime.
>
>> You could probably generate at runtime an Ant file filelist.xml
>> including all the <file name="..."/> you need and then run a <subant>
>> task to do what you want.
>
> If you can generate any file at runtime, then make that a file with one
> file name per line and use <resourcelist>.  Actually you don't even need
> an external file if you can read said list from a property, something
> like
>
> <resourcelist id="files">
>  <propertyresource name="property-holding-list-of-files"/>
> </resourcelist>
>
> Stefan
>
> ---------------------------------------------------------------------
> 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: Copying a static list of files

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-06-25, Michael Ludwig wrote:

> Patrick Martin schrieb am 25.06.2010 um 09:06 (+0200):

>> Using embedded <file name="..."/> would work if i had the list of
>> files upfront. But I only have it at runtime.

> You could probably generate at runtime an Ant file filelist.xml
> including all the <file name="..."/> you need and then run a <subant>
> task to do what you want.

If you can generate any file at runtime, then make that a file with one
file name per line and use <resourcelist>.  Actually you don't even need
an external file if you can read said list from a property, something
like

<resourcelist id="files">
  <propertyresource name="property-holding-list-of-files"/>
</resourcelist>

Stefan

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


Re: Copying a static list of files

Posted by Michael Ludwig <mi...@gmx.de>.
Patrick Martin schrieb am 25.06.2010 um 09:06 (+0200):

> Using embedded <file name="..."/> would work if i had the list of
> files upfront. But I only have it at runtime.

You could probably generate at runtime an Ant file filelist.xml
including all the <file name="..."/> you need and then run a <subant>
task to do what you want.

  <subant antfile="filelist.xml" target="echo-paths"/>

But this is starting to feel awkward ("von hinten durch die Brust ins
Auge", don't know in English), and I'm sure there is an easier way to
achieve what you want.

-- 
Michael Ludwig

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


Re: Copying a static list of files

Posted by Patrick Martin <an...@gmail.com>.
Hello,

Thank you for your suggestions.

Using embedded <file name="..."/> would work if i had the list of
files upfront. But I only have it at runtime. I'll check if short
filenames can help me. This can be tricky as I need to strip out the
base directory with short file names from my file list...

Thanks,

On Thu, Jun 24, 2010 at 11:17 PM, Michael Ludwig <mi...@gmx.de> wrote:
> Patrick Martin schrieb am 24.06.2010 um 21:21 (+0200):
>> Sorry, I meant to say that "spaces in filenames are unfriendly with
>> filelist", not filesets....
>
> Not sure I understand the problem you're facing, but <filelist>
> definitely works with filenames containing spaces, you just have
> to put them in a nested <file> element.
>
> G:\dev\Ant :: more /t2 spacelist.txt
> G:\dev\Ant\dir with spaces\d r e i.txt
> G:\dev\Ant\dir with spaces\eins.txt
> G:\dev\Ant\dir with spaces\zwei.txt
>
> G:\dev\Ant :: more /t2 spacelist.xml
> <!-- vim: set filetype=ant :-->
> <project>
>
>  <echo>Do &lt;loadfile> and &lt;filelist>
>  work with spacy filenames?</echo>
>
>  <loadfile property="file.list" srcfile="spacelist.txt"/>
>  <echo message="${file.list}"/>
>  <echo>  So it works using &lt;loadfile>.</echo>
>
>  <filelist id="space.list" dir="dir with spaces"
>    files="eins.txt zwei.txt">
>    <file name="d r e i.txt"/>
>  </filelist>
>  <pathconvert refid="space.list"
>    pathsep="${line.separator}" property="space.prop"/>
>  <echo message="${space.prop}"/>
>  <echo>  And it also works using &lt;filelist>.</echo>
>
> </project>
>
> G:\dev\Ant :: ant -f spacelist.xml
> Buildfile: G:\dev\Ant\spacelist.xml
>     [echo] Do <loadfile> and <filelist>
>     [echo]   work with spacy filenames?
>     [echo] G:\dev\Ant\dir with spaces\d r e i.txt
>     [echo] G:\dev\Ant\dir with spaces\eins.txt
>     [echo] G:\dev\Ant\dir with spaces\zwei.txt
>     [echo]   So it works using <loadfile>.
>     [echo] G:\dev\Ant\dir with spaces\eins.txt
>     [echo] G:\dev\Ant\dir with spaces\zwei.txt
>     [echo] G:\dev\Ant\dir with spaces\d r e i.txt
>     [echo]   And it also works using <filelist>.
>
> BUILD SUCCESSFUL
>
> --
> Michael Ludwig
>
> ---------------------------------------------------------------------
> 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: Copying a static list of files

Posted by Michael Ludwig <mi...@gmx.de>.
Patrick Martin schrieb am 24.06.2010 um 21:21 (+0200):
> Sorry, I meant to say that "spaces in filenames are unfriendly with
> filelist", not filesets....

Not sure I understand the problem you're facing, but <filelist>
definitely works with filenames containing spaces, you just have
to put them in a nested <file> element.

G:\dev\Ant :: more /t2 spacelist.txt
G:\dev\Ant\dir with spaces\d r e i.txt
G:\dev\Ant\dir with spaces\eins.txt
G:\dev\Ant\dir with spaces\zwei.txt

G:\dev\Ant :: more /t2 spacelist.xml
<!-- vim: set filetype=ant :-->
<project>

  <echo>Do &lt;loadfile> and &lt;filelist>
  work with spacy filenames?</echo>

  <loadfile property="file.list" srcfile="spacelist.txt"/>
  <echo message="${file.list}"/>
  <echo>  So it works using &lt;loadfile>.</echo>

  <filelist id="space.list" dir="dir with spaces"
    files="eins.txt zwei.txt">
    <file name="d r e i.txt"/>
  </filelist>
  <pathconvert refid="space.list"
    pathsep="${line.separator}" property="space.prop"/>
  <echo message="${space.prop}"/>
  <echo>  And it also works using &lt;filelist>.</echo>

</project>

G:\dev\Ant :: ant -f spacelist.xml
Buildfile: G:\dev\Ant\spacelist.xml
     [echo] Do <loadfile> and <filelist>
     [echo]   work with spacy filenames?
     [echo] G:\dev\Ant\dir with spaces\d r e i.txt
     [echo] G:\dev\Ant\dir with spaces\eins.txt
     [echo] G:\dev\Ant\dir with spaces\zwei.txt
     [echo]   So it works using <loadfile>.
     [echo] G:\dev\Ant\dir with spaces\eins.txt
     [echo] G:\dev\Ant\dir with spaces\zwei.txt
     [echo] G:\dev\Ant\dir with spaces\d r e i.txt
     [echo]   And it also works using <filelist>.

BUILD SUCCESSFUL

-- 
Michael Ludwig

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


Re: Copying a static list of files

Posted by Patrick Martin <an...@gmail.com>.
Sorry, I meant to say that "spaces in filenames are unfriendly with
filelist", not filesets....

On Thu, Jun 24, 2010 at 9:17 PM, Patrick Martin <an...@gmail.com> wrote:
> Hello,
>
> My problem is not so much with slashes and back-slashes (which i am
> quite used to deal with), but rather with spaces in filenames which
> are unfriendly with fileset.
> With <resourcelist><file file=.../></resourcelist> or with <files>
> resource collections, I don't see how to set the equivalent to the
> <filelist> "dir" attribute to make it work properly with <copy>.
>
> Rgds,
>
> Patrick
>
> On Thu, Jun 24, 2010 at 6:22 PM, Martin Gainty <mg...@hotmail.com> wrote:
>>
>> Good Afternoon Patrick-
>>
>>
>>
>> Ant uses the filesystem which is provided by the Operating System
>>
>> so if your on Windows using NTFS and your installation folder for program fubar was installed at C:\Program Files (C:\Program Files\fubar)
>> which would map to
>> C:\PROGRA~1\fubar
>>
>> but in the case of Ant,Maven (and every other utility developed under Unix) and ported to Windows then use back-slashes e.g.
>>
>> C:/PROGRA~1/fubar
>>
>>
>>
>> in the case of an UNC name you can use a Machine and ShareName
>>
>> \\Machine\ShareName
>>
>>
>> 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, 24 Jun 2010 17:50:23 +0200
>>> Subject: Copying a static list of files
>>> From: antuser@gmail.com
>>> To: user@ant.apache.org
>>>
>>> Hello,
>>>
>>> I want to copy a big number of files located on a remote server.
>>> To avoid scanning the remote directory, I use a locally generated list
>>> of absolute file names in a file called fileList.txt.
>>>
>>> So my fileList.txt contains something like:
>>> \\machine\share\dir1\dir2\file1.ext
>>> \\machine\share\dir1\dir2\file with spaces.ext
>>> \\machine\share\dir1\dir2\an other one.ext
>>> \\machine\share\dir1\file3.ext
>>>
>>> Now I want to copy some content of \\machine\share\dir1\dir2 in a
>>> target folder (eg file*.ext).
>>>
>>> I first thought of using filelist, but I get into problems with spaces
>>> in file names.
>>> <loadfile property="file.list" srcfile="fileList.txt">
>>> <filterchain>
>>> <!-- matching and removing prefix \\machine\share\dir1\dir2 -->
>>> .....
>>> </filterchain>
>>> </loadfile>
>>> <copy todir="target">
>>> <restrict>
>>> <filelist dir="\\machine\share\dir1\dir2" files="${file.list}" />
>>> <and>
>>> <or>
>>> <name name="${include.pattern.1}" />
>>> <name name="${include.pattern.2}" />
>>> </or>
>>> <not>
>>> <or>
>>> <name name="${exclude.pattern.1}" />
>>> <name name="${exclude.pattern.2}" />
>>> </or>
>>> </not>
>>> </and>
>>> </restrict>
>>> </copy>
>>>
>>> Then I tried to use the <files> resource collection with its
>>> includesfile attribute, but I don't see how to specify the equivalent
>>> of the <filelist> dir attribute. I even tried something with
>>> <mappedresources>, without chance (nothing gets copied):
>>> <copy todir="target">
>>> <restrict>
>>> <mappedresources>
>>> <files includesfile="fileList.txt" />
>>> <globmapper from="\\machine\share\dir1\dir2\*" to="*" handledirsep="true" />
>>> </mappedresources>
>>> <and>
>>> <or>
>>> <name name="${include.pattern.1}" />
>>> <name name="${include.pattern.2}" />
>>> </or>
>>> <not>
>>> <or>
>>> <name name="${exclude.pattern.1}" />
>>> <name name="${exclude.pattern.2}" />
>>> </or>
>>> </not>
>>> </and>
>>> </restrict>
>>> </copy>
>>>
>>> would anyone have an idea?
>>>
>>> Thanks,
>>>
>>> Patrick
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: user-help@ant.apache.org
>>>
>>
>> _________________________________________________________________
>> Hotmail is redefining busy with tools for the New Busy. Get more from your inbox.
>> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2
>

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


Re: Copying a static list of files

Posted by Michael Ludwig <mi...@gmx.de>.
Patrick Martin schrieb am 24.06.2010 um 21:17 (+0200):
> 
> My problem is not so much with slashes and back-slashes (which i am
> quite used to deal with), but rather with spaces in filenames which
> are unfriendly with fileset.

Even if <filelist> weren't able to copy with spacy filenames, you could
use Martin's suggestion to use the old 8.3 filenames.

md "a b c"
dir /x

24.06.2010  23:36    <DIR>          ABC~1        a b c

> On Thu, Jun 24, 2010 at 6:22 PM, Martin Gainty <mg...@hotmail.com>
> wrote:

> > so if your on Windows using NTFS and your installation folder for
> > program fubar was installed at C:\Program Files (C:\Program
> > Files\fubar) which would map to C:\PROGRA~1\fubar

-- 
Michael Ludwig

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


Re: Copying a static list of files

Posted by Patrick Martin <an...@gmail.com>.
Hello,

My problem is not so much with slashes and back-slashes (which i am
quite used to deal with), but rather with spaces in filenames which
are unfriendly with fileset.
With <resourcelist><file file=.../></resourcelist> or with <files>
resource collections, I don't see how to set the equivalent to the
<filelist> "dir" attribute to make it work properly with <copy>.

Rgds,

Patrick

On Thu, Jun 24, 2010 at 6:22 PM, Martin Gainty <mg...@hotmail.com> wrote:
>
> Good Afternoon Patrick-
>
>
>
> Ant uses the filesystem which is provided by the Operating System
>
> so if your on Windows using NTFS and your installation folder for program fubar was installed at C:\Program Files (C:\Program Files\fubar)
> which would map to
> C:\PROGRA~1\fubar
>
> but in the case of Ant,Maven (and every other utility developed under Unix) and ported to Windows then use back-slashes e.g.
>
> C:/PROGRA~1/fubar
>
>
>
> in the case of an UNC name you can use a Machine and ShareName
>
> \\Machine\ShareName
>
>
> 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, 24 Jun 2010 17:50:23 +0200
>> Subject: Copying a static list of files
>> From: antuser@gmail.com
>> To: user@ant.apache.org
>>
>> Hello,
>>
>> I want to copy a big number of files located on a remote server.
>> To avoid scanning the remote directory, I use a locally generated list
>> of absolute file names in a file called fileList.txt.
>>
>> So my fileList.txt contains something like:
>> \\machine\share\dir1\dir2\file1.ext
>> \\machine\share\dir1\dir2\file with spaces.ext
>> \\machine\share\dir1\dir2\an other one.ext
>> \\machine\share\dir1\file3.ext
>>
>> Now I want to copy some content of \\machine\share\dir1\dir2 in a
>> target folder (eg file*.ext).
>>
>> I first thought of using filelist, but I get into problems with spaces
>> in file names.
>> <loadfile property="file.list" srcfile="fileList.txt">
>> <filterchain>
>> <!-- matching and removing prefix \\machine\share\dir1\dir2 -->
>> .....
>> </filterchain>
>> </loadfile>
>> <copy todir="target">
>> <restrict>
>> <filelist dir="\\machine\share\dir1\dir2" files="${file.list}" />
>> <and>
>> <or>
>> <name name="${include.pattern.1}" />
>> <name name="${include.pattern.2}" />
>> </or>
>> <not>
>> <or>
>> <name name="${exclude.pattern.1}" />
>> <name name="${exclude.pattern.2}" />
>> </or>
>> </not>
>> </and>
>> </restrict>
>> </copy>
>>
>> Then I tried to use the <files> resource collection with its
>> includesfile attribute, but I don't see how to specify the equivalent
>> of the <filelist> dir attribute. I even tried something with
>> <mappedresources>, without chance (nothing gets copied):
>> <copy todir="target">
>> <restrict>
>> <mappedresources>
>> <files includesfile="fileList.txt" />
>> <globmapper from="\\machine\share\dir1\dir2\*" to="*" handledirsep="true" />
>> </mappedresources>
>> <and>
>> <or>
>> <name name="${include.pattern.1}" />
>> <name name="${include.pattern.2}" />
>> </or>
>> <not>
>> <or>
>> <name name="${exclude.pattern.1}" />
>> <name name="${exclude.pattern.2}" />
>> </or>
>> </not>
>> </and>
>> </restrict>
>> </copy>
>>
>> would anyone have an idea?
>>
>> Thanks,
>>
>> Patrick
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>
> _________________________________________________________________
> Hotmail is redefining busy with tools for the New Busy. Get more from your inbox.
> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2

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


RE: Copying a static list of files

Posted by Martin Gainty <mg...@hotmail.com>.
Good Afternoon Patrick-

 

Ant uses the filesystem which is provided by the Operating System

so if your on Windows using NTFS and your installation folder for program fubar was installed at C:\Program Files (C:\Program Files\fubar) 
which would map to
C:\PROGRA~1\fubar

but in the case of Ant,Maven (and every other utility developed under Unix) and ported to Windows then use back-slashes e.g.

C:/PROGRA~1/fubar

 

in the case of an UNC name you can use a Machine and ShareName

\\Machine\ShareName


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, 24 Jun 2010 17:50:23 +0200
> Subject: Copying a static list of files
> From: antuser@gmail.com
> To: user@ant.apache.org
> 
> Hello,
> 
> I want to copy a big number of files located on a remote server.
> To avoid scanning the remote directory, I use a locally generated list
> of absolute file names in a file called fileList.txt.
> 
> So my fileList.txt contains something like:
> \\machine\share\dir1\dir2\file1.ext
> \\machine\share\dir1\dir2\file with spaces.ext
> \\machine\share\dir1\dir2\an other one.ext
> \\machine\share\dir1\file3.ext
> 
> Now I want to copy some content of \\machine\share\dir1\dir2 in a
> target folder (eg file*.ext).
> 
> I first thought of using filelist, but I get into problems with spaces
> in file names.
> <loadfile property="file.list" srcfile="fileList.txt">
> <filterchain>
> <!-- matching and removing prefix \\machine\share\dir1\dir2 -->
> .....
> </filterchain>
> </loadfile>
> <copy todir="target">
> <restrict>
> <filelist dir="\\machine\share\dir1\dir2" files="${file.list}" />
> <and>
> <or>
> <name name="${include.pattern.1}" />
> <name name="${include.pattern.2}" />
> </or>
> <not>
> <or>
> <name name="${exclude.pattern.1}" />
> <name name="${exclude.pattern.2}" />
> </or>
> </not>
> </and>
> </restrict>
> </copy>
> 
> Then I tried to use the <files> resource collection with its
> includesfile attribute, but I don't see how to specify the equivalent
> of the <filelist> dir attribute. I even tried something with
> <mappedresources>, without chance (nothing gets copied):
> <copy todir="target">
> <restrict>
> <mappedresources>
> <files includesfile="fileList.txt" />
> <globmapper from="\\machine\share\dir1\dir2\*" to="*" handledirsep="true" />
> </mappedresources>
> <and>
> <or>
> <name name="${include.pattern.1}" />
> <name name="${include.pattern.2}" />
> </or>
> <not>
> <or>
> <name name="${exclude.pattern.1}" />
> <name name="${exclude.pattern.2}" />
> </or>
> </not>
> </and>
> </restrict>
> </copy>
> 
> would anyone have an idea?
> 
> Thanks,
> 
> Patrick
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
 		 	   		  
_________________________________________________________________
Hotmail is redefining busy with tools for the New Busy. Get more from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2