source: tmcsimulator/trunk/src/tmcsim/common/RevisionNumber.java @ 6

Revision 6, 1.6 KB checked in by jdalbey, 10 years ago (diff)

Multifile commit. Add version # to Paramics Communicator. Move Load button in Sim Mgr. Add several tests. Add package jars target.

Line 
1package tmcsim.common;
2
3import java.io.File;
4import java.util.Scanner;
5import java.util.logging.Level;
6import java.util.logging.Logger;
7
8/**
9 * RevisionNumber represents the current Subversion revision. The Ant build
10 * script generates this value and saves it in a plain text file in the 'config'
11 * folder. (See target '-pre-compile'). The file should be included into the
12 * distributed zip file by the build script so it is available at run time to be
13 * displayed in help info.
14 *
15 * @author jdalbey
16 */
17public class RevisionNumber
18{
19
20    private static Logger logger = Logger.getLogger("tmcsim.common");
21    // Read the subversion revision info and return it
22
23    /**
24     * Return the version number as a string. The revision number is generated
25     * by the svnversion command.
26     *
27     * @see http://svnbook.red-bean.com/en/1.7/svn.ref.svnversion.re.html
28     * Currently this string it return untouched. Future enhancements might make
29     * it pretty.
30     * @return the revision number as a string
31     */
32    public static String getString()
33    {
34        String revision = "unknown"; // default
35        String kConfigFile = "config/svn-version.txt";
36//        InputStream in = RevisionNumber.class.getResourceAsStream("config/svn-version.txt");
37        try
38        {
39            Scanner scan = new Scanner(new File(kConfigFile));
40            revision = scan.next();
41        } catch (Exception e)
42        {
43            logger.logp(Level.SEVERE,
44                    "RevisionNumber", "getString()",
45                    "Exception trying to read from file: "
46                    + kConfigFile, e);
47        }
48        return revision;
49    }
50}
Note: See TracBrowser for help on using the repository browser.