You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Anders Hessellund Jensen <ah...@trifork.com> on 2006/02/28 16:30:05 UTC

[m2] Timestamp plugin

I would like to be able to substitute timestamps with the build time 
into a resource file. As I understand it, there is currently no plugin 
to to this, so I consider writing one.

The plugin should leverage the existing resource filtering mechanism of 
M2. The plugin would take a configuration like this:

<configuration>
   <timestamps>
     <timestamp>
        <propertyName>build.date</propertyName>
        <pattern>yyyy.MM.dd</pattern>
     <timestamp>
   <timestamps>
</configuration>

Running the plugin with this configuration would define the M2 property 
build.date, and any filtered resource file would get ${build.date} 
substituted with 2006.02.28 or whatever the date at build time is.

WDYT?

Best regards,
Anders

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


Re: [m2] Timestamp plugin

Posted by Anders Hessellund Jensen <ah...@trifork.com>.
The plugin is in progress. I'm aiming for functionality identical to 
that of the TStamp Ant core task: 
http://ant.apache.org/manual/CoreTasks/tstamp.html .

Anders Hessellund Jensen wrote:
> I would like to be able to substitute timestamps with the build time 
> into a resource file. As I understand it, there is currently no plugin 
> to to this, so I consider writing one.
> 
> The plugin should leverage the existing resource filtering mechanism of 
> M2. The plugin would take a configuration like this:
> 
> <configuration>
>   <timestamps>
>     <timestamp>
>        <propertyName>build.date</propertyName>
>        <pattern>yyyy.MM.dd</pattern>
>     <timestamp>
>   <timestamps>
> </configuration>
> 
> Running the plugin with this configuration would define the M2 property 
> build.date, and any filtered resource file would get ${build.date} 
> substituted with 2006.02.28 or whatever the date at build time is.
> 
> WDYT?
> 
> Best regards,
> Anders
> 
> ---------------------------------------------------------------------
> 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: [m2] Timestamp plugin

Posted by Prasad Kashyap <go...@gmail.com>.
This seems like a very useful plugin to have. I think we should have one.

Cheers
Prasad

On 2/28/06, Anders Hessellund Jensen <ah...@trifork.com> wrote:
> I would like to be able to substitute timestamps with the build time
> into a resource file. As I understand it, there is currently no plugin
> to to this, so I consider writing one.
>
> The plugin should leverage the existing resource filtering mechanism of
> M2. The plugin would take a configuration like this:
>
> <configuration>
>    <timestamps>
>      <timestamp>
>         <propertyName>build.date</propertyName>
>         <pattern>yyyy.MM.dd</pattern>
>      <timestamp>
>    <timestamps>
> </configuration>
>
> Running the plugin with this configuration would define the M2 property
> build.date, and any filtered resource file would get ${build.date}
> substituted with 2006.02.28 or whatever the date at build time is.
>
> WDYT?
>
> Best regards,
> Anders
>
> ---------------------------------------------------------------------
> 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: [m2] Timestamp plugin

Posted by Anders Hessellund Jensen <ah...@trifork.com>.
Hi Jason,

Not much work has been done yet. I have created a really minimal version 
of the plugin. Thats 7 lines of real code. Have a look at the plugin if 
you want to, its attached to 
https://issues.apache.org/jira/browse/GERONIMO-1659 . It may not be the 
best way of doing it, but doubt there is any simpler way.

/Anders

