Results 1 to 5 of 5
  1. #1
    sal_manilla is offline Member
    Join Date
    Apr 2008
    Posts
    3
    Rep Power
    0

    Default 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"
    Java 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:
    Java 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.
    Java 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

  2. #2
    Freespeech is offline Member
    Join Date
    May 2008
    Posts
    1
    Rep Power
    0

    Default

    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

  3. #3
    rajikpasha is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

    Default Need Help

    Hi ,

    My requirement is also like this {Get Build number and revision number , we r using SVN}, i tried your method but its giving error when build:

    [echo] Generate build info class...
    [taskdef] Could not load definitions from resource svntask.properties. It could not be found.

    BUILD FAILED
    D:\WorkBench\New_Tmonitor\21-10-2010\dashboard\build.xml:761: Problem: failed to create task or type svn

    .Can u please tell me what is "svntask.properties" and what it contains ???

    Thanks in Advance..

  4. #4
    sal_manilla is offline Member
    Join Date
    Apr 2008
    Posts
    3
    Rep Power
    0

    Default

    Hi,

    it's been a while since the post and development, so I can't be of great help right now. I think I had a quite similar issue and I guess it was some problem with the setup of the additional libraries and paths.

    Maybe as a starting point I've googled the following link that might be worth looking at.

    Subversion, Ant and SVN task Death Becomes you


    Sorry I don't have a better answer and final solution for you.


    sal_manilla

  5. #5
    rajikpasha is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

Similar Threads

  1. Code for adding search function in an application
    By Avdhut in forum Threads and Synchronization
    Replies: 5
    Last Post: 03-03-2009, 11:15 AM
  2. How to run/build the JSP file using Eclipse
    By cbklp in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 01-19-2008, 01:03 AM
  3. Debugging Java Application in Eclipse IDE
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 05-22-2007, 10:34 PM
  4. Stable Build: Eclipse 3.3M6
    By goldhouse in forum Java Software
    Replies: 0
    Last Post: 04-02-2007, 03:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •