You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Vincent Massol <vm...@pivolis.com> on 2003/06/13 14:29:16 UTC

New feature: filtering

Hi,

I've just committed a new feature in CVS: filtering of runtime resources
and test resources. I've also committed a sample project that shows how
to use it, in src/plugins-build/examples/simple-filtering

Basically, whenever you want to filter some tokens in resources, use the
following syntax in your project.xml:

  <build>
  	<sourceDirectory>src/java</sourceDirectory>

    <resources>
      <resource>
-->     <filtering>true</filtering>
        <directory>src/conf</directory>
        <includes>
          <include>test.properties</include>
        </includes>
      </resource>
      <resource>
        <directory>src/conf</directory>
        <includes>
          <include>test-nofilter.properties</include>
        </includes>
      </resource>
    </resources>

  </build>

Then write a pregoal on java:jar-resources or test:test-resources in
your project's maven.xml and create your Ant filter tokens there.

By default, filtering is off.

NOTE: For some unknown reasons the filtering does not seem to work yet
on the simple-filtering project. Not sure why... I'm debugging it...
Help welcome :-)

Thanks
-Vincent


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: New feature: filtering

Posted by Vincent Massol <vm...@pivolis.com>.

> -----Original Message-----
> From: Brett Porter [mailto:bporter@f2network.com.au]
> Sent: 16 June 2003 08:07
> To: Maven Developers List
> Subject: Re: New feature: filtering
> 
> > BTW, do you have any idea why the sample-filtering project in
> > plugin-builds/examples does not work WRT filtering?
> 
> You've placed the "filtering" attribute on the "fileset" tag. It
should
> be on the "copy" tag.
> 

arg! You're right... I have been looking into the eye for a few hours
without finding the problem... Pair-programming/reviewing is nice :-)
Thanks.

> Also, test-nofilter should contain "@testFilter@" so you can check it
is
> not replaced.

Yep. Good idea. Done.

-Vincent

> 
> Cheers,
> Brett
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: New feature: filtering

Posted by Brett Porter <bp...@f2network.com.au>.
> BTW, do you have any idea why the sample-filtering project in
> plugin-builds/examples does not work WRT filtering?

You've placed the "filtering" attribute on the "fileset" tag. It should 
be on the "copy" tag.

Also, test-nofilter should contain "@testFilter@" so you can check it is 
not replaced.

Cheers,
Brett


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: New feature: filtering

Posted by Brett Porter <bp...@f2network.com.au>.
> I'm not fussy about the syntax but I do not want to bind the filtering
> to Ant.

Why don't we keep @...@ syntax by default, but allow configuration (as 
does Ant). I think we can reuse the POM definition to configure Ant 
filtersets for those that want to use it, but if we remove 
<resources:copy/> and replace it with a Java class, then that class can 
still use these tags in the same way. I think we need to specify files 
to load filters from, and perhaps token/value pairs in the POM for 
simpler cases. Both can work.

IMHO the fact that you have Ant underlying has been the most powerful 
aspect of Maven, and has made it so useful in our environment. While I 
understand the difficulties being had with Jelly, it is adding something 
very useful.

Cheers,
Brett

-- 
Web Developer
f2 network ~ everything essential
02 8596 4437


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: New feature: filtering

Posted by Jason van Zyl <ja...@zenplex.com>.
On Mon, 2003-06-16 at 09:48, Vincent Massol wrote:
>  
> > > I don't have the full picture of what you're doing though...
> > 
> > I'm trying to trace down the memory leak and sequentially going
> through
> > a list of suspect points of leakage.
> 
> That's cool :-)

Yes, well I'm trying but so far to no avail. I'll keep hunting tonight.

> -Vincent
> [snip]
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
-- 
jvz.

Jason van Zyl
jason@zenplex.com
http://tambora.zenplex.org

In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.
  
  -- Jacques Ellul, The Technological Society


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: New feature: filtering

Posted by Vincent Massol <vm...@pivolis.com>.

