You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by David J Iannucci <dj...@myriad.com> on 2001/03/12 05:40:09 UTC

Finding file types in

Sorry if this has been answered already in an obvious place,
but I haven't found it.

The <fileset> task allows you to choose a set of files
based on file names, but how about on file _types_?
For example, I'd like to make a set out of all the
(sub)directories in the current directory.  I don't
want to do this by (e.g.) assuming that anything without
a ".[ext]" in the name is a directory.  Is this possible
now, or is it being worked on?

Thanks,
Dave Iannucci
dji@myriad.com

Re: Finding file types in

Posted by Stefan Bodewig <bo...@apache.org>.
David J. Iannucci <dj...@myriad.com> wrote:

> So..... if I want to write my buildfile so that it finds anything
> in a subdirectory under it and builds those, recursively, without
> hard-wiring the names, would you recommend something like the
> following?
> 
>    <apply executable="ant" ..... type="dir">
>       .....
>       <fileset dir="." includes="*" />
>    </apply>

No, for several reasons.

(1) You have no control about the order in which they get executed.

(2) 

<execon executable="ant">
  <arg value="-f" />
  <srcfile/>
  <fileset dir="." includes="**/build.xml" />
</execon

Looks like the far more obvious choice.

(3) You are forking a new JVM for every build file. Several <ant>
tasks would run the builds in the same VM and therefore improve build
time considerably.

Apart from "avoid recursive builds" - as this really is not Ant's way
of thinking, this is trying to make Ant fit with the Makefile model -
there is not too much ATM apart from my (2) above.

An <ant> task that would use a fileset to identify subbuilds is on the
wishlist for upcomming implementations.

Stefan

Re: DUH...Why can't I get AWK to work?

Posted by Peter Donald <do...@apache.org>.
At 08:24  14/3/01 -0500, Larry Yates wrote:
>For some reason, I can't get awk to work properly from Ant although it works
>OK from the command line. Everything 'looks' OK (i.e. the directory does
>contain html files)...

When doing it on the command line the * is expanded while when passing it
via ant it is not expanded and thus fails.

Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*


Re: Problems with CLASSPATH

Posted by Stefan Bodewig <bo...@apache.org>.
Larry Yates <ly...@adelphia.net> wrote:

> Is this the correct way to use this property?
> 
> <property name="build.sysclasspath" value="ignore"/>

either this way or from the command line -Dbuild.sysclasspath=ignore.

> What other (if any) values can be assigned?

It has been documented after the relase, see
<http://jakarta.apache.org/cvsweb/index.cgi/jakarta-ant/docs/manual/sysclasspath.html>
for the current version.

Stefan

RE: DUH...Why can't I get AWK to work?

Posted by Larry Yates <ly...@adelphia.net>.
Thanks!
Actually, using "ExecOn" versus "Exec" cured my wildcard expansion problem.

However, I dumped the whole thing (awk/sed/et al) for the "REPLACE" task.

...like I tell everybody, Ant is the GREATEST THING SINCE SLICED BREAD!!!

-Larry
-----Original Message-----
From: Conor MacNeill [mailto:conor@cortexebusiness.com.au]
Sent: Wednesday, March 14, 2001 8:49 PM
To: ant-user@jakarta.apache.org
Subject: RE: DUH...Why can't I get AWK to work?


Larry,

Wildcard expansion under Unix is performed by the shell. It is not performed
by Ant so you are passing *.html straight to awk. You should probably change
the executable to /bin/sh and pass the awk command as an argument.

Conor


