ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Womack <>
Subject RE: per directory make file?
Date Wed, 27 Jun 2001 17:34:55 GMT
Will, thanks for the reply.

I don't think this will work for a dynamic set of possible subdirectories.
Maybe I missed it, but I haven't found anything in ant that will let me
traverse through subdirecotries, calling a task for each one.  So, I would
need to know all of the subdirectories upfront.  In my case, there are
probably hundreds.  And it still doesn't let me omit or exclude a set of
arbitrary files (which would be directory specific, not pattern specific).

I have been thinking about what solution I'd like to see, so let me describe
it.  Maybe it will ring a bell with someone out there.

The javac command is given a source directory to compile from and a
destination direcotry to store the resulting classes.  It supports fileset
entities that give you control over which files get compiled.  This is great
for most cases.  I prefer this, as I said before, because it kind of forces
you to keep only relevant code in the source tree.

However, I know that some of my colleagues are going to say they want to
have files in the source tree that should not be compiled with the normal
build.  How can I exclude those files from the javac compile?  The way it is
done with the current make is to define a "makefile" per directory.  This
file contains the list of "relevant" files for that directory, and is used
by the top level make to decide which files to compile.

Something similar could be done for the current javac command, I think.  If
I could define a fileset-like description that says "walk all of the
subdirectories.  if you find a file named "makefile", add the files listed
inside of it to the list of files to compile.  otherwise, add all of the
files in the directory to the list of files to compile."  You could use this
mechanism to exclude contents of subdirectories by having an empty
"makefile", or you could have only a specific set of files included.  And if
the entire subdirectory should be included, then have no make file at all.
This way the javac would only be called once for a directory, which is a
real time saver compared to our current make (1 minute vs 12 minutes), but
you could have very fine tuned control over the set of files that gets
compiled outside of the make file itself.  Of course, you now have the
overhead and dependency on the contents of all these makefiles.  There is
potential to mess things up.

I could swear I heard mention of a mechanism like this for ant on this
mailing list.  But maybe I am hallucinating.  If anyone has any other ideas,
I would love to hear about them.  I'll be looking at the ant code to see how
hard it would be to implement what I'm talking about above.


-----Original Message-----
From: []
Sent: Tuesday, June 26, 2001 1:25 PM
Subject: Re: per directory make file?

Regarding the per directory make file, this is simply done with the <ant>

<ant dir="${subproject.dir}" target="build">

The only key thing to note here is that any properties set within the
"master" build.xml file will bubble down into the dependant build.xml.

Other than that, this works just peachy.


Will Hartung

----- Original Message -----
From: "Kyle Adams" <>
To: <>
Sent: Tuesday, June 26, 2001 12:49 PM
Subject: Re: per directory make file?


I posted a similar question today (see "Build script design issues").  I
wonder if there are any more articles out there on best practices for Ant
scripts - the articles I've read so far have not been that specific.  I'm
looking forward to see what responses we get to our question.


>>> 06/26/01 03:10PM >>>
I am in the process of creating an ant replacement for our current make file
build.  We have a make file per directory that specifies which files within
that directory should be compiled.  This allows our developers to have files
in the source tree that are not built as part of the normal build.

Is there a similar method/task for ant?  I thought I heard mention of a
similar task on this mailing list, but I cannot find it in the archives.

What is considered a best practice in regards to this?  I prefer having just
the required files in the source tree, and having the auxilary files in
another tree.  Then we can just use the javac task directly to compile all
the files.  But I can see where some flexibility is useful.


View raw message