> -----Original Message-----
> From: Jason van Zyl [mailto:jason@zenplex.com]
> Sent: 16 June 2003 15:47
> To: Maven Developers List
> Subject: RE: New feature: filtering
> 
> On Mon, 2003-06-16 at 09:39, Vincent Massol wrote:
> 
> > Filtering is working right now for runtime and test resources... We
can
> > get the release out the door (on this subject). I don't see how
> > rewriting our filtering support and in addition writing some
additional
> > java code can help improve the delivery speed... :-)
> 
> I've have a series of changes I've tried to make and I'm trying to be
> conservative with what I'm changing and I get other side effect
> problems. Instead of tracking things down in Jelly I prefer just to
> write a Java class that I can write tests for easily and be done with
> it.
> 
> > I don't have the full picture of what you're doing though...
> 
> I'm trying to trace down the memory leak and sequentially going
through
> a list of suspect points of leakage.

That's cool :-)

-Vincent
[snip]



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: New feature: filtering

Posted by Jason van Zyl <ja...@zenplex.com>.
On Mon, 2003-06-16 at 09:39, Vincent Massol wrote:

> Filtering is working right now for runtime and test resources... We can
> get the release out the door (on this subject). I don't see how
> rewriting our filtering support and in addition writing some additional
> java code can help improve the delivery speed... :-)

I've have a series of changes I've tried to make and I'm trying to be
conservative with what I'm changing and I get other side effect
problems. Instead of tracking things down in Jelly I prefer just to
write a Java class that I can write tests for easily and be done with
it.

> I don't have the full picture of what you're doing though...

I'm trying to trace down the memory leak and sequentially going through
a list of suspect points of leakage.

> -Vincent
> 
> > > Thanks
> > > -Vincent
> > >
> > > >
> > > > --
> > > > jvz.
> > > >
> > > > Jason van Zyl
> > > > jason@zenplex.com
> > > > http://tambora.zenplex.org
> > > >
> > > > In short, man creates for himself a new religion of a rational
> > > > and technical order to justify his work and to be justified in it.
> > > >
> > > >   -- Jacques Ellul, The Technological Society
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > > > For additional commands, e-mail: dev-help@maven.apache.org
> > >
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: dev-help@maven.apache.org
> > --
> > jvz.
> > 
> > Jason van Zyl
> > jason@zenplex.com
> > http://tambora.zenplex.org
> > 
> > In short, man creates for himself a new religion of a rational
> > and technical order to justify his work and to be justified in it.
> > 
> >   -- Jacques Ellul, The Technological Society
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
-- 
jvz.

Jason van Zyl
jason@zenplex.com
http://tambora.zenplex.org

In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.
  
  -- Jacques Ellul, The Technological Society


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: New feature: filtering

Posted by Vincent Massol <vm...@pivolis.com>.

> -----Original Message-----
> From: Jason van Zyl [mailto:jason@zenplex.com]
> Sent: 16 June 2003 15:24
> To: Maven Developers List
> Subject: RE: New feature: filtering
> 
> On Mon, 2003-06-16 at 04:44, Vincent Massol wrote:
> 
> > And you can re-use any of these without having to go through an XML
> > script file of course. Why would you want to reinvent the wheel?
> 
> Because everytime I take this line of thought I end up spending
> monumental amounts of time because I run into strange oddities because
> of coupling with the Ant project. For this particular task I don't
need
> any Ant code. I want to get this release out the door.
> 

Filtering is working right now for runtime and test resources... We can
get the release out the door (on this subject). I don't see how
rewriting our filtering support and in addition writing some additional
java code can help improve the delivery speed... :-)

I don't have the full picture of what you're doing though...

-Vincent

> > Thanks
> > -Vincent
> >
> > >
> > > --
> > > jvz.
> > >
> > > Jason van Zyl
> > > jason@zenplex.com
> > > http://tambora.zenplex.org
> > >
> > > In short, man creates for himself a new religion of a rational
> > > and technical order to justify his work and to be justified in it.
> > >
> > >   -- Jacques Ellul, The Technological Society
> > >
> > >
> > >
---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: dev-help@maven.apache.org
> >
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> --
> jvz.
> 
> Jason van Zyl
> jason@zenplex.com
> http://tambora.zenplex.org
> 
> In short, man creates for himself a new religion of a rational
> and technical order to justify his work and to be justified in it.
> 
>   -- Jacques Ellul, The Technological Society
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: New feature: filtering

