Eric,
We create an almost-Java source file, e.g., Version.txt, containing
replacement targets. We extract version information from Subversion (or
ClearCase, etc.) into a property with Ant, which we then <replace> in an
Ant <copy> from Version.txt to Version.java. The advantages of this
approach are (1) the ability to use version control for Version.txt, (2)
the ability to extract version information of various types (build date,
product version number, build number, and version-control version
number) for the compiled version, and (3) independence from the build
system allowing you to use Ant, make, clearmake, etc., and switch
systems if your process demands. The disadvantage of this approach is
that Version.txt is not automatically recognized as a Java source file
by IDEs, such as Eclipse, based solely on its suffix.
Steve's approach seems very similar, except that he prefers to use Java
properties files read by Java classes at run-time, instead of Java
source files themselves. I prefer the Java source file in order to keep
all of the version-related information in individual Java classes, and
not in a separable, easily editable, property file that is read at
run-time. For some approaches, there is definitely a benefit to the
flexibility of an editable property file that is read at run-time. I
use my Version base class, and its derivatives, for version
compatibility test methods across both sides of interfaces, as well as
returning a string for version reporting, "Help | About" information, etc.
Regards,
Wayne
from Version.txt:
public static final String DATE_STRING = "@date@";
public static final String MAJOR_VERSION = "@major@";
public static final String MINOR_VERSION = "@minor@";
public static final String PATCH_VERSION = "@patch@";
public static final String BUILD_NUMBER = "@build@";
resuting Version.java:
public static final String DATE_STRING = "Tue Nov 06 00:08:51 PST 2007";
public static final String MAJOR_VERSION = "02";
public static final String MINOR_VERSION = "00";
public static final String PATCH_VERSION = "00";
public static final String BUILD_NUMBER = "143";
Frederich, Eric P21322 wrote:
Thanks for the reply and a possible solution but this seems more like a
hack.
Yeah, right now I have something like
Public static final String programName = "Java Program XYZ";
I'd like to be able to make one where that string is "Java Program XYZ -
Development Version" automagically using ant.
If the javac command could set properties the way the java command does
it would be nice.
If this isn't the case I guess I'll be stuck with a "hack" like this.
Just seems to be a pain to explicitly copy the original to a tmp
directory, do the replacement on the file, compile it and then copy the
original file back.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]