What is a good way to handle a version number in a Java application?

前端 未结 6 842
[愿得一人]
[愿得一人] 2020-12-23 10:25

I am developing a desktop app using Java and Swing Application Framework. I have an application about box and I\'d like to have that box contain some indication of what ver

6条回答
  •  不知归路
    2020-12-23 10:50

    Have the build script create a property file holding the version. It's good idea to grab the revision # directly from SVN. This way you can refer to it in tests. Place this property file into the packaged jar and read it in run time. We usually have major and minor versions set as parameters to ant scrpt while revision is managed automatically by SVN and gives consistent build number for the references.

    This snippet target runs svn command line and outputs into a temp file (svndump). Then constructing xx.yy.zz string, place it in another file which will be later included into jar. Note that xx.yy are taken from external parameters, this is major-minor version.

    
        
            
            
        
    
        
        
        
        
    
        
        
    
        
    
    

提交回复
热议问题