Posted by Jason van Zyl <ja...@zenplex.com>.
On Mon, 2003-06-16 at 04:44, Vincent Massol wrote:

> And you can re-use any of these without having to go through an XML
> script file of course. Why would you want to reinvent the wheel?

Because everytime I take this line of thought I end up spending
monumental amounts of time because I run into strange oddities because
of coupling with the Ant project. For this particular task I don't need
any Ant code. I want to get this release out the door.

> Thanks
> -Vincent
> 
> > 
> > --
> > jvz.
> > 
> > Jason van Zyl
> > jason@zenplex.com
> > http://tambora.zenplex.org
> > 
> > In short, man creates for himself a new religion of a rational
> > and technical order to justify his work and to be justified in it.
> > 
> >   -- Jacques Ellul, The Technological Society
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
-- 
jvz.

Jason van Zyl
jason@zenplex.com
http://tambora.zenplex.org

In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.
  
  -- Jacques Ellul, The Technological Society


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: New feature: filtering

Posted by Vincent Massol <vm...@pivolis.com>.

> -----Original Message-----
> From: Jason van Zyl [mailto:jason@zenplex.com]
> Sent: 16 June 2003 10:35
> To: Maven Developers List
> Subject: Re: New feature: filtering
> 
> On Mon, 2003-06-16 at 03:20, Brett Porter wrote:
> > > oh, ok. I thought you wanted to put the filter in the POM... If
it's
> > > just the filtersets, then, yes I agree. However, I'm not sure I
like
> the
> > > format:
> > >
> > > <resources>
> > >   <filters>
> > >     <id>my.filters</id>
> > >     <directory>${basedir}/../filters</directory>
> > >     <includes>
> > >       <include>**/*.properties</include>
> > >     </includes>
> > >   </filters>
> > >   <resource>
> > >     <filtersets>
> > >       <filterset>my.filters</filterset>
> > >       <filterset>base.filters</filterset>
> > >     </filtersets>
> > >        ...
> > >   </resource>
> > > [...]
> > >
> > > I much prefer:
> > >
> > > <resources>
> > >   <resource>
> > >     <filtering>true</filtering>
> > >     <filtersets>
> > >       <filterset>filtersetid1</filterset>
> > >       <filterset>filtersetid2</filterset>
> > >     </filtersets>
> > >     <directory>${basedir}/../filters</directory>
> > >     <includes>
> > >       <include>**/*.properties</include>
> > >     </includes>
> > >   </resource>
> > > [...]
> > >
> >
> > I'm happy either way - its just a matter of whether filters get into
the
> > POM or just maven.xml.
> 
> I would be much happier with the filters being setup in the POM or
> something that has nothing to do with Ant. I was going to port the
> resource handling code to a small Java class because the expression
> handling with Jexl is very brittle. While trying to make some very
> simple changes things are breaking and I'm finding it's just easier to
> make a small Java class than fight with Jelly all day. I realize most
of
> my problems are with Jexl but moving this code to Java is much
simpler.
> 
> If you can figure out how you want to specify the filters I have the
> code to handle copying resources with @FOO@ type tokens within.
> 
> I'm not fussy about the syntax but I do not want to bind the filtering
> to Ant.

Jason, I have some trouble following your line of thought. Ant is java
based:

http://cvs.apache.org/viewcvs.cgi/ant/src/main/org/apache/tools/ant/filt
ers/

http://cvs.apache.org/viewcvs.cgi/ant/src/main/org/apache/tools/ant/type
s/

http://cvs.apache.org/viewcvs.cgi/ant/src/main/org/apache/tools/ant/task
defs/Filter.java

And you can re-use any of these without having to go through an XML
script file of course. Why would you want to reinvent the wheel?

