<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Inject Build Time (timestamp) Property Using Maven</title>
	<atom:link href="http://www.gadberry.com/aaron/2007/05/28/inject-build-time-timestamp-property-using-maven/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gadberry.com/aaron/2007/05/28/inject-build-time-timestamp-property-using-maven/</link>
	<description>Help - v. helped, helpÂ·ing, helps</description>
	<lastBuildDate>Sat, 21 Nov 2009 03:50:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Cristian</title>
		<link>http://www.gadberry.com/aaron/2007/05/28/inject-build-time-timestamp-property-using-maven/comment-page-1/#comment-21406</link>
		<dc:creator>Cristian</dc:creator>
		<pubDate>Wed, 19 Nov 2008 20:57:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.gadberry.com/aaron/2007/05/28/inject-build-time-timestamp-property-using-maven/#comment-21406</guid>
		<description>Hi, I am struggling for a couple of days with maven-antrun-plugin to inject the timestamp in a property file. I&#039;ve tried to above code that was changed a little (don&#039;t want to use a regex to find and replace but rather than directly inject the result in a file). I would expect at least to see in the logs the result from  but not luck. I&#039;ve checked the local repository and have all the dependencies for ant downloaded.


Any suggestions are more than welcome. Thanks alot.

&lt;code&gt;
&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;ant&lt;/groupId&gt;
&lt;artifactId&gt;ant-nodeps&lt;/artifactId&gt;
&lt;version&gt;1.6.5&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
&lt;build&gt;
&lt;filters&gt;
&lt;filter&gt;${basedir}/target/classes/filter.properties&lt;/filter&gt;
&lt;/filters&gt;

&lt;resources&gt;
&lt;resource&gt;
&lt;directory&gt;src/main/resources&lt;/directory&gt;
&lt;filtering&gt;true&lt;/filtering&gt;
&lt;/resource&gt;
&lt;!-- 
&lt;resource&gt;
&lt;directory&gt;src/test/resources&lt;/directory&gt;
&lt;filtering&gt;true&lt;/filtering&gt;
&lt;/resource&gt;
--&gt;
&lt;/resources&gt;


&lt;pluginManagement&gt;
  &lt;plugins&gt;
  &lt;plugin&gt;
  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
  &lt;configuration&gt;
  &lt;source&gt;1.5&lt;/source&gt;
  &lt;target&gt;1.5&lt;/target&gt;
  &lt;/configuration&gt;
  &lt;/plugin&gt;
  
  &lt;plugin&gt;
  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
  &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
  &lt;executions&gt;
  &lt;execution&gt;
  &lt;id&gt;set-build-time&lt;/id&gt;
&lt;phase&gt;generate-resources&lt;/phase&gt;
&lt;goals&gt;
&lt;goal&gt;run&lt;/goal&gt;
  &lt;/goals&gt;
  &lt;configuration&gt;
  &lt;tasks&gt;
  &lt;!-- Safety --&gt;
  &lt;mkdir dir=&quot;${project.build.directory}&quot; /&gt;
&lt;tstamp&gt;
&lt;format property=&quot;last.updated&quot; pattern=&quot;yyyy-MM-dd hh:mm:ss&quot; /&gt;
&lt;/tstamp&gt;
&lt;echo file=&quot;${basedir}/target/classes/filter.properties&quot; message=&quot;build.time=${last.updated}&quot; /&gt;
&lt;echo message=&quot;================================&quot; /&gt;
&lt;echo message=&quot;================================&quot; /&gt;
&lt;echo message=&quot;================================&quot; /&gt;
&lt;echo message=&quot;build.time=${last.updated}&quot; /&gt;
&lt;echo message=&quot;================================&quot; /&gt;
&lt;echo message=&quot;================================&quot; /&gt;
&lt;echo message=&quot;================================&quot; /&gt;
&lt;/tasks&gt;
&lt;/configuration&gt;
  &lt;/execution&gt;
  &lt;/executions&gt;
  &lt;/plugin&gt;

  &lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
  &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
  &lt;configuration&gt;
  &lt;useDefaultManifestFile&gt;
  true
  &lt;/useDefaultManifestFile&gt;
  &lt;/configuration&gt;
  &lt;/plugin&gt;

  &lt;/plugins&gt;
  &lt;/pluginManagement&gt;
  &lt;/build&gt;
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Hi, I am struggling for a couple of days with maven-antrun-plugin to inject the timestamp in a property file. I&#8217;ve tried to above code that was changed a little (don&#8217;t want to use a regex to find and replace but rather than directly inject the result in a file). I would expect at least to see in the logs the result from  but not luck. I&#8217;ve checked the local repository and have all the dependencies for ant downloaded.</p>
<p>Any suggestions are more than welcome. Thanks alot.</p>
<p><pre><code>
&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;ant&lt;/groupId&gt;
&lt;artifactId&gt;ant-nodeps&lt;/artifactId&gt;
&lt;version&gt;1.6.5&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
&lt;build&gt;
&lt;filters&gt;
&lt;filter&gt;${basedir}/target/classes/filter.properties&lt;/filter&gt;
&lt;/filters&gt;

&lt;resources&gt;
&lt;resource&gt;
&lt;directory&gt;src/main/resources&lt;/directory&gt;
&lt;filtering&gt;true&lt;/filtering&gt;
&lt;/resource&gt;
&lt;!-- 
&lt;resource&gt;
&lt;directory&gt;src/test/resources&lt;/directory&gt;
&lt;filtering&gt;true&lt;/filtering&gt;
&lt;/resource&gt;
--&gt;
&lt;/resources&gt;


