Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-22-2008, 01:53 AM
Member
 
Join Date: Apr 2008
Posts: 2
sal_manilla is on a distinguished road
Java and Eclipse: Adding a build or revision number to application using SVNAnt
Hi!

Lately I wanted to include the SNV repository revision number into my applications about box. As the search with Google was very time consuming and not very satisfactory I want to outline how I have solved this issue.

1. Download SVNAnt 1.1.0 RC2 from http://subclipse.tigris.org/files/do...-1.1.0-RC2.zip
(Be sure you have Ant installed)

2. Install it as described in the README

3. In the source directory I've created an empty file called "BuildInfo.java" and checked it in into my repository.

4. In the Eclipse project I've created a new file in my source directory called "build.xml"
Code:
<!-- Generate a java class with the current svn revision number --> <project> <echo>Generate build info class...</echo> <taskdef resource="svntask.properties" /> <svn> <status path="${basedir}\BuildInfo.java" revisionProperty="svn.revision" /> </svn> <tstamp> <format property="TODAY" pattern="EEE, d-MMMM-yyyy HH:mm:ss z" locale="ENGLISH, GERMANY"/> </tstamp> <echo>Virtual PVT Cell Revision: ${svn.revision}</echo> <echo>Time stamp ${TODAY}</echo> <echo>Write build info to file ${basedir}\BuildInfo.java</echo> <!-- the source code of the java class --> <echo file="${basedir}\BuildInfo.java"> package gui; public class BuildInfo { public static final String revisionNumber="${svn.revision}"; public static final String timeStamp="${TODAY}"; } </echo> </project>
This ant script gets now the revision number form the file "BuildInfo.java" and creates a simple Java class that can be now included anywhere in the project. It may look like this:
Code:
package gui; public class BuildInfo { public static final String revisionNumber="451"; public static final String timeStamp="Mon, 21-April-2008 23:51:43 CEST"; }
Inlcude your BuildInfo.java in any source file and you can say e.g.
Code:
System.out.println(BuildInfo.revisionNumber);
5. To execute the script everytime before a build the following did the trick:
Project->Properties->Builder
Click New...
Select Ant Builder
As Build file set our "build.xml"
OK

Well that's it, basically. I hope it is helpful for someone.
sal_manilla
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-16-2008, 06:56 PM
Member
 
Join Date: May 2008
Posts: 1
Freespeech is on a distinguished road
Thank you so much ! I was just looking for the same thing and experiencing feelings similar to your about Google and the search for an esay solution.

It's working and it's pretty easy do configure ! I would just add that you must have subversion installed on your machine to use the <svn> tag of the build.xml file even if your repository is on another machine.

Thanks again !

FS
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code for adding search function in an application Avdhut Threads and Synchronization 2 04-12-2008 05:10 PM
How to run/build the JSP file using Eclipse cbklp JavaServer Pages (JSP) and JSTL 1 01-19-2008 01:03 AM
Build a Rich Client Platform application (II) JavaForums Java Blogs 0 01-03-2008 11:40 AM
Debugging Java Application in Eclipse IDE JavaForums Eclipse 0 05-22-2007 10:34 PM
Stable Build: Eclipse 3.3M6 goldhouse Java Announcements 0 04-02-2007 03:27 PM


All times are GMT +3. The time now is 02:23 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org