Thanks
-Vincent

> 
> --
> jvz.
> 
> Jason van Zyl
> jason@zenplex.com
> http://tambora.zenplex.org
> 
> In short, man creates for himself a new religion of a rational
> and technical order to justify his work and to be justified in it.
> 
>   -- Jacques Ellul, The Technological Society
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: New feature: filtering

Posted by Jason van Zyl <ja...@zenplex.com>.
On Mon, 2003-06-16 at 03:20, Brett Porter wrote:
> > oh, ok. I thought you wanted to put the filter in the POM... If it's
> > just the filtersets, then, yes I agree. However, I'm not sure I like the
> > format:
> > 
> > <resources>
> >   <filters>
> >     <id>my.filters</id>
> >     <directory>${basedir}/../filters</directory>
> >     <includes>
> >       <include>**/*.properties</include>
> >     </includes>
> >   </filters>
> >   <resource>
> >     <filtersets>
> >       <filterset>my.filters</filterset>
> >       <filterset>base.filters</filterset>
> >     </filtersets>
> >        ...
> >   </resource> 
> > [...]
> > 
> > I much prefer:
> > 
> > <resources>
> >   <resource>
> >     <filtering>true</filtering>
> >     <filtersets>
> >       <filterset>filtersetid1</filterset>
> >       <filterset>filtersetid2</filterset>
> >     </filtersets>
> >     <directory>${basedir}/../filters</directory>
> >     <includes>
> >       <include>**/*.properties</include>
> >     </includes>
> >   </resource>
> > [...]
> > 
> 
> I'm happy either way - its just a matter of whether filters get into the 
> POM or just maven.xml.

I would be much happier with the filters being setup in the POM or
something that has nothing to do with Ant. I was going to port the
resource handling code to a small Java class because the expression
handling with Jexl is very brittle. While trying to make some very
simple changes things are breaking and I'm finding it's just easier to
make a small Java class than fight with Jelly all day. I realize most of
my problems are with Jexl but moving this code to Java is much simpler.

If you can figure out how you want to specify the filters I have the
code to handle copying resources with @FOO@ type tokens within.

I'm not fussy about the syntax but I do not want to bind the filtering
to Ant.

-- 
jvz.

Jason van Zyl
jason@zenplex.com
http://tambora.zenplex.org

In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.
  
  -- Jacques Ellul, The Technological Society


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: New feature: filtering

Posted by Brett Porter <bp...@f2network.com.au>.
> Although I don't quite agree, I've applied it for now. The part that I
> don't like is that copying will be done all the time when there are
> filters, even if the file or the filter value have not changed...

This has always been an issue with ant filtering. The only option you 
have is to set up some uptodate based copying, but that means you must 
know where the filters come from. I guess you could uptodate on the 
maven.xml's, but its a bit hokey...

I've never found the extra copying to impact speed too much.

- Brett


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: New feature: filtering

Posted by Vincent Massol <vm...@pivolis.com>.

> -----Original Message-----
> From: Brett Porter [mailto:bporter@f2network.com.au]
> Sent: 16 June 2003 09:21
> To: Maven Developers List
> Subject: Re: New feature: filtering
> 
> > oh, ok. I thought you wanted to put the filter in the POM... If it's
> > just the filtersets, then, yes I agree. However, I'm not sure I like
the
> > format:
> >
> > <resources>
> >   <filters>
> >     <id>my.filters</id>
> >     <directory>${basedir}/../filters</directory>
> >     <includes>
> >       <include>**/*.properties</include>
> >     </includes>
> >   </filters>
> >   <resource>
> >     <filtersets>
> >       <filterset>my.filters</filterset>
> >       <filterset>base.filters</filterset>
> >     </filtersets>
> >        ...
> >   </resource>
> > [...]
> >
> > I much prefer:
> >
> > <resources>
> >   <resource>
> >     <filtering>true</filtering>
> >     <filtersets>
> >       <filterset>filtersetid1</filterset>
> >       <filterset>filtersetid2</filterset>
> >     </filtersets>
> >     <directory>${basedir}/../filters</directory>
> >     <includes>
> >       <include>**/*.properties</include>
> >     </includes>
> >   </resource>
> > [...]
> >
> 
> I'm happy either way - its just a matter of whether filters get into
the
> POM or just maven.xml.
> 
> However, I'd leave <filtering> out if there is filtersets - as you can
> derive filtering from !filtersets.isEmpty()
> 
> Also, you didn't put overwrite="true" into the copy in the cvs commit
I
> noticed. To see what I mean, try this:
> ----- snip -----
> $ maven java:jar-resources
> ...
> $ cat target/classes/test.properties
> # A simple config file with an Ant filter
> 
> test.property = it worked!
> ----- snip -----
> Now edit maven.xml so the property is "it still works!", and run again
> ----- snip -----
> $ maven java:jar-resources
> ...
> $ cat target/classes/test.properties
> # A simple config file with an Ant filter
> 
> test.property = it worked!
> ----- snip -----
> 
> You need the overwrite flag :)

