Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven archetype + Velocity: how to show the date

I have a maven archetype project. When I use this archetype I want that some files report the actual date. I tried with $date but Velocity does not recognize it. I found something called DateTools but I don't know how can I use it. It's the first time I use Velocity.

like image 940
Alf Avatar asked Feb 20 '23 21:02

Alf


1 Answers

Unfortunately, the Maven Archetype plugin doesn't come bundled with Velocity Tools. I've added it by modifying the Maven Archetypes Plugin. Follow these steps, presuming you're using Maven 2.2.1:

svn co -q http://svn.apache.org/repos/asf/maven/archetype/tags/maven-archetype-2.2
cd maven-archetype-2.2
curl -k -O https://raw.github.com/gist/3404715/59c7fa1c20c60e2a165de4109c2acffb8026febd/velocity-tools.patch
patch -p0 -i velocity-tools.patch
mvn install

The modified Maven Archetype plugin will now be installed locally.

$date usage in your templates should now render, e.g.

The date is $date

...to:

The date is Aug 20, 2012 4:40:22 PM
like image 121
opyate Avatar answered Mar 03 '23 09:03

opyate