It is possible to use the Code Switcher in batch operations where multiple versions of an application are built. CodeSwitcher is (of course) a Java application.
CodeSwitcher reads the source code of a file, remove comments where appropriate and comment blocks that are not used for this version. This operation is done for all files of a defined directory, and all subdirectories.
This is an example source code before CodeSwitcher is used:
...
//#ifdef JAVA2
pProperties.store(out,"hsqldb database");
//#else
/*
pProperties.save(out,"hsqldb database");
*/
//#endif
...
The next step is to run CodeSwitcher. This is done using a command line:
java org.hsqldb.util.CodeSwitcher . -JAVA2
The '.' means the program works on the current directory (all subdirectories are processes recursivly). '-JAVA2' means the code labeled with JAVA2 must be switched off. And this is how the source code looks after CodeSwitcher has processed this file:
...
//#ifdef JAVA2
/*
pProperties.store(out,"hsqldb database");
*/
//#else
pProperties.save(out,"hsqldb database");
//#endif
...
For detailed information on the command line options run 'java org.hsqldb.util.CodeSwitcher'.