You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Marshall Schor <ms...@schor.com> on 2010/12/08 18:02:24 UTC
avoiding overwriting newer file when using maven resources plugin
copy-resources with filtering
The Maven resources plugin has a goal "copy-resources" which has a configuration
parameter "overwrite". The default is "false" - meaning not to overwrite a
target file if not needed (if the target has a later date than the source).
This setting is ignored, however, if the file is being filtered.
I'm using this to inject version info from the POM into a Java source file. So
everytime this module is built, it always updates this file even though nothing
(usually) has changed.
Is there a better Maven way to do this?
-Marshall
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: avoiding overwriting newer file when using maven resources plugin
copy-resources with filtering
Posted by Marshall Schor <ms...@schor.com>.
On 12/9/2010 3:59 AM, Stephen Connolly wrote:
> Sounds like you might be better served by writing your own plugin to do the
> filtering, that way you can take the timestamps into consideration.
OK, I just thought that since this might be common scenario, there might be an
existing Maven way to do this.
> Also I hope you are putting the filtered java source into a sub-folder of
> ${basedir}/target
Yes, we do that in all cases except one - that of building Eclipse "feature"
projects.
For that case, I'm injecting the version info into the "feature.xml", which I
believe Eclipse (by convention) wants to find at the project "top level".
-Marshall
> -Stephen
>
> On 8 December 2010 22:49, Marshall Schor <ms...@schor.com> wrote:
>
>>
>> On 12/8/2010 4:40 PM, Anders Hammar wrote:
>>> I guess the dependency plugin can't really tell, as the filtering takes a
>>> value outside of the source file which could have changed since the last
>>> time the file was filtered.
>>> The price you pay for filtering I guess?
>> I was wondering (since I know the "source" of the filtered values) if there
>> was
>> a Maven-way of telling it this information?
>>
>> Something like being able to declare: file xyz depends on files abc and
>> def, so
>> if abc and def are both older than xyz, don't bother updating xyz.
>>
>> -Marshall Schor
>>> /Anders
>>>
>>> On Wed, Dec 8, 2010 at 18:02, Marshall Schor <ms...@schor.com> wrote:
>>>
>>>> The Maven resources plugin has a goal "copy-resources" which has a
>>>> configuration
>>>> parameter "overwrite". The default is "false" - meaning not to
>> overwrite a
>>>> target file if not needed (if the target has a later date than the
>>>> source).
>>>>
>>>> This setting is ignored, however, if the file is being filtered.
>>>>
>>>> I'm using this to inject version info from the POM into a Java source
>> file.
>>>> So
>>>> everytime this module is built, it always updates this file even though
>>>> nothing
>>>> (usually) has changed.
>>>>
>>>> Is there a better Maven way to do this?
>>>>
>>>> -Marshall
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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: avoiding overwriting newer file when using maven resources plugin
copy-resources with filtering
Posted by Stephen Connolly <st...@gmail.com>.
Sounds like you might be better served by writing your own plugin to do the
filtering, that way you can take the timestamps into consideration.
Also I hope you are putting the filtered java source into a sub-folder of
${basedir}/target
-Stephen
On 8 December 2010 22:49, Marshall Schor <ms...@schor.com> wrote:
>
>
> On 12/8/2010 4:40 PM, Anders Hammar wrote:
> > I guess the dependency plugin can't really tell, as the filtering takes a
> > value outside of the source file which could have changed since the last
> > time the file was filtered.
> > The price you pay for filtering I guess?
>
> I was wondering (since I know the "source" of the filtered values) if there
> was
> a Maven-way of telling it this information?
>
> Something like being able to declare: file xyz depends on files abc and
> def, so
> if abc and def are both older than xyz, don't bother updating xyz.
>
> -Marshall Schor
> > /Anders
> >
> > On Wed, Dec 8, 2010 at 18:02, Marshall Schor <ms...@schor.com> wrote:
> >
> >> The Maven resources plugin has a goal "copy-resources" which has a
> >> configuration
> >> parameter "overwrite". The default is "false" - meaning not to
> overwrite a
> >> target file if not needed (if the target has a later date than the
> >> source).
> >>
> >> This setting is ignored, however, if the file is being filtered.
> >>
> >> I'm using this to inject version info from the POM into a Java source
> file.
> >> So
> >> everytime this module is built, it always updates this file even though
> >> nothing
> >> (usually) has changed.
> >>
> >> Is there a better Maven way to do this?
> >>
> >> -Marshall
> >>
> >> ---------------------------------------------------------------------
> >> 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: avoiding overwriting newer file when using maven resources plugin
copy-resources with filtering
Posted by Marshall Schor <ms...@schor.com>.
On 12/8/2010 4:40 PM, Anders Hammar wrote:
> I guess the dependency plugin can't really tell, as the filtering takes a
> value outside of the source file which could have changed since the last
> time the file was filtered.
> The price you pay for filtering I guess?
I was wondering (since I know the "source" of the filtered values) if there was
a Maven-way of telling it this information?
Something like being able to declare: file xyz depends on files abc and def, so
if abc and def are both older than xyz, don't bother updating xyz.
-Marshall Schor
> /Anders
>
> On Wed, Dec 8, 2010 at 18:02, Marshall Schor <ms...@schor.com> wrote:
>
>> The Maven resources plugin has a goal "copy-resources" which has a
>> configuration
>> parameter "overwrite". The default is "false" - meaning not to overwrite a
>> target file if not needed (if the target has a later date than the
>> source).
>>
>> This setting is ignored, however, if the file is being filtered.
>>
>> I'm using this to inject version info from the POM into a Java source file.
>> So
>> everytime this module is built, it always updates this file even though
>> nothing
>> (usually) has changed.
>>
>> Is there a better Maven way to do this?
>>
>> -Marshall
>>
>> ---------------------------------------------------------------------
>> 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: avoiding overwriting newer file when using maven resources plugin
copy-resources with filtering
Posted by Anders Hammar <an...@hammar.net>.
I guess the dependency plugin can't really tell, as the filtering takes a
value outside of the source file which could have changed since the last
time the file was filtered.
The price you pay for filtering I guess?
/Anders
On Wed, Dec 8, 2010 at 18:02, Marshall Schor <ms...@schor.com> wrote:
> The Maven resources plugin has a goal "copy-resources" which has a
> configuration
> parameter "overwrite". The default is "false" - meaning not to overwrite a
> target file if not needed (if the target has a later date than the
> source).
>
> This setting is ignored, however, if the file is being filtered.
>
> I'm using this to inject version info from the POM into a Java source file.
> So
> everytime this module is built, it always updates this file even though
> nothing
> (usually) has changed.
>
> Is there a better Maven way to do this?
>
> -Marshall
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>