<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Howtos &#187; Ant</title>
	<atom:link href="http://howto.isgoodness.com/category/it/programming/ant/feed/" rel="self" type="application/rss+xml" />
	<link>http://howto.isgoodness.com</link>
	<description>Stuffs that are worth to mention and worth to know</description>
	<lastBuildDate>Sun, 27 Feb 2011 16:19:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to get svn revision in ant using svn or svnversion</title>
		<link>http://howto.isgoodness.com/2009/10/how-to-get-svn-revision-in-ant-using-svn-or-svnversion/</link>
		<comments>http://howto.isgoodness.com/2009/10/how-to-get-svn-revision-in-ant-using-svn-or-svnversion/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 19:00:07 +0000</pubDate>
		<dc:creator>Van Nhu</dc:creator>
				<category><![CDATA[Ant]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[revision]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://howto.isgoodness.com/?p=12</guid>
		<description><![CDATA[This article is aimed to you whom use svn in linux environment. If you are using windows and Tortoise this post may be more interesting. Here are two ways to get revision number when you build your project. The first one is a complete method to get this number and the second one will give [...]]]></description>
			<content:encoded><![CDATA[<p>This article is aimed to you whom use svn in linux environment. If you are using windows and Tortoise this <a href="http://howto.isgoodness.com/2009/10/how-to-get-revision-using-tortoise-in-ant/">post</a> may be more interesting.</p>
<p>Here are two ways to get revision number when you build your project. The first one is a complete method to get this number and the second one will give you this number including a trailing if there is (<a href="http://svnbook.red-bean.com/en/1.1/re57.html" target="_blank">see</a>). In both examples I try to get the current revision number of Zend Framework &#8230;</p>
<p>Using svn<br />
In this case we use &#8220;svn info&#8221; and put the data into xml file svninfo.xml. After that we load in the data using xmlproperty and select the revision number. Your target would look like this</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;get-revision&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;svn&quot;</span> <span style="color: #000066;">output</span>=<span style="color: #ff0000;">&quot;svninfo.xml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;info --xml Zend&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xmlproperty</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;svninfo.xml&quot;</span> <span style="color: #000066;">collapseattributes</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;svn.revision&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${info.entry.revision}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${svn.revision}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/echo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>And after running this target you get an output as bellow and the echo statement should give you 17746</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;info<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry</span> <span style="color: #000066;">kind</span>=<span style="color: #ff0000;">&quot;dir&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;Zend&quot;</span> <span style="color: #000066;">revision</span>=<span style="color: #ff0000;">&quot;17746&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			http://framework.zend.com/svn/...
			...framework/standard/trunk/library/Zend
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;root<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://framework.zend.com/svn/framework<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/root<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;uuid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>****<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/uuid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;wc-info<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;schedule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>normal<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/schedule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;depth<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>infinity<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/depth<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wc-info<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;commit</span> <span style="color: #000066;">revision</span>=<span style="color: #ff0000;">&quot;17740&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>****<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;date<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2009-08-22T02:53:32.295192Z<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/date<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/commit<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/entry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/info<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Using svnversion<br />
This case is really simple and you don&#8217;t need an output file. However, the result may contain none numeric character and you need to convert it if you do need an integer. The easiest way is to parse this as an int in your application before you start using it. In this example the echo statement should print out something like 17746M</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;get-version&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">outputproperty</span>=<span style="color: #ff0000;">&quot;svn.revision&quot;</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;svnversion&quot;</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;Zend&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${svn.revision}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/echo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://howto.isgoodness.com/2009/10/how-to-get-svn-revision-in-ant-using-svn-or-svnversion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get svn revision in ant using tortoise</title>
		<link>http://howto.isgoodness.com/2009/10/how-to-get-revision-using-tortoise-in-ant/</link>
		<comments>http://howto.isgoodness.com/2009/10/how-to-get-revision-using-tortoise-in-ant/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 21:40:47 +0000</pubDate>
		<dc:creator>Van Nhu</dc:creator>
				<category><![CDATA[Ant]]></category>
		<category><![CDATA[revision]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[tortoise]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://howto.isgoodness.com/?p=3</guid>
		<description><![CDATA[This post is for you who are using Tortoise in windows environment and want to get the highest committed revision number when running an ant build script.  This number can be useful when handling the version of the static files/contents. Here is a simple ant target &#60;target name=&#34;get-revision&#34;&#62; &#60;exec executable=&#34;subWCRev.exe&#34;&#62; &#60;arg value=&#34;${srcBaseDir}&#34;/&#62; &#60;arg value=&#34;${srcBaseDir}/revision.build&#34;/&#62; &#60;arg [...]]]></description>
			<content:encoded><![CDATA[<p>This post is for you who are using Tortoise in windows environment and want to get the highest committed revision number when running an ant build script.  This number can be useful when handling the version of the static files/contents. Here is a simple ant target</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;get-revision&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;subWCRev.exe&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${srcBaseDir}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${srcBaseDir}/revision.build&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${srcBaseDir}/deploy/revision.properties&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Where ${srcBaseDir} is the top directory of svn checkout (working copy), ${srcBaseDir}/revision.build is the template file and ${srcBaseDir}/deploy/revision.properties is the output file.</p>
<p>And content of the file revision.build</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">common.svn.revision <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> $WCREV$</span></pre></div></div>

<p>Where $WCREV$ is the placeholder for the highest committed revision number. You can find more placeholders by running subWCRev.exe in cmd-promt.</p>
<p>The output to the file revision.properties will be,  for instance</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">common.svn.revision <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 1001</span></pre></div></div>

<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://howto.isgoodness.com/2009/10/how-to-get-revision-using-tortoise-in-ant/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

