|Java Preprocessor Using Eclipse Part 1|
|Written by Administrator|
|Sunday, 03 January 2010 15:03|
Java Preprocessing Using Eclipse Part 1
So, you would like to macros like
System.out.println("Welcome to the PRO version of this wonderful software. :) ");
System.out.println("Sorry, you are using the lousy, crippled, and worthless version of our otherwise wonderful software. :( ");
The Explanation of Why I would Ever Want Icky C-style macros in my Java code
Now, searching for a java preprocessor on the web, you will find lots of people who are simply horrified that anybody would want to put such backward, impure things in their code. And the above could certainly be done without preprocessing. But there are sometimes you just really really want to use IFDEF type macros. In my case, it was because I have a really huge library which is now filled with lines which generate log data using various combinations of String.format("blah blah %d %f", i, fx); type stuff. Then because I was going to be running on an embedded platform, all those strings were getting generated on the heap even if the log lines weren't executing. This was very bad. I didn't want to remote all the log lines because I need them for debugging. In my case this library was a big port from c# code. I had to do a lot of checking by putting the same log lines in the C# code, running that, and then putting the same output lines in the Java code and comparing the output.
Prebop to the Rescue
Prebop is an open source java preprocessor which uses Ant and is fairly easy to integrate with Eclipse. If you don't know what Eclipse is, then I don't see why you are reading this article. Now if you don't know what Ant is, here is Apache's one-line description:
But fear not, you will not have to learn everything about Ant. In fact, you can use Ant in Eclipse without too much pain at all.
So anyway, to use a preprocessor in your Eclipse Java application, you need to do the following steps:
|Last Updated on Monday, 04 January 2010 13:10|