I'm building a Java application (using Ant with build.xml and build.property files). Now I'd like to be able to create a different "debug" build which prints several diagnostic messages to System.err. This is achieved by something like this (simplified):
private static final boolean DEBUG = false;
public static void debug (String msg) {
if (DEBUG) {
System.err.println(msg);
}
}
Is it possible to influence the value of the DEBUG constant at build time? I guess what I'm looking for is the Java equivalent for C-preprocessor definitions. Ideally I'd have a different build target in the build.xml file, which would set DEBUG to true and create a myapp-debug.jar as output.
A related use of this would be the name of the config file the application is using. This is also specified as a static constant in the source code, but I'd prefer it to be adjustable at build time.
Sorry if this is all obvious to you, I'm not an expert :)