ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@bost.de>
Subject Re: Combining PatternSets with Path elements
Date Wed, 15 Nov 2000 10:42:51 GMT
Matt Conway <Matt_Conway@i2.com> wrote:

> An alternative approach, would be some way to combine a path element
> with a pattern to produce a patternset.

Are you serious?

OK, let's take a detailed look.

> <path id="packages">
>      <pathelement location="com/foo/util" />
>      <pathelement location="com/foo/bar" />
> </path>

Note that the <pathelement>s will translate into absolute paths, this
means you'd get a PATH like
${basedir}/com/foo/util:${basedir}/com/foo/bar on Unix systems. Having
absolute paths here makes them useless for building patterns (as
patterns are relative to the surrounding fileset's dir).

So what could be achieved is creating filesets by filtering paths
through patternsets (making each path component the dir attribute of a
fileset and applying the patternset to it).

Say we had something like

<filesets usepath="packages" applypatterns="patternsets" />

that could be used anywhere where you can place multiple filesets
right now. I'm just making up the syntax as I write, I'm not proposing
something here, just playing and trying to see where it leads us to.

The original use case was something like (1) define a set of packages
my module consists of, (2) compile only those packages and (3) copy
all .xml from those packages to a destination directory.

Starting with your path definition above as (1) and my made up
filesets element number (3) was easy:

<patternset id="xmlfiles">
  <include name="*.xml">
</patternset>

<copy todir="${dest}">
  <filesets usepath="packages" applypatterns="xmlfiles" />
</copy>

But now we get into another problem, the <javac> won't work
anymore. <javac> doesn't handle filesets at all, it's <src> element is
a PATH. Great, we already defined our packages as a path, so

<javac>
  <src refid="packages" />
</javac>

is what we want, right? Unfortunately no, it's close but not
quite. 

<javac> expects the directories making up its <src> to point to the
top of a file hierarchy - if you don't do so (and our example doesn't)
Ant will be unable to decide which files have changed since the last
compile and therefore always compile everything.

Stefan

Mime
View raw message