Jason van Zyl wrote:
> Anders Hessellund Jensen wrote:
> 
>> I would like to be able to substitute timestamps with the build time 
>> into a resource file. As I understand it, there is currently no plugin 
>> to to this, so I consider writing one.
> 
> 
> Sorry for not responding to this earlier, and I know that you've started 
> working on this plugin and I'd like to harness the work you've done but 
> I think what you are doing should be an extension to the resources 
> plugin. We should figure out how to augment filtering of resources. I 
> think the easiest way to do this is to filter the resources using Velocity.
> 
> This way additional tools can be created for swizzling resources and 
> this can all happen in one pass through velocity instead of having N 
> plugins which need to make N passes over the resources to filter them. 
> So I don't want to discourage you at all. Work on the plugin and I will 
> try to integrate your code into the resources plugin when you are done.
> 
> The other advantage of using Velocity in the resources plugin will allow 
> you to use Velocity directives in your resources so you can do any sort 
> of conditional logic you may want to have instead of simple 
> substitution. So I think we would benefit in two ways using Velocity 
> here: scalable addition of tools that can be used to swizzle resources 
> (a timestamp tool is a perfect example) and conditional logic which can 
> sometimes be useful like looking at a property introduced by a profile 
> and behave a certain way for example.
> 
>> The plugin should leverage the existing resource filtering mechanism 
>> of M2. The plugin would take a configuration like this:
>>
>> <configuration>
>>   <timestamps>
>>     <timestamp>
>>        <propertyName>build.date</propertyName>
>>        <pattern>yyyy.MM.dd</pattern>
>>     <timestamp>
>>   <timestamps>
>> </configuration>
>>
>> Running the plugin with this configuration would define the M2 
>> property build.date, and any filtered resource file would get 
>> ${build.date} substituted with 2006.02.28 or whatever the date at 
>> build time is.
>>
>> WDYT?
>>
>> Best regards,
>> Anders
>>
>> ---------------------------------------------------------------------
>> 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
> 


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


Re: [m2] Timestamp plugin

Posted by Jason van Zyl <ja...@maven.org>.
Brett Porter wrote:
> I'm not so sure about this. Do we really want to be swizzling resources?

I don't know what anyone might want to do, that's why I would use Velocity.

This is the first suggestion of what users might want to do.

> So far what I've seen has been fairly limited needs - fields in the
> manifest and a properties file of info for record keeping. I think a
> specialised plugin (maybe even a velocity plugin) is better for this
> than introducing velocity to normal resources.

Just makes it more efficient in a single pass, extensible and Velocity 
is pretty fast, though the JAR shouldn't be 400k.

> - Brett
> 


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


Re: [m2] Timestamp plugin

Posted by Jason van Zyl <ja...@maven.org>.
Geoffrey De Smet wrote:
> Resources could use a lot more then the current filtering:
> - build timestamp

Most of these are supported and they actually use a reflection tool to 
provide a light version of Velocity essentially.

> - pom information:
> -- version
> -- name, description, organization, ...
> -- url

This one is not but could again be dropped into a Velocity context. If 
Velocity really bogged down the build cycle, and I don't believe it 
would, then I would be for just using Velocity as it can be used for 
anything essentially. Provided a mechanism was made so that any tool 
could be dropped into the Velocity context it's unlimited as to what you 
could do with resources.

> - svn revision
> 

Jason.

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


Re: [m2] Timestamp plugin

Posted by Geoffrey De Smet <ge...@gmail.com>.
Resources could use a lot more then the current filtering:
- build timestamp
- pom information:
-- version
-- name, description, organization, ...
-- url
- svn revision
So all these things can be shown in the application and logs


The current resources filtering happens something like this now:
src/main
- resources: files
- filters: filters that change the resources files

That looks a bit dangerous to me, as its hard to predict how many files 
your filters will affect. Something defaulted like this would look nice 
IMHO (through configuration this is now also possible):
src/main
- resources: static resources
- filtered-resources
- filters

Being able to plug in dynamic filters (based on java classes or ant 
scripts) that make the build timestamp etc, would be nice, for example:
<filter>
  <!--Only supported type currently -->
  <type>property-file-based-filter</type>
  <file>../myFilter.properties</file>
</filter>
<filter>
  <type>ant-file-based-filter</type>
  <file>...</file>
  <target>...</file>
</filter>
<filter>
  <type>pom-replaces-filter</type>
  <prefix>${</...>
  <suffix>}</...>
</...>