Although I don't quite agree, I've applied it for now. The part that I
don't like is that copying will be done all the time when there are
filters, even if the file or the filter value have not changed...

-Vincent

> 
> Cheers,
> Brett
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: New feature: filtering

Posted by Brett Porter <bp...@f2network.com.au>.
> oh, ok. I thought you wanted to put the filter in the POM... If it's
> just the filtersets, then, yes I agree. However, I'm not sure I like the
> format:
> 
> <resources>
>   <filters>
>     <id>my.filters</id>
>     <directory>${basedir}/../filters</directory>
>     <includes>
>       <include>**/*.properties</include>
>     </includes>
>   </filters>
>   <resource>
>     <filtersets>
>       <filterset>my.filters</filterset>
>       <filterset>base.filters</filterset>
>     </filtersets>
>        ...
>   </resource> 
> [...]
> 
> I much prefer:
> 
> <resources>
>   <resource>
>     <filtering>true</filtering>
>     <filtersets>
>       <filterset>filtersetid1</filterset>
>       <filterset>filtersetid2</filterset>
>     </filtersets>
>     <directory>${basedir}/../filters</directory>
>     <includes>
>       <include>**/*.properties</include>
>     </includes>
>   </resource>
> [...]
> 

I'm happy either way - its just a matter of whether filters get into the 
POM or just maven.xml.

However, I'd leave <filtering> out if there is filtersets - as you can 
derive filtering from !filtersets.isEmpty()

Also, you didn't put overwrite="true" into the copy in the cvs commit I 
noticed. To see what I mean, try this:
----- snip -----
$ maven java:jar-resources
...
$ cat target/classes/test.properties
# A simple config file with an Ant filter

test.property = it worked!
----- snip -----
Now edit maven.xml so the property is "it still works!", and run again
----- snip -----
$ maven java:jar-resources
...
$ cat target/classes/test.properties
# A simple config file with an Ant filter

test.property = it worked!
----- snip -----

You need the overwrite flag :)

Cheers,
Brett





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: New feature: filtering

Posted by Vincent Massol <vm...@pivolis.com>.

> -----Original Message-----
> From: Brett Porter [mailto:bporter@f2network.com.au]
> Sent: 16 June 2003 07:21
> To: Maven Developers List
> Subject: Re: New feature: filtering
> 
> > Why is that? I never use the "overwrite" attribute and all my
filtering
> > work fine...
> 
> change a filter, but don't touch the file that will be filtered - Ant
> (at least last time I checked) doesn't copy the file again, leaving it
> with the old value.
> 
> >
> > BTW, do you have any idea why the sample-filtering project in
> > plugin-builds/examples does not work WRT filtering?
> >
> 
> Haven't looked - I'll check it out when I have a chance.
> 
> > Hmmm.... Not sure. It seems to me that it is complicating the POM
quite
> > a bit. Also, I'd prefer the following format:
> >
> > <resource>
> >   <filters>
> >      <filter>
> >        <token/>
> >        <value/>
> >      </filter>
> >   </filters>
> >   [...]
> > </resource>
> >
> > I'm curious to see what other think.
> 
> I have ~100 tokens to filter in our large project. I think that might
> complicate the POM more :)
> 
> I've happy to just have a yes/no flag for filtering, as long as you
can
> specify a list of files and/or tokens to read them from. I just
thought
> the filterset solution was as clean, and allowed finer-grained control
> if you need it.
> 

