You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Carsten Ziegeler <cz...@apache.org> on 2005/08/19 14:20:49 UTC
[M2] How does filtering resources work?
I'm a little confused how filtering of resources in M2 works.
Now, I can define several resource sets in the build resources
section (with include/exclude) patterns. But there is no way
of defining filters there. (At least that's what I think).
Now I can turn on filtering in the resources plugin. I guess without
any additional configuration, this enables filtering for *all* resources.
So if I only want to filter one resource set (defined in the build
section), do I have to specify the same resources in the plugin
configuration as well? Wouldn't it be better to define the filters
directly at the resources in the build section?
On the same topic, is it possible to have filters that replace tokens
with values from the pom, like project name or version?
Thanks
Carsten
--
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [M2] How does filtering resources work?
Posted by Brett Porter <br...@gmail.com>.
I thinhk we should bounce this off the maven developer list first, but
I'm thinking it is reasonable.
- Brett
On 8/23/05, Carsten Ziegeler <cz...@apache.org> wrote:
> If I'm not the only one who thinks that filters directly defined at the
> resources is a good idea, I could try to develop a patch. Interested?
>
> Carsten
>
> Carsten Ziegeler wrote:
> > Hi Brett,
> >
> > Brett Porter wrote:
> >
> >>There was some hesitation to adding filtering in the first place - we
> >>added it as a parameter on the resources plugin because it was
> >>uncertain it would be retained in the POM. It now looks like it will,
> >>but we're wary of how it is used.
> >>
> >>It is important for Maven to work that the values filtered in are
> >>always the same if the artifact being built is the same. If you want
> >>to build 2 different artifacts, you use 2 profiles (or two projects),
> >>and provide different filters to each.
> >
> > Ok, agree.
> >
> >
> >>I'm curious why you need different filters for different sets of files
> >>- do they have changing values or is it just an "optimisation"?
> >
> > Kind of optimization and I don't want to filter binary files. So I
> > thought of creating one resource set with "ascii files" and one for
> > the binary files and apply filtering only to the first set to be sure
> > that the binary files don't get corrupted.
> >
> >
> >>Also, it should be noted that Maven builds in a pom.properties file
> >>into META-INF as well as a copy of pom.xml so that you can retrieve
> >>such values at runtime if needed.
> >>
> >>Anyway, I'm happy to discuss what the filtering needs are and adjust
> >>accordingly. I'm still reluctant to promote filters to the resource
> >>element itself, but it can be considered again.
> >
> > I think it makes more sense to have it at the resources element because
> > you define your resource sets and then you want to apply directly to
> > this set some filtering (or not). If you separate this (resource set and
> > plugin configuration) it's not that obvious what's really going on and
> > it makes it imho harder to apply filtering than it should be. You loose
> > the connection between the resource sets (or test resource sets) and the
> > settings of the plugin.
> >
> > WDYT?
> >
> > Carsten
>
>
> --
> Carsten Ziegeler - Open Source Group, S&N AG
> http://www.s-und-n.de
> http://www.osoco.org/weblogs/rael/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [M2] How does filtering resources work?
Posted by Ralph Pöllath <li...@poellath.org>.
On 23.08.2005, at 07:53, Carsten Ziegeler wrote:
> If I'm not the only one who thinks that filters directly defined at
> the
> resources is a good idea, I could try to develop a patch. Interested?
+1
Cheers,
-Ralph.
> Carsten
>
> Carsten Ziegeler wrote:
>
>> Hi Brett,
>>
>> Brett Porter wrote:
>>
>>
>>> There was some hesitation to adding filtering in the first place
>>> - we
>>> added it as a parameter on the resources plugin because it was
>>> uncertain it would be retained in the POM. It now looks like it
>>> will,
>>> but we're wary of how it is used.
>>>
>>> It is important for Maven to work that the values filtered in are
>>> always the same if the artifact being built is the same. If you want
>>> to build 2 different artifacts, you use 2 profiles (or two
>>> projects),
>>> and provide different filters to each.
>>>
>>
>> Ok, agree.
>>
>>
>>
>>> I'm curious why you need different filters for different sets of
>>> files
>>> - do they have changing values or is it just an "optimisation"?
>>>
>>
>> Kind of optimization and I don't want to filter binary files. So I
>> thought of creating one resource set with "ascii files" and one for
>> the binary files and apply filtering only to the first set to be sure
>> that the binary files don't get corrupted.
>>
>>
>>
>>> Also, it should be noted that Maven builds in a pom.properties file
>>> into META-INF as well as a copy of pom.xml so that you can retrieve
>>> such values at runtime if needed.
>>>
>>> Anyway, I'm happy to discuss what the filtering needs are and adjust
>>> accordingly. I'm still reluctant to promote filters to the resource
>>> element itself, but it can be considered again.
>>>
>>
>> I think it makes more sense to have it at the resources element
>> because
>> you define your resource sets and then you want to apply directly to
>> this set some filtering (or not). If you separate this (resource
>> set and
>> plugin configuration) it's not that obvious what's really going on
>> and
>> it makes it imho harder to apply filtering than it should be. You
>> loose
>> the connection between the resource sets (or test resource sets)
>> and the
>> settings of the plugin.
>>
>> WDYT?
>>
>> Carsten
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [M2] How does filtering resources work?
Posted by Carsten Ziegeler <cz...@apache.org>.
If I'm not the only one who thinks that filters directly defined at the
resources is a good idea, I could try to develop a patch. Interested?
Carsten
Carsten Ziegeler wrote:
> Hi Brett,
>
> Brett Porter wrote:
>
>>There was some hesitation to adding filtering in the first place - we
>>added it as a parameter on the resources plugin because it was
>>uncertain it would be retained in the POM. It now looks like it will,
>>but we're wary of how it is used.
>>
>>It is important for Maven to work that the values filtered in are
>>always the same if the artifact being built is the same. If you want
>>to build 2 different artifacts, you use 2 profiles (or two projects),
>>and provide different filters to each.
>
> Ok, agree.
>
>
>>I'm curious why you need different filters for different sets of files
>>- do they have changing values or is it just an "optimisation"?
>
> Kind of optimization and I don't want to filter binary files. So I
> thought of creating one resource set with "ascii files" and one for
> the binary files and apply filtering only to the first set to be sure
> that the binary files don't get corrupted.
>
>
>>Also, it should be noted that Maven builds in a pom.properties file
>>into META-INF as well as a copy of pom.xml so that you can retrieve
>>such values at runtime if needed.
>>
>>Anyway, I'm happy to discuss what the filtering needs are and adjust
>>accordingly. I'm still reluctant to promote filters to the resource
>>element itself, but it can be considered again.
>
> I think it makes more sense to have it at the resources element because
> you define your resource sets and then you want to apply directly to
> this set some filtering (or not). If you separate this (resource set and
> plugin configuration) it's not that obvious what's really going on and
> it makes it imho harder to apply filtering than it should be. You loose
> the connection between the resource sets (or test resource sets) and the
> settings of the plugin.
>
> WDYT?
>
> Carsten
--
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [M2] How does filtering resources work?
Posted by Carsten Ziegeler <cz...@apache.org>.
Hi Brett,
Brett Porter wrote:
> There was some hesitation to adding filtering in the first place - we
> added it as a parameter on the resources plugin because it was
> uncertain it would be retained in the POM. It now looks like it will,
> but we're wary of how it is used.
>
> It is important for Maven to work that the values filtered in are
> always the same if the artifact being built is the same. If you want
> to build 2 different artifacts, you use 2 profiles (or two projects),
> and provide different filters to each.
Ok, agree.
>
> I'm curious why you need different filters for different sets of files
> - do they have changing values or is it just an "optimisation"?
Kind of optimization and I don't want to filter binary files. So I
thought of creating one resource set with "ascii files" and one for
the binary files and apply filtering only to the first set to be sure
that the binary files don't get corrupted.
>
> Also, it should be noted that Maven builds in a pom.properties file
> into META-INF as well as a copy of pom.xml so that you can retrieve
> such values at runtime if needed.
>
> Anyway, I'm happy to discuss what the filtering needs are and adjust
> accordingly. I'm still reluctant to promote filters to the resource
> element itself, but it can be considered again.
I think it makes more sense to have it at the resources element because
you define your resource sets and then you want to apply directly to
this set some filtering (or not). If you separate this (resource set and
plugin configuration) it's not that obvious what's really going on and
it makes it imho harder to apply filtering than it should be. You loose
the connection between the resource sets (or test resource sets) and the
settings of the plugin.
WDYT?
Carsten
--
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [M2] How does filtering resources work?
Posted by Brett Porter <br...@gmail.com>.
There was some hesitation to adding filtering in the first place - we
added it as a parameter on the resources plugin because it was
uncertain it would be retained in the POM. It now looks like it will,
but we're wary of how it is used.
It is important for Maven to work that the values filtered in are
always the same if the artifact being built is the same. If you want
to build 2 different artifacts, you use 2 profiles (or two projects),
and provide different filters to each.
I'm curious why you need different filters for different sets of files
- do they have changing values or is it just an "optimisation"?
Also, it should be noted that Maven builds in a pom.properties file
into META-INF as well as a copy of pom.xml so that you can retrieve
such values at runtime if needed.
Anyway, I'm happy to discuss what the filtering needs are and adjust
accordingly. I'm still reluctant to promote filters to the resource
element itself, but it can be considered again.
Cheers,
Brett
On 8/20/05, Andrius Karpavicius <An...@sintagma.lt> wrote:
> Hi,
>
> I am almost an expert here, after trying to get filtering work for two
> days :)
>
>
> From resources plugin code:
>
> // support ${token}
> Reader reader = new InterpolationFilterReader( fileReader,
> filterProperties, "${", "}" );
> // support @token@
> reader = new InterpolationFilterReader( reader,
> filterProperties, "@", "@" );
>
> reader = new InterpolationFilterReader( reader, new
> ReflectionProperties( project ), "${", "}" );
>
>
> It seems like you can replace trwo things :
>
> 1. From a properties file in a format ${token} or @token@
> 2. From a POM.xml file ${project.version}
>
> To apply different filtering to diferent resources you would have to
> define resoruces as part of maven-resources-plugin configuration,
>
> Unfortunatelly I was not able to do so. It would simply ignore my
> resources settings. You can see earlier emails.
>
> Can somebory tell what is a proper way of configuring resources in
> plugin/config section, or is it a bug?
>
>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-resources-plugin</artifactId>
> <executions>
> <execution>
> <phase>compile</phase>
> <goals>
> <goal>resources</goal>
> </goals>
> <configuration>
> <resources>
> <resource>
> <targetPath>../filtered-webapp-resources</targetPath>
> <directory>${basedir}/src/main/webapp</directory>
> </resource>
> <resource>
> <targetPath>../filtered-webapp-resources/WEB-INF/classes</targetPath>
> <directory>${basedir}/src/main/resources</directory>
> </resource>
> </resources>
>
> <outputDirectory>${project.build.directory}/${project.build.finalName}/copiedwithresources</outputDirectory>
>
> <filterPropertiesFile>${basedir}/src/filters/filter.properties</filterPropertiesFile>
> <filtering>true</filtering>
> </configuration>
> </execution>
> </executions>
> </plugin>
>
>
>
>
>
>
> Carsten Ziegeler <cz...@apache.org>
> 2005.08.19 15:20
> Please respond to
> "Maven Users List" <us...@maven.apache.org>
>
>
> To
> users@maven.apache.org
> cc
>
> Subject
> [M2] How does filtering resources work?
>
>
>
>
>
>
> I'm a little confused how filtering of resources in M2 works.
> Now, I can define several resource sets in the build resources
> section (with include/exclude) patterns. But there is no way
> of defining filters there. (At least that's what I think).
>
> Now I can turn on filtering in the resources plugin. I guess without
> any additional configuration, this enables filtering for *all* resources.
> So if I only want to filter one resource set (defined in the build
> section), do I have to specify the same resources in the plugin
> configuration as well? Wouldn't it be better to define the filters
> directly at the resources in the build section?
>
> On the same topic, is it possible to have filters that replace tokens
> with values from the pom, like project name or version?
>
> Thanks
> Carsten
> --
> Carsten Ziegeler - Open Source Group, S&N AG
> http://www.s-und-n.de
> http://www.osoco.org/weblogs/rael/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [M2] How does filtering resources work?
Posted by Carsten Ziegeler <cz...@apache.org>.
Andrius Karpavicius schrieb:
> Hi,
>
> I am almost an expert here, after trying to get filtering work for two
> days :)
>
:)
>
> It seems like you can replace trwo things :
>
> 1. From a properties file in a format ${token} or @token@
> 2. From a POM.xml file ${project.version}
>
Ah, great, thanks!
> To apply different filtering to diferent resources you would have to
> define resoruces as part of maven-resources-plugin configuration,
>
> Unfortunatelly I was not able to do so. It would simply ignore my
> resources settings. You can see earlier emails.
>
Yes, I saw them - :( So, can someone help us here?
Thanks!
Carsten
--
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [M2] How does filtering resources work?
Posted by Andrius Karpavicius <An...@sintagma.lt>.
Hi,
I am almost an expert here, after trying to get filtering work for two
days :)
>From resources plugin code:
// support ${token}
Reader reader = new InterpolationFilterReader( fileReader,
filterProperties, "${", "}" );
// support @token@
reader = new InterpolationFilterReader( reader,
filterProperties, "@", "@" );
reader = new InterpolationFilterReader( reader, new
ReflectionProperties( project ), "${", "}" );
It seems like you can replace trwo things :
1. From a properties file in a format ${token} or @token@
2. From a POM.xml file ${project.version}
To apply different filtering to diferent resources you would have to
define resoruces as part of maven-resources-plugin configuration,
Unfortunatelly I was not able to do so. It would simply ignore my
resources settings. You can see earlier emails.
Can somebory tell what is a proper way of configuring resources in
plugin/config section, or is it a bug?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>resources</goal>
</goals>
<configuration>
<resources>
<resource>
<targetPath>../filtered-webapp-resources</targetPath>
<directory>${basedir}/src/main/webapp</directory>
</resource>
<resource>
<targetPath>../filtered-webapp-resources/WEB-INF/classes</targetPath>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
<outputDirectory>${project.build.directory}/${project.build.finalName}/copiedwithresources</outputDirectory>
<filterPropertiesFile>${basedir}/src/filters/filter.properties</filterPropertiesFile>
<filtering>true</filtering>
</configuration>
</execution>
</executions>
</plugin>
Carsten Ziegeler <cz...@apache.org>
2005.08.19 15:20
Please respond to
"Maven Users List" <us...@maven.apache.org>
To
users@maven.apache.org
cc
Subject
[M2] How does filtering resources work?
I'm a little confused how filtering of resources in M2 works.
Now, I can define several resource sets in the build resources
section (with include/exclude) patterns. But there is no way
of defining filters there. (At least that's what I think).
Now I can turn on filtering in the resources plugin. I guess without
any additional configuration, this enables filtering for *all* resources.
So if I only want to filter one resource set (defined in the build
section), do I have to specify the same resources in the plugin
configuration as well? Wouldn't it be better to define the filters
directly at the resources in the build section?
On the same topic, is it possible to have filters that replace tokens
with values from the pom, like project name or version?
Thanks
Carsten
--
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org