You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Dick, Brian E." <Br...@FMR.com> on 2004/08/18 18:28:39 UTC

Apply, fileset, redirector unexpected behavior

Is this the way it is supposed to work?

The test directory has two files, foo1.txt and foo2.txt.

Running the following build file produces an error. Notice that the
source file sent as a command line argument is different from the file
sent to the redirector.

   <project name="apply.xml" default="applyit">
      <target name="applyit">
         <apply executable="echo">
            <fileset dir="test" includes="*.*"/>

            <redirector>
               <inputmapper type="identity"/>
            </redirector>
         </apply>
      </target>
   </project>

Produces the following.

   applyit:
       [apply] Current OS is Windows XP
       [apply] Executing 'echo' with arguments:
       [apply] 'C:\test\foo1.txt'
       [apply]
       [apply] The ' characters around the executable and arguments are
       [apply] not part of the command.
       [apply] Redirecting input from file
       [apply] Opening C:\foo1.txt

   BUILD FAILED
   C:\apply.xml:5: java.io.FileNotFoundException: C:\foo1.txt
   ...

To get it to work, I had to change the fileset. Notice that the source
file sent as a command line argument is the same as the file sent to the
redirector.

   <project name="apply.xml" default="applyit">
      <target name="applyit">
         <apply executable="echo">
            <fileset dir="." includes="test/*.*"/>

            <redirector>
               <inputmapper type="identity"/>
            </redirector>
         </apply>
      </target>
   </project>

Produces the following.

applyit:
    [apply] Current OS is Windows XP
    [apply] Executing 'echo' with arguments:
    [apply] 'C:\test\foo1.txt'
    [apply]
    [apply] The ' characters around the executable and arguments are
    [apply] not part of the command.
    [apply] Redirecting input from file
    [apply] Opening C:\test\foo1.txt
    [apply] C:\test\foo1.txt
    [apply] Executing 'echo' with arguments:
    [apply] 'C:\test\foo2.txt'
    [apply]
    [apply] The ' characters around the executable and arguments are
    [apply] not part of the command.
    [apply] Redirecting input from file
    [apply] Opening C:\test\foo2.txt
    [apply] C:\test\foo2.txt
    [apply] Applied echo to 2 files and 0 directories.

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


Re: Apply, fileset, redirector unexpected behavior

Posted by Matt Benson <gu...@yahoo.com>.
Brian:  This behavior, although probably undesirable
(and to be honest, unforeseen), appears to be--believe
it or not--correct.  Filename Mappers operate on
(usually relative) filenames as opposed to Files and
do not take basedirs into account.  I am afraid we
would end up with all kinds of odd code if we tried to
handle this per mapper or any other way that comes to
mind.  I will leave it at that for now and consider
the matter closed unless there is a hue and cry AND
someone with a better idea.  :)

Thanks,
Matt

--- "Dick, Brian E." <Br...@FMR.com> wrote:

> Is this the way it is supposed to work?
> 
> The test directory has two files, foo1.txt and
> foo2.txt.
> 
> Running the following build file produces an error.
> Notice that the
> source file sent as a command line argument is
> different from the file
> sent to the redirector.
> 
>    <project name="apply.xml" default="applyit">
>       <target name="applyit">
>          <apply executable="echo">
>             <fileset dir="test" includes="*.*"/>
> 
>             <redirector>
>                <inputmapper type="identity"/>
>             </redirector>
>          </apply>
>       </target>
>    </project>
> 
> Produces the following.
> 
>    applyit:
>        [apply] Current OS is Windows XP
>        [apply] Executing 'echo' with arguments:
>        [apply] 'C:\test\foo1.txt'
>        [apply]
>        [apply] The ' characters around the
> executable and arguments are
>        [apply] not part of the command.
>        [apply] Redirecting input from file
>        [apply] Opening C:\foo1.txt
> 
>    BUILD FAILED
>    C:\apply.xml:5: java.io.FileNotFoundException:
> C:\foo1.txt
>    ...
> 
> To get it to work, I had to change the fileset.
> Notice that the source
> file sent as a command line argument is the same as
> the file sent to the
> redirector.
> 
>    <project name="apply.xml" default="applyit">
>       <target name="applyit">
>          <apply executable="echo">
>             <fileset dir="." includes="test/*.*"/>
> 
>             <redirector>
>                <inputmapper type="identity"/>
>             </redirector>
>          </apply>
>       </target>
>    </project>
> 
> Produces the following.
> 
> applyit:
>     [apply] Current OS is Windows XP
>     [apply] Executing 'echo' with arguments:
>     [apply] 'C:\test\foo1.txt'
>     [apply]
>     [apply] The ' characters around the executable
> and arguments are
>     [apply] not part of the command.
>     [apply] Redirecting input from file
>     [apply] Opening C:\test\foo1.txt
>     [apply] C:\test\foo1.txt
>     [apply] Executing 'echo' with arguments:
>     [apply] 'C:\test\foo2.txt'
>     [apply]
>     [apply] The ' characters around the executable
> and arguments are
>     [apply] not part of the command.
>     [apply] Redirecting input from file
>     [apply] Opening C:\test\foo2.txt
>     [apply] C:\test\foo2.txt
>     [apply] Applied echo to 2 files and 0
> directories.
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 



		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

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