Brett Porter wrote:
> I'm not so sure about this. Do we really want to be swizzling resources?
> 
> So far what I've seen has been fairly limited needs - fields in the
> manifest and a properties file of info for record keeping. I think a
> specialised plugin (maybe even a velocity plugin) is better for this
> than introducing velocity to normal resources.
> 
> - Brett
> 
> Jason van Zyl wrote:
>> Anders Hessellund Jensen wrote:
>>> I would like to be able to substitute timestamps with the build time
>>> into a resource file. As I understand it, there is currently no plugin
>>> to to this, so I consider writing one.
>> Sorry for not responding to this earlier, and I know that you've started
>> working on this plugin and I'd like to harness the work you've done but
>> I think what you are doing should be an extension to the resources
>> plugin. We should figure out how to augment filtering of resources. I
>> think the easiest way to do this is to filter the resources using Velocity.
>>
>> This way additional tools can be created for swizzling resources and
>> this can all happen in one pass through velocity instead of having N
>> plugins which need to make N passes over the resources to filter them.
>> So I don't want to discourage you at all. Work on the plugin and I will
>> try to integrate your code into the resources plugin when you are done.
>>
>> The other advantage of using Velocity in the resources plugin will allow
>> you to use Velocity directives in your resources so you can do any sort
>> of conditional logic you may want to have instead of simple
>> substitution. So I think we would benefit in two ways using Velocity
>> here: scalable addition of tools that can be used to swizzle resources
>> (a timestamp tool is a perfect example) and conditional logic which can
>> sometimes be useful like looking at a property introduced by a profile
>> and behave a certain way for example.
>>
>>> The plugin should leverage the existing resource filtering mechanism
>>> of M2. The plugin would take a configuration like this:
>>>
>>> <configuration>
>>>   <timestamps>
>>>     <timestamp>
>>>        <propertyName>build.date</propertyName>
>>>        <pattern>yyyy.MM.dd</pattern>
>>>     <timestamp>
>>>   <timestamps>
>>> </configuration>
>>>
>>> Running the plugin with this configuration would define the M2
>>> property build.date, and any filtered resource file would get
>>> ${build.date} substituted with 2006.02.28 or whatever the date at
>>> build time is.
>>>
>>> WDYT?
>>>
>>> Best regards,
>>> Anders
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>

-- 
With kind regards,
Geoffrey De Smet


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


Re: [m2] Timestamp plugin

Posted by Jason van Zyl <ja...@maven.org>.
Piéroni Raphaël wrote:
> Do the archetype plugin have a Velocity feature ?
> 

Archetype uses Velocity for creating project templates. But that 
actually needs to be fixed in some places as running GIFs through 
Velocity usually doesn't work very well :-)

Jason.


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


Re: [m2] Timestamp plugin

Posted by Piéroni Raphaël <ra...@gmail.com>.
Do the archetype plugin have a Velocity feature ?

2006/3/2, Brett Porter <br...@apache.org>:
>
> I'm not so sure about this. Do we really want to be swizzling resources?
>
> So far what I've seen has been fairly limited needs - fields in the
> manifest and a properties file of info for record keeping. I think a
> specialised plugin (maybe even a velocity plugin) is better for this
> than introducing velocity to normal resources.
>
> - Brett
>
> Jason van Zyl wrote:
> > Anders Hessellund Jensen wrote:
> >> I would like to be able to substitute timestamps with the build time
> >> into a resource file. As I understand it, there is currently no plugin
> >> to to this, so I consider writing one.
> >
> > Sorry for not responding to this earlier, and I know that you've started
> > working on this plugin and I'd like to harness the work you've done but
> > I think what you are doing should be an extension to the resources
> > plugin. We should figure out how to augment filtering of resources. I
> > think the easiest way to do this is to filter the resources using
> Velocity.
> >
> > This way additional tools can be created for swizzling resources and
> > this can all happen in one pass through velocity instead of having N
> > plugins which need to make N passes over the resources to filter them.
> > So I don't want to discourage you at all. Work on the plugin and I will
> > try to integrate your code into the resources plugin when you are done.
> >
> > The other advantage of using Velocity in the resources plugin will allow
> > you to use Velocity directives in your resources so you can do any sort
> > of conditional logic you may want to have instead of simple
> > substitution. So I think we would benefit in two ways using Velocity
> > here: scalable addition of tools that can be used to swizzle resources
> > (a timestamp tool is a perfect example) and conditional logic which can
> > sometimes be useful like looking at a property introduced by a profile
> > and behave a certain way for example.
> >
> >> The plugin should leverage the existing resource filtering mechanism
> >> of M2. The plugin would take a configuration like this:
> >>
> >> <configuration>
> >>   <timestamps>
> >>     <timestamp>
> >>        <propertyName>build.date</propertyName>
> >>        <pattern>yyyy.MM.dd</pattern>
> >>     <timestamp>
> >>   <timestamps>
> >> </configuration>
> >>
> >> Running the plugin with this configuration would define the M2
> >> property build.date, and any filtered resource file would get
> >> ${build.date} substituted with 2006.02.28 or whatever the date at
> >> build time is.
> >>
> >> WDYT?
> >>
> >> Best regards,
> >> Anders
> >>
> >> ---------------------------------------------------------------------
> >> 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
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: [m2] Timestamp plugin

