Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #14407
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Nigel Wade <nmw@ion.le.ac.uk> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Get Rev Number from SVN to Display in Web App |
| Date | Tue, 08 May 2012 14:56:10 +0100 |
| Lines | 62 |
| Message-ID | <a0sn2cFpuhU1@mid.individual.net> (permalink) |
| References | <joaro7$8hs$1@news.albasani.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-15 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net Fvw5lqZkQDUHrWzLCnYDoQRoUTVJaKGiaSzLgq8roLPMoA+pzX+zyTWPf5FDmGFEYy |
| Cancel-Lock | sha1:Fnr009/i4KdzGd4CuzbZEjbfvNU= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 |
| In-Reply-To | <joaro7$8hs$1@news.albasani.net> |
| Xref | csiph.com comp.lang.java.programmer:14407 |
Show key headers only | View raw
On 08/05/12 11:15, Jan Burse wrote:
> Dear All,
>
> Is there a simple Ant task to retrieve the revision
> number of my code from a SVN repository, and then
> store it in some location, so that later my web
> application can show it?
>
> Best Regards
I use NetBeans, and have added the following to its build.xml for an application in
which I want to include the SVN revision.
This sets a property for ant:
<target name="-post-init" description="Get the svn revision of the current build">
<exec dir=".." outputproperty="svna.version" executable="svnversion">
<arg value="-c" />
<redirector>
<outputfilterchain>
<tokenfilter>
<replaceregex pattern="^[0-9]*:?" replace="" flags="g"/>
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
<echo>SVN version ${svna.version}</echo>
</target>
This embeds it into the jar manifest in the post-jar target:
<target name="-post-jar">
...
<jar destfile="${tmp.dir}/temp_final.jar" filesetmanifest="skip">
<zipgroupfileset dir="dist" includes="*.jar"/>
<zipgroupfileset dir="dist/lib" includes="*.jar"/>
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
<attribute name="Implementation-Version" value="${svna.version}"/>
<attribute name="SVN-Revision" value="${svna.version}" />
</manifest>
</jar>
This is the resulting contents of the jar manifest:
Manifest-Version: 1.0
Main-Class: package.Main
Implementation-Version: 384M
SVN-Revision: 384M
The main class extracts it, when given the -v flag, using:
System.out.println("SVN revision : " +Main.class.getPackage().getImplementationVersion() );
HTH.
--
Nigel Wade
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Get Rev Number from SVN to Display in Web App Jan Burse <janburse@fastmail.fm> - 2012-05-08 12:15 +0200
Re: Get Rev Number from SVN to Display in Web App Roedy Green <see_website@mindprod.com.invalid> - 2012-05-08 03:23 -0700
Re: Get Rev Number from SVN to Display in Web App Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-05-08 05:34 -0500
Re: Get Rev Number from SVN to Display in Web App Donkey Hottie <donkey@fredriksson.dy.fi> - 2012-05-08 14:13 +0300
Re: Get Rev Number from SVN to Display in Web App Jan Burse <janburse@fastmail.fm> - 2012-05-08 13:20 +0200
Re: Get Rev Number from SVN to Display in Web App Donkey Hottie <donkey@fredriksson.dy.fi> - 2012-05-08 15:09 +0300
Re: Get Rev Number from SVN to Display in Web App Jan Burse <janburse@fastmail.fm> - 2012-05-08 14:17 +0200
Re: Get Rev Number from SVN to Display in Web App Jan Burse <janburse@fastmail.fm> - 2012-05-08 14:23 +0200
Re: Get Rev Number from SVN to Display in Web App Lew <noone@lewscanon.com> - 2012-05-08 05:44 -0700
Re: Get Rev Number from SVN to Display in Web App Nigel Wade <nmw@ion.le.ac.uk> - 2012-05-08 14:56 +0100
Re: Get Rev Number from SVN to Display in Web App Jan Burse <janburse@fastmail.fm> - 2012-05-08 16:21 +0200
csiph-web