If you are using version control a better approach would be to run the
svnversion tool on the top-level of your source tree and parse the first
number returned (it may return a single number or a number followed by a
colon and another number).
Michael
-----Original Message-----
From: Andreas Hesse [mailto:***@bvu.de]
Sent: Thursday, October 30, 2008 8:49 AM
To: ***@netbeans.org
Subject: Re: [nbusers] Auto Increment Build/Version Number
Hi Rich,
try this:
1) Add the following code to yout build.xml
<target name="-pre-jar" >
<propertyfile file="${src.dir}\version.properties">
<entry key="BUILD" value="1" type="int" operation="+"/>
</propertyfile>
</target>
2) create a file named 'version.properties' in your sources directory
and put a 'BUILD=0' into it (without quotes )
Now each successfully compilation of you app will increase the
buildnumer in the property-file
To acces the build number from witihin you app add something like this
to your app (e.g. in Class Main):
final static ResourceBundle rb =
ResourceBundle.getBundle("version.properties");
public static final String getRbTok(String propToken) {
String msg = "";
try {
msg = rb.getString(propToken);
} catch (MissingResourceException e) {
System.err.println("Token ".concat(propToken).concat(" not
in Propertyfile!"));
}
return msg;
}
Now you can acces your build-Number quit simple:
System.out.println("This is build %s", getRbTok("BUILD"));
Good Luck,
Andreas
Post by rwmoreyHi --
I am new to Java/NetBeans programming and I am wondering if there is a
way to access a build number for my project from within the project and
to also have this number auto increment each time I compile my project.
Post by rwmoreyIf so, can someone provide me guidance with how to access the build
number as well as setting it to auto-increment?