oh, ok. I thought you wanted to put the filter in the POM... If it's
just the filtersets, then, yes I agree. However, I'm not sure I like the
format:

<resources>
  <filters>
    <id>my.filters</id>
    <directory>${basedir}/../filters</directory>
    <includes>
      <include>**/*.properties</include>
    </includes>
  </filters>
  <resource>
    <filtersets>
      <filterset>my.filters</filterset>
      <filterset>base.filters</filterset>
    </filtersets>
       ...
  </resource> 
[...]

I much prefer:

<resources>
  <resource>
    <filtering>true</filtering>
    <filtersets>
      <filterset>filtersetid1</filterset>
      <filterset>filtersetid2</filterset>
    </filtersets>
    <directory>${basedir}/../filters</directory>
    <includes>
      <include>**/*.properties</include>
    </includes>
  </resource>
[...]

Where filtersetid1 is a filter set id defined somewhere in the project's
maven.xml

-Vincent

> Cheers,
> Brett


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: New feature: filtering

Posted by Brett Porter <bp...@f2network.com.au>.
> Why is that? I never use the "overwrite" attribute and all my filtering
> work fine...

change a filter, but don't touch the file that will be filtered - Ant 
(at least last time I checked) doesn't copy the file again, leaving it 
with the old value.

> 
> BTW, do you have any idea why the sample-filtering project in
> plugin-builds/examples does not work WRT filtering?
> 

Haven't looked - I'll check it out when I have a chance.

> Hmmm.... Not sure. It seems to me that it is complicating the POM quite
> a bit. Also, I'd prefer the following format:
> 
> <resource>
>   <filters>
>      <filter>
>        <token/>
>        <value/>
>      </filter>
>   </filters>
>   [...]
> </resource>
> 
> I'm curious to see what other think.

I have ~100 tokens to filter in our large project. I think that might 
complicate the POM more :)

I've happy to just have a yes/no flag for filtering, as long as you can 
specify a list of files and/or tokens to read them from. I just thought 
the filterset solution was as clean, and allowed finer-grained control 
if you need it.

Cheers,
Brett




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: New feature: filtering

Posted by Vincent Massol <vm...@pivolis.com>.

> -----Original Message-----
> From: Brett Porter [mailto:bporter@f2network.com.au]
> Sent: 16 June 2003 06:59
> To: Maven Developers List
> Subject: Re: New feature: filtering
> 
> Hi Vincent,
> 
> This is great! However, there is one problem: you'll need to add
> <fileset ... overwrite="${resource.filtering}"> as well, as overwrite
> needs to be enabled for filtering.

Why is that? I never use the "overwrite" attribute and all my filtering
work fine...

BTW, do you have any idea why the sample-filtering project in
plugin-builds/examples does not work WRT filtering?

