|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectPrecompile
public class Precompile
A simple class to precompile Java source code similar to C precompilation.
The idea behind this is in having an option to generate similar sources out of one code base. So you can comment / uncomment different parts of the code via precompile switches in the source files or as arguments to this class (-D).
Syntax:
java Precompile [-q] [-f] -i [-i ...] [-o [-o ...]] {-D...}
java Precompile -l -i [-i ...]
In the first mode, you give this class at least one directory as parameter,
this is the directory, where the input source files reside (-i). Optionally,
you specify with the -o switch, where Precompile.java should put the
precompiled source files. If the output directory does already exist, and
it is not empty, Precompile will stop. Use the -f switch, to force
overwriting existing files in the output directory.-Ddefine-name -Ddefine-name ... as additional
parameters.
In the second mode, Precompile will list (-l or --list) all used define
switches in all the source files only.
Supported precompile switches are:
#define <value>
Only to define a switch for evaluation by#ifdefor#ifndef. You can also #define values from the command line by the -D switch. Locally defined switches are restricted to the file in which they occur.#undef <value>
#undefine <value>
Only to undefine a previously set switch. #undefine is also restricted to the file in which it appears.#if <value> ... #else ... #endif
This can be #if 0 (==false) or #if 1 (or any other Integer != 0: ==true). Otherwise it is interpreted identical to #ifdef <value>.#ifdef <value> ... #else ... #endif
True, if <value> is defined prior to this line of code, false otherwise.#ifndef <value> ... #else ... #endif
Equal to#ifdef, but with reversed logic.
| Constructor Summary | |
|---|---|
Precompile()
|
|
| Method Summary | |
|---|---|
static void |
main(java.lang.String[] params)
You can run the class stand alone via this method. |
java.lang.String[] |
precompile(java.lang.String[] inputDirs,
java.lang.String[] outputDirs,
boolean force,
java.lang.String[] switches)
This is the routine to precompile all *.java files in a given directory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Precompile()
| Method Detail |
|---|
public java.lang.String[] precompile(java.lang.String[] inputDirs,
java.lang.String[] outputDirs,
boolean force,
java.lang.String[] switches)
throws java.security.GeneralSecurityException,
java.io.IOException
inputDirs - In which directories are the java source files? ALL Java
source files in these directories will be precompiled.outputDirs - In which directories to put the precompiled source files.
They do not have to exist, they will be created automatically if needed.force - A boolean to force overwriting the contents of any existing
output directories before writing to them. If force is false, and an
output directory is not empty, a GeneralSecurityException is thrown.switches - Any <DEFINES> to be used as precompile options.
Can be null if none should be applied.
java.security.GeneralSecurityException
java.io.IOExceptionpublic static void main(java.lang.String[] params)
Parameters in detail:
-i <directory>The directory containing the input source files. All *.java files in this directory will be precompiled. You can give multiple directories with-idir1 -idir2 -idir3 ....-o <directory>(Optional) The directory to where the precompiled source files will be written. You can give multiple directories in the same way as it is explained above for the -i switch.
If you don't give output directories, Precompile.java will try to find a "package" statement in the source file, and use the package name as the output directory for that file. The method of finding the package name should be rather robust, but in case it fails, this is, you don't find the resulting file in the correct directory, specify the output directories with the -o switch(es). Also, if you prefer to put the output files into another directory, than the package name implies, you have to use -o .-q(Optional) Quiet mode. Don't output anything except for errors.-f(Optional) Force overwriting existing files in the output directories. Precompile.java will not overwrite contents in the output directory by default.
When using Precompile.java without -o switch, you might first want to test without -f to see, if Precompile.java outputs to the directories you think. In following precompiles, you can then add the -f switch.-D<switch>(Optional) Any switch to be used for precompilation. You can have any number of -D options.
params - An array of Strings. See above for a more detailed
explanation of possible parameters.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||