You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ma...@i2.com on 2000/11/09 01:35:58 UTC

Combining PatternSets with Path elements

Hi all,

Sorry for the length of this email, but I figured some background might
help in describing what I want to do.

We are currently using GNU make for our builds, but I thought I would give
ant a go in the hopes of cleaning things up a bit.  First a little
background of what we are currently doing.

Our current build system has blah.mk files specifying settings for each
project,  with each of those pulling in a master.mk which has all the build
logic based upon manipulations of the variables set in the .mk file.  This
has the benefit that end users don't have to know make in order to do the
day to day maintenance of their projects - all they have to do is set a few
make variables, and the master.mk takes care of all the details.

Our source tree has a single root, and we break it up into components based
on a list of package names specified in the .mk file, thus component1 could
specify com.foo.util and com.foo.bar as its packages, and would result in a
jar containing the result of compiling all the java files in those
directories ONLY - no subdirectories get pulled in, so com.foo.util.baz
would not be in component1's jar.  This is important to save on build time
as we have some large components that take forever to build and are
mutually exclusive.

I'd like to keep my ant system as close to this as possible, but have run
into a few problems.  What I'd like to do is to be able have individual
project xml files which pull in a master build.xml file which has all the
real logic.  I've seen examples of pulling in files in the mail list
archives, so that shouldn't be a problem.  Where I get stuck is figuring
out how to be able to specify a list of package directories in the project
xml and then be able to use that list to limit my make rules to those
directories, i.e. my javac task would only compile the java files in those
directories, my ejbcompiler task would only process the ejbs in those
directories, etc.  In my make files, how a file is processed is usually
based on an extension or pattern in the filename, so what I would like to
be able to do is somehow combine (set union) a path element with a
patternset element to produce a fileset element, and then have my tasks
reference and operate on that fileset.  Basically, I don't want each user
to have to specify the same list of directories over and over again with
different patterns.

Is there a way to do this?  If not, is there a more "ant friendly" way to
do something similar to achieve the same goals (simple project files,
exclusive builds of packages within the same source tree)?  Thanks,

Matt






Re: Combining PatternSets with Path elements

Posted by Stefan Bodewig <bo...@bost.de>.
Matt Conway <Ma...@i2.com> wrote:

> Our source tree has a single root, and we break it up into
> components based on a list of package names specified in the .mk
> file, thus component1 could specify com.foo.util and com.foo.bar as
> its packages, and would result in a jar containing the result of
> compiling all the java files in those directories ONLY - no
> subdirectories get pulled in, so com.foo.util.baz would not be in
> component1's jar.

This translates to

<patternset id="component1">
  <include name="**/com/foo/util/*" />
  <include name="**/com/foo/bar/*" />
</patternset>

you could even use patternset's includesfile attribute to keep the
patterns outside of the buildfiles. Note the single * at the end of
each pattern to exclude subpackages.

> Where I get stuck is figuring out how to be able to specify a list
> of package directories in the project xml and then be able to use
> that list to limit my make rules to those directories, i.e. my javac
> task would only compile the java files in those directories, my
> ejbcompiler task would only process the ejbs in those directories,
> etc.

<javac>
  <patternset refid="component1" />
</javac>

for example.

Unfortunately not all tasks support patternsets as the should, javadoc
being a prominent exception.

I think this is what you've been asking for, but I'm not sure.

Stefan