Thanks David! It works now!

I still do not understand what this have to do with empty directories?

I just wanted to rename files and not their containing directories - why should I have to think about the "includeEmptyDirs" property?

Again, thanks for your time,
Adrian.

David Jackman wrote:
First, I'll attempt to explain why things happened the way they did for
the lines you marked with "(?)":

<!--
this line has no effect (?)
(from Ant's User Manual)
-->
<ant:globmapper from="*" to="*.xml" />
This one didn't work because doing mappings with a special tag (as
opposed to the mapper tag using the type attribute) wasn't introduced
until Ant 1.6.2, and Maven still uses Ant 1.5.3.


        <!--
                this line does not copy anything,
                only the ${dest.dir} is created (?)
        -->
        <ant:mapper type="glob" from="*.*" to="*.*.xml" />
According to the Ant docs, the glob type mapper can have at most one *
in the from and the to attributes.  Since this contains 2 in each, it
makes sense that it doesn't work as desired.

<!--
this line appends ".xml" both to
files and directories (?)
-->
<and:mapper type="glob" from="*" to="*.xml" />
This makes sense because the glob mapper applies itself to everything in
the fileset, and the fileset said to include everything.


Since Ant sees itself as copying the directories with the .xml
extension, you can prevent this by simply adding the includeEmptyDirs
attribute to the copy element:
    <ant:copy todir="target" includeEmptyDirs="false">
        <ant:fileset dir="src" />
        <ant:mapper type="glob" from="*" to="*.xml" />
    </ant:copy>
The downside here is that it won't copy empty directories if you have
any.  If you do have empty directories, you would need to create a
separate copy task to do this.

Hope this helps,
..David..


-----Original Message----- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Adrian Herscu Sent: Saturday, May 14, 2005 7:59 AM To: users@maven.apache.org Subject: Problem with <ant:copy> global mapper

Hi all,

I have a ${src.dir} like:
src/main/mylang
        +treeofpackages
                +file1.xxx
                +file2.xxx
                +file1.yyy
                ...

Now, I want to write a Maven goal to copy this directory structure into
a ${dest.dir} while appending an ".xml" extension to all files (but not
to directories).

I tried to use:

<ant:copy todir="${dest.dir}">
        <!--
                this line alone copies the directory
                structure and files as expected
        -->
        <ant:fileset dir="${src.dir}" />

        <!--
                this line has no effect (?)
                (from Ant's User Manual)
        -->
        <ant:globmapper from="*" to="*.xml" />

        <!--
                this line appends ".xml" both to
                files and directories (?)
        -->
        <and:mapper type="glob" from="*" to="*.xml" />

        <!--
                this line does not copy anything,
                only the ${dest.dir} is created (?)
        -->
        <ant:mapper type="glob" from="*.*" to="*.*.xml" />

        <!--
                this line works as expected :)
        -->
        <ant:mapper type="glob" from="*.xxx" to="*.xxx.xml" />

</ant:copy>

Is it possible to write this task using only one <ant:copy> task and
without specifying a mapper for each source file extension?


Thanks for your time, Adrian.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to