> -----Original Message-----
> From: Larry Yates [mailto:lyates1@adelphia.net]
> Sent: Thursday, 15 March 2001 12:25 PM
> To: ant-user@jakarta.apache.org
> Subject: DUH...Why can't I get AWK to work?
>
>
> For some reason, I can't get awk to work properly from Ant
> although it works
> OK from the command line. Everything 'looks' OK (i.e. the directory does
> contain html files)...
>
> Any ideas?
> Is there another way of making transformations (editing) on a
> list of files?
>
> Here's the relevant part of the build.xml file:
>    <target name="modify">
>       <property name="from" value="servlet/" />
>       <property name="to"   value="servletdemo/" />
>       <exec dir="${html}" executable="awk" os="NONSTOP_KERNEL" >
>         <arg line="'gsub(&quot;${from}&quot;,&quot;${to}&quot;)'
> ${html}/*.html"/>
>       </exec>
>    </target>
>
> and here's the log:
> modify:
>      [exec] Myos = NONSTOP_KERNEL
>      [exec] awk 'gsub("servlet/","servletdemo/")'
> /test/applications/demo/release2/html/*.html
>      [exec] awk: Cannot find or open file
> /test/applications/demo/release2/html/*.html.
>      [exec]
>      [exec]  The source line number is 1.
>      [exec] Result: 2
>
> BUILD SUCCESSFUL
>
> Thanks!
> -Larry
>
>


RE: DUH...Why can't I get AWK to work?

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
Larry,

Wildcard expansion under Unix is performed by the shell. It is not performed
by Ant so you are passing *.html straight to awk. You should probably change
the executable to /bin/sh and pass the awk command as an argument.

Conor


> -----Original Message-----
> From: Larry Yates [mailto:lyates1@adelphia.net]
> Sent: Thursday, 15 March 2001 12:25 PM
> To: ant-user@jakarta.apache.org
> Subject: DUH...Why can't I get AWK to work?
>
>
> For some reason, I can't get awk to work properly from Ant
> although it works
> OK from the command line. Everything 'looks' OK (i.e. the directory does
> contain html files)...
>
> Any ideas?
> Is there another way of making transformations (editing) on a
> list of files?
>
> Here's the relevant part of the build.xml file:
>    <target name="modify">
>       <property name="from" value="servlet/" />
>       <property name="to"   value="servletdemo/" />
>       <exec dir="${html}" executable="awk" os="NONSTOP_KERNEL" >
>         <arg line="'gsub(&quot;${from}&quot;,&quot;${to}&quot;)'
> ${html}/*.html"/>
>       </exec>
>    </target>
>
> and here's the log:
> modify:
>      [exec] Myos = NONSTOP_KERNEL
>      [exec] awk 'gsub("servlet/","servletdemo/")'
> /test/applications/demo/release2/html/*.html
>      [exec] awk: Cannot find or open file
> /test/applications/demo/release2/html/*.html.
>      [exec]
>      [exec]  The source line number is 1.
>      [exec] Result: 2
>
> BUILD SUCCESSFUL
>
> Thanks!
> -Larry
>
>


DUH...Why can't I get AWK to work?

Posted by Larry Yates <ly...@adelphia.net>.
For some reason, I can't get awk to work properly from Ant although it works
OK from the command line. Everything 'looks' OK (i.e. the directory does
contain html files)...

Any ideas?
Is there another way of making transformations (editing) on a list of files?

Here's the relevant part of the build.xml file:
   <target name="modify">
      <property name="from" value="servlet/" />
      <property name="to"   value="servletdemo/" />
      <exec dir="${html}" executable="awk" os="NONSTOP_KERNEL" >
        <arg line="'gsub(&quot;${from}&quot;,&quot;${to}&quot;)'
${html}/*.html"/>
      </exec>
   </target>

and here's the log:
modify:
     [exec] Myos = NONSTOP_KERNEL
     [exec] awk 'gsub("servlet/","servletdemo/")'
/test/applications/demo/release2/html/*.html
     [exec] awk: Cannot find or open file
/test/applications/demo/release2/html/*.html.
     [exec]
     [exec]  The source line number is 1.
     [exec] Result: 2

BUILD SUCCESSFUL

Thanks!
-Larry


RE: Problems with CLASSPATH

Posted by Larry Yates <ly...@adelphia.net>.
Is this the correct way to use this property?

<property name="build.sysclasspath" value="ignore"/>

...or is it a <target> attribute?

What other (if any) values can be assigned?

Thanks!
-Larry

-----Original Message-----
From: Stefan Bodewig [mailto:bodewig@apache.org]
Sent: Wednesday, March 14, 2001 6:52 AM
To: ant-user@jakarta.apache.org
Subject: Re: Problems with CLASSPATH


Martin Monsorno <mo...@exolution.de> wrote:

> Isn't it possible to make ant NOT use the CLASSPATH settings of the 
> environment?

Set the magic property build.sysclasspath to ignore.

I'm afraid, this has been undocumented in the release.

Stefan

Re: Problems with CLASSPATH

Posted by Stefan Bodewig <bo...@apache.org>.
Martin Monsorno <mo...@exolution.de> wrote:

> Isn't it possible to make ant NOT use the CLASSPATH settings of the 
> environment?

Set the magic property build.sysclasspath to ignore.

I'm afraid, this has been undocumented in the release.

Stefan

Re: Problems with CLASSPATH

Posted by Martin Monsorno <mo...@exolution.de>.
Got the same problem, but my resulting classpath is the environmental
CLASSPATH + the one I specified.

Isn't it possible to make ant NOT use the CLASSPATH settings of the 
environment?

Larry Yates wrote:
> 
> Hi,
> I'm trying to compile with a classpath that I define at runtime, but the
> compile uses
> the environment CLASSPATH. The "Compilation args" show that the PATH I
> define is not used.
> 
> What am I doing wrong?
> 
> Here is the build.xml:
> <project name="Ecom" default="compile" basedir=".">
>    <property name="app.name" value="release2"/>
>    <property name="deploy.home"
> value="/test/applications/demo/${app.name}"/>
>    <property name="classes" value="${deploy.home}/servletclasses"/>
> 
>    <path id="project.class.path">
>      <fileset dir="/">
>        <include name="${java.home}/lib/classes.zip,
>                       ${java.home}/lib/servletclasses.zip,
>                       ${java.home}/lib/tsmp.jar,
>                       ${classes},
>                       ${deploy.home}/lib/xerces.jar,
>                       ${deploy.home}/lib/xalan.jar" />
>      </fileset>
>    </path>
> 
>    <target name="compile">
>       <rmic  base="${deploy.home}/servletclasses"
>              includes="**/*Impl.class"
>            <classpath refid="project.class.path" />
>       </rmic>
>    </target>
> </project>
> 
> Thanks for any and all help!
> -Larry