> 
> Also, I'd prefer to see filter loading incorporated into the POM.
> <build>
>    <resources>
>      <filters>
>        <id>my.filters</id>
>        <directory>${basedir}/../filters</directory>
>        <includes>
>          <include>**/*.properties</include>
>        </includes>
>      </filters>
>      <resource>
>        <filtersets>
>          <filterset>my.filters</filterset>
>          <filterset>base.filters</filterset>
>        </filtersets>
>        ...
>      </resource>
>    </resources>
> </build>
> 
> Resulting copy:
> <fileset dir="..." overwrite="${!resources.filtersets.isEmpty()}">
>    ...
>    <j:forEach var="filterset" items="${resources.filtersets}">
>      <filterset refid="${filterset}"/>
>    </j:forEach>
> </fileset>
> 
> I'd be happy to implement this if others agree this belongs in the
POM.

Hmmm.... Not sure. It seems to me that it is complicating the POM quite
a bit. Also, I'd prefer the following format:

<resource>
  <filters>
     <filter>
       <token/>
       <value/>
     </filter>
  </filters>
  [...]
</resource>

I'm curious to see what other think.

Thanks
-Vincent

> 
> - Brett
> 
> Vincent Massol wrote:
> > Hi,
> >
> > I've just committed a new feature in CVS: filtering of runtime
resources
> > and test resources. I've also committed a sample project that shows
how
> > to use it, in src/plugins-build/examples/simple-filtering
> >
> > Basically, whenever you want to filter some tokens in resources, use
the
> > following syntax in your project.xml:
> >
> >   <build>
> >   	<sourceDirectory>src/java</sourceDirectory>
> >
> >     <resources>
> >       <resource>
> > -->     <filtering>true</filtering>
> >         <directory>src/conf</directory>
> >         <includes>
> >           <include>test.properties</include>
> >         </includes>
> >       </resource>
> >       <resource>
> >         <directory>src/conf</directory>
> >         <includes>
> >           <include>test-nofilter.properties</include>
> >         </includes>
> >       </resource>
> >     </resources>
> >
> >   </build>
> >
> > Then write a pregoal on java:jar-resources or test:test-resources in
> > your project's maven.xml and create your Ant filter tokens there.
> >
> > By default, filtering is off.
> >
> > NOTE: For some unknown reasons the filtering does not seem to work
yet
> > on the simple-filtering project. Not sure why... I'm debugging it...
> > Help welcome :-)
> >
> > Thanks
> > -Vincent
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> 
> --
> Web Developer
> f2 network ~ everything essential
> 02 8596 4437
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: New feature: filtering

Posted by Brett Porter <bp...@f2network.com.au>.
Hi Vincent,

This is great! However, there is one problem: you'll need to add 
<fileset ... overwrite="${resource.filtering}"> as well, as overwrite 
needs to be enabled for filtering.

Also, I'd prefer to see filter loading incorporated into the POM.
<build>
   <resources>
     <filters>
       <id>my.filters</id>
       <directory>${basedir}/../filters</directory>
       <includes>
         <include>**/*.properties</include>
       </includes>
     </filters>
     <resource>
       <filtersets>
         <filterset>my.filters</filterset>
         <filterset>base.filters</filterset>
       </filtersets>
       ...
     </resource>
   </resources>
</build>

Resulting copy:
<fileset dir="..." overwrite="${!resources.filtersets.isEmpty()}">
   ...
   <j:forEach var="filterset" items="${resources.filtersets}">
     <filterset refid="${filterset}"/>
   </j:forEach>
</fileset>

I'd be happy to implement this if others agree this belongs in the POM.

- Brett

Vincent Massol wrote:
> Hi,
> 
> I've just committed a new feature in CVS: filtering of runtime resources
> and test resources. I've also committed a sample project that shows how
> to use it, in src/plugins-build/examples/simple-filtering
> 
> Basically, whenever you want to filter some tokens in resources, use the
> following syntax in your project.xml:
> 
>   <build>
>   	<sourceDirectory>src/java</sourceDirectory>
> 
>     <resources>
>       <resource>
> -->     <filtering>true</filtering>
>         <directory>src/conf</directory>
>         <includes>
>           <include>test.properties</include>
>         </includes>
>       </resource>
>       <resource>
>         <directory>src/conf</directory>
>         <includes>
>           <include>test-nofilter.properties</include>
>         </includes>
>       </resource>
>     </resources>
> 
>   </build>
> 
> Then write a pregoal on java:jar-resources or test:test-resources in
> your project's maven.xml and create your Ant filter tokens there.
> 
> By default, filtering is off.
> 
> NOTE: For some unknown reasons the filtering does not seem to work yet
> on the simple-filtering project. Not sure why... I'm debugging it...
> Help welcome :-)
> 
> Thanks
> -Vincent
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org

-- 
Web Developer
f2 network ~ everything essential
02 8596 4437


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org