Skip to content
/ jpp Public

Java preprocessor - for people who miss #ifdef in Java :)

License

Notifications You must be signed in to change notification settings

mkowsiak/jpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Price Version GitHub Download

Java Preprocessor

Based on <#FreeMarker> C like preprocessor for Java. It helps you generate different Java source code base - depending on <#FreeMarker> based control flow in the sources.

Project structure

.
|-- LICENSE.md                             - MIT license file
|-- README.md                              - this README.md file
|-- bin
|   `-- jpp.sh                             - wrapper to make running more convenient
|-- build.xml                              - ant based build script for the project
|-- images
|   |-- debug_vs_release.png               - illustration of sample debug vs. release
|   `-- java_version.png                   - illustration of different JVM's version APIs
|-- resources
|   `-- log4j2.xml                         - we want to format error and info differently
|-- sample
|   `-- src
|       |-- DebugVsRelease.java            - debug vs. release passed as arg
|       |-- DebugVsReleaseDefine.java      - debug vs. release defined in the code
|       `-- somepackage
|           `-- JavaVersion.java           - sample code for getting Java version
`-- src
    `-- org
        `-- owsiak
            `-- preprocessor
                |-- CLIParser.java         - handling cli args is done here
                `-- JavaPreprocessor.java  - main class for Preprocessor

Building

> git clone https://github.com/mkowsiak/jpp.git
> cd jpp
> ant dist

Running

> java -jar dist/jpp.jar

or

> ant run

or

> export PATH=${PATH}:`pwd`/bin
> jpp.sh

Samples

Preprocessing for different Java versions (e.g. getting JVM version)

# if we plan to use the code with version < 9
./bin/jpp.sh -Dversion=6 -s sample/src -d sample/preprocessed -f somepackage/JavaVersion.java

# if we plan to use the code with version >= 9
./bin/jpp.sh -Dversion=9 -s sample/src -d sample/preprocessed -f somepackage/JavaVersion.java

Preprocessing for debug/release versions of code

# if we plan to compile code with all debug stuff
./bin/jpp.sh -Ddebug=true -s sample/src -d sample/preprocessed -f DebugVsRelease.java

# if we plan to compile code in "release" mode
./bin/jpp.sh -Ddebug=false -s sample/src -d sample/preprocessed -f DebugVsRelease.java

It is possible to define variable inside source code as well

./bin/jpp.sh -s sample/src -d sample/preprocessed -f DebugVsReleaseDefine.java

References

Download

About

Java preprocessor - for people who miss #ifdef in Java :)

Resources

License

Stars

Watchers

Forks

Packages

No packages published