-- 
Martin Monsorno
mailto:Martin.Monsorno@exolution.de

Problems with CLASSPATH

Posted by Larry Yates <ly...@adelphia.net>.
Hi,
I'm trying to compile with a classpath that I define at runtime, but the
compile uses
the environment CLASSPATH. The "Compilation args" show that the PATH I
define is not used.

What am I doing wrong?

Here is the build.xml:
<project name="Ecom" default="compile" basedir=".">
   <property name="app.name" value="release2"/>
   <property name="deploy.home"
value="/test/applications/demo/${app.name}"/>
   <property name="classes" value="${deploy.home}/servletclasses"/>

   <path id="project.class.path">
     <fileset dir="/">
       <include name="${java.home}/lib/classes.zip,
                      ${java.home}/lib/servletclasses.zip,
                      ${java.home}/lib/tsmp.jar,
                      ${classes},
                      ${deploy.home}/lib/xerces.jar,
                      ${deploy.home}/lib/xalan.jar" />
     </fileset>
   </path>

   <target name="compile">
      <rmic  base="${deploy.home}/servletclasses"
             includes="**/*Impl.class"
           <classpath refid="project.class.path" />
      </rmic>
   </target>
</project>

Thanks for any and all help!
-Larry


Re: Finding file types in

Posted by Peter Donald <do...@apache.org>.
At 10:19  12/3/01 -0700, David J Iannucci wrote:
>So..... if I want to write my buildfile so that it finds anything
>in a subdirectory under it and builds those, recursively, without
>hard-wiring the names, would you recommend something like the
>following?

I would recommend you not use a recursive build process ;) If you want to
know why pop over to google and search for an article titled "Recursive
make considered harmful" ;)

Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*


Re: Finding file types in

Posted by David J Iannucci <dj...@myriad.com>.
Stefan Bodewig wrote:
> 
> > The <fileset> task allows you to choose a set of files
> > based on file names, but how about on file _types_?
> 
> This is not possible for a fileset, at least not now. The <execon>
> task and its relatives <apply> and <chmod> support a type attribute
> to filter based on file type.

So..... if I want to write my buildfile so that it finds anything
in a subdirectory under it and builds those, recursively, without
hard-wiring the names, would you recommend something like the
following?

   <apply executable="ant" ..... type="dir">
      .....
      <fileset dir="." includes="*" />
   </apply>

Or am I missing something fundamental about Ant?  Is there a
more natural way to do this sort of thing?  I know I haven't
completely wrapped my head around all this yet, but your advice
(anyone's :-) is much appreciated.

Dave Iannucci
dji@myriad.com

Re: Finding file types in

Posted by David Rees <d....@usa.net>.
rOn 12 Mar 2001 07:51:45 +0100, Stefan Bodewig wrote:

>David J. Iannucci <dj...@myriad.com> wrote:
>
>> The <fileset> task allows you to choose a set of files
>> based on file names, but how about on file _types_?
>
>This is not possible for a fileset, at least not now. The <execon>
>task and its relatives <apply> and <chmod> support a type attribute to
>filter based on file type.
>

I have a submission on the ant-dev list that would support this. It
would work as follows:

...
  <fileset dir="\tmp\fromDir">
    <AttributeFileCuller fileDir="dir" />
  </fileset>
...

I am not sure what it status on being accepted is. If I hear more I
will reply here.

d

Re: Finding file types in

Posted by Stefan Bodewig <bo...@apache.org>.
David J. Iannucci <dj...@myriad.com> wrote:

> The <fileset> task allows you to choose a set of files
> based on file names, but how about on file _types_?

This is not possible for a fileset, at least not now. The <execon>
task and its relatives <apply> and <chmod> support a type attribute to
filter based on file type.

Stefan