Posted by Brett Porter <br...@apache.org>.
I'm not so sure about this. Do we really want to be swizzling resources?

So far what I've seen has been fairly limited needs - fields in the
manifest and a properties file of info for record keeping. I think a
specialised plugin (maybe even a velocity plugin) is better for this
than introducing velocity to normal resources.

- Brett

Jason van Zyl wrote:
> Anders Hessellund Jensen wrote:
>> I would like to be able to substitute timestamps with the build time
>> into a resource file. As I understand it, there is currently no plugin
>> to to this, so I consider writing one.
> 
> Sorry for not responding to this earlier, and I know that you've started
> working on this plugin and I'd like to harness the work you've done but
> I think what you are doing should be an extension to the resources
> plugin. We should figure out how to augment filtering of resources. I
> think the easiest way to do this is to filter the resources using Velocity.
> 
> This way additional tools can be created for swizzling resources and
> this can all happen in one pass through velocity instead of having N
> plugins which need to make N passes over the resources to filter them.
> So I don't want to discourage you at all. Work on the plugin and I will
> try to integrate your code into the resources plugin when you are done.
> 
> The other advantage of using Velocity in the resources plugin will allow
> you to use Velocity directives in your resources so you can do any sort
> of conditional logic you may want to have instead of simple
> substitution. So I think we would benefit in two ways using Velocity
> here: scalable addition of tools that can be used to swizzle resources
> (a timestamp tool is a perfect example) and conditional logic which can
> sometimes be useful like looking at a property introduced by a profile
> and behave a certain way for example.
> 
>> The plugin should leverage the existing resource filtering mechanism
>> of M2. The plugin would take a configuration like this:
>>
>> <configuration>
>>   <timestamps>
>>     <timestamp>
>>        <propertyName>build.date</propertyName>
>>        <pattern>yyyy.MM.dd</pattern>
>>     <timestamp>
>>   <timestamps>
>> </configuration>
>>
>> Running the plugin with this configuration would define the M2
>> property build.date, and any filtered resource file would get
>> ${build.date} substituted with 2006.02.28 or whatever the date at
>> build time is.
>>
>> WDYT?
>>
>> Best regards,
>> Anders
>>
>> ---------------------------------------------------------------------
>> 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
> 

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


Re: [m2] Timestamp plugin

Posted by Jason van Zyl <ja...@maven.org>.
Anders Hessellund Jensen wrote:
> I would like to be able to substitute timestamps with the build time 
> into a resource file. As I understand it, there is currently no plugin 
> to to this, so I consider writing one.

Sorry for not responding to this earlier, and I know that you've started 
working on this plugin and I'd like to harness the work you've done but 
I think what you are doing should be an extension to the resources 
plugin. We should figure out how to augment filtering of resources. I 
think the easiest way to do this is to filter the resources using Velocity.

This way additional tools can be created for swizzling resources and 
this can all happen in one pass through velocity instead of having N 
plugins which need to make N passes over the resources to filter them. 
So I don't want to discourage you at all. Work on the plugin and I will 
try to integrate your code into the resources plugin when you are done.

The other advantage of using Velocity in the resources plugin will allow 
you to use Velocity directives in your resources so you can do any sort 
of conditional logic you may want to have instead of simple 
substitution. So I think we would benefit in two ways using Velocity 
here: scalable addition of tools that can be used to swizzle resources 
(a timestamp tool is a perfect example) and conditional logic which can 
sometimes be useful like looking at a property introduced by a profile 
and behave a certain way for example.

> The plugin should leverage the existing resource filtering mechanism of 
> M2. The plugin would take a configuration like this:
> 
> <configuration>
>   <timestamps>
>     <timestamp>
>        <propertyName>build.date</propertyName>
>        <pattern>yyyy.MM.dd</pattern>
>     <timestamp>
>   <timestamps>
> </configuration>
> 
> Running the plugin with this configuration would define the M2 property 
> build.date, and any filtered resource file would get ${build.date} 
> substituted with 2006.02.28 or whatever the date at build time is.
> 
> WDYT?
> 
> Best regards,
> Anders
> 
> ---------------------------------------------------------------------
> 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