&lt;pluginManagement&gt;
  &lt;plugins&gt;
  &lt;plugin&gt;
  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
  &lt;configuration&gt;
  &lt;source&gt;1.5&lt;/source&gt;
  &lt;target&gt;1.5&lt;/target&gt;
  &lt;/configuration&gt;
  &lt;/plugin&gt;
  
  &lt;plugin&gt;
  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
  &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
  &lt;executions&gt;
  &lt;execution&gt;
  &lt;id&gt;set-build-time&lt;/id&gt;
&lt;phase&gt;generate-resources&lt;/phase&gt;
&lt;goals&gt;
&lt;goal&gt;run&lt;/goal&gt;
  &lt;/goals&gt;
  &lt;configuration&gt;
  &lt;tasks&gt;
  &lt;!-- Safety --&gt;
  &lt;mkdir dir="${project.build.directory}" /&gt;
&lt;tstamp&gt;
&lt;format property="last.updated" pattern="yyyy-MM-dd hh:mm:ss" /&gt;
&lt;/tstamp&gt;
&lt;echo file="${basedir}/target/classes/filter.properties" message="build.time=${last.updated}" /&gt;
&lt;echo message="================================" /&gt;
&lt;echo message="================================" /&gt;
&lt;echo message="================================" /&gt;
&lt;echo message="build.time=${last.updated}" /&gt;
&lt;echo message="================================" /&gt;
&lt;echo message="================================" /&gt;
&lt;echo message="================================" /&gt;
&lt;/tasks&gt;
&lt;/configuration&gt;
  &lt;/execution&gt;
  &lt;/executions&gt;
  &lt;/plugin&gt;

  &lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
  &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
  &lt;configuration&gt;
  &lt;useDefaultManifestFile&gt;
  true
  &lt;/useDefaultManifestFile&gt;
  &lt;/configuration&gt;
  &lt;/plugin&gt;

  &lt;/plugins&gt;
  &lt;/pluginManagement&gt;
  &lt;/build&gt;
</code></pre></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wam</title>
		<link>http://www.gadberry.com/aaron/2007/05/28/inject-build-time-timestamp-property-using-maven/comment-page-1/#comment-4563</link>
		<dc:creator>wam</dc:creator>
		<pubDate>Wed, 03 Oct 2007 09:30:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.gadberry.com/aaron/2007/05/28/inject-build-time-timestamp-property-using-maven/#comment-4563</guid>
		<description>i found a simpler solution using ant&#039;s tstamp task:

&lt;code&gt;
&lt;ant:tstamp/&gt;
&lt;ant:echo&gt;${DSTAMP}&lt;/ant:echo&gt;
&lt;ant:echo&gt;${TSTAMP}&lt;/ant:echo&gt;
&lt;ant:echo&gt;${TODAY}&lt;/ant:echo&gt;
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>i found a simpler solution using ant&#8217;s tstamp task:</p>
<p><pre><code>
&lt;ant:tstamp/&gt;
&lt;ant:echo&gt;${DSTAMP}&lt;/ant:echo&gt;
&lt;ant:echo&gt;${TSTAMP}&lt;/ant:echo&gt;
&lt;ant:echo&gt;${TODAY}&lt;/ant:echo&gt;
</code></pre></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Wagner</title>
		<link>http://www.gadberry.com/aaron/2007/05/28/inject-build-time-timestamp-property-using-maven/comment-page-1/#comment-3791</link>
		<dc:creator>Martin Wagner</dc:creator>
		<pubDate>Fri, 15 Jun 2007 11:30:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.gadberry.com/aaron/2007/05/28/inject-build-time-timestamp-property-using-maven/#comment-3791</guid>
		<description>I try this again - the HTML formatter didn&#039;t like my input... Thanks for this great hint. Two comments: 

First, you need an extra dependency in that allows executing optional ant tasks:

&lt;plugin&gt;
    ...
    &lt;dependencies&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;ant&lt;/groupId&gt;
			&lt;artifactId&gt;ant-nodeps&lt;/artifactId&gt;
			&lt;version&gt;1.6.5&lt;/version&gt;
		&lt;/dependency&gt;
	&lt;/dependencies&gt;
&lt;/plugin&gt;


Second, you can also patch just the &lt;em&gt;generated&lt;/em&gt; resource in the project&#039;s build directory, thus eleminating the need for the cleanup task. Maven guarantees that all POM-defined plugins are executed after default tasks in the respective lifecycle phases, we can safely assume that the resource file has already been processed and copied to the build directory. 

Martin</description>
		<content:encoded><![CDATA[<p>I try this again &#8211; the HTML formatter didn&#8217;t like my input&#8230; Thanks for this great hint. Two comments: </p>
<p>First, you need an extra dependency in that allows executing optional ant tasks:</p>
<p>&lt;plugin><br />
    &#8230;<br />
    &lt;dependencies><br />
		&lt;dependency><br />
			&lt;groupId>ant&lt;/groupId><br />
			&lt;artifactId>ant-nodeps&lt;/artifactId><br />
			&lt;version>1.6.5&lt;/version><br />
		&lt;/dependency><br />
	&lt;/dependencies><br />
&lt;/plugin></p>
<p>Second, you can also patch just the <em>generated</em> resource in the project&#8217;s build directory, thus eleminating the need for the cleanup task. Maven guarantees that all POM-defined plugins are executed after default tasks in the respective lifecycle phases, we can safely assume that the resource file has already been processed and copied to the build directory. </p>
<p>Martin</p>
]]></content:encoded>
	</item>
</channel>
</rss>
