-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.html
88 lines (83 loc) · 4.93 KB
/
README.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title>jpp - A Simple Java Preprocessor for Ant</title>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
html {color: #333333; line-height: 1.5; font-family: Helvetica, arial, sans-serif;} pre {background-color: #f8f8f8;border: 1px solid #ddd;}
</style>
</head>
<body>
<h1 id="jpp---a-simple-java-preprocessor-for-ant">jpp - A Simple Java Preprocessor for Ant</h1>
<h2 id="about-jpp">About jpp</h2>
<p>jpp is an Ant task for preprocessing text files, especially Java source files.</p>
<p>Its main purpose is to allow “conditional compilation”. Other features commonly provided by text preprocessors, like inclusion of files or macro expansion, are not supported.</p>
<p>Ant provides the jpp task with properties that control the preprocessing of the files. Using conditional directives parts of the text file can be excluded in the resulting file.</p>
<h2 id="syntax">Syntax</h2>
<pre><code>#if [!]propertyName [# ... optional inline comment ...]
...text 1...
[#else
...text 2...]
#endif</code></pre>
<p><em>(’[ … ]’ encloses optional parts).</em></p>
<h2 id="preprocessing">Preprocessing</h2>
<p>jpp analyses a file’s text line-by-line and writes the result to the destination file.</p>
<p>Here the details of the preprocessing:</p>
<ul>
<li>When the <code>#if</code> condition is true the lines following the <code>#if</code> (i.e. “<code>...text 1...</code>”) are copied to the destination file, otherwise the lines following the <code>#else</code> (i.e. “<code>...text 2...</code>”) are copied.</li>
<li>All lines containing a jpp directive (<code>#if</code>, <code>#else</code>, <code>#endif</code>) are removed.</li>
<li>All lines outside an <code>#if...#endif</code> block are copied to the destination file.</li>
<li><code>#if</code> … <code>#endif</code> blocks can be nested, i.e. they can appear in the “if” and “else” areas of an outer <code>#if</code> … <code>#endif</code> block.</li>
</ul>
<p>An <code>#if</code> condition is true if either</p>
<ul>
<li>a single name is specified (e.g. “<code>#if FOO</code>”) and the property with that name holds the value <code>true</code>, or</li>
<li>a negate operator <code>!</code> and a name is given (e.g. “<code>#if !FOO</code>”) and no property with that name is defined or the property does not hold the value <code>true</code>.</li>
</ul>
<h2 id="using-jpp-directives-in-java-source-files">Using jpp directives in Java source files</h2>
<p>When using jpp directives in Java source files the directives must be included in Java comments to avoid compile errors.</p>
<p>You may either use single line comments, e.g. as in:</p>
<pre><code>//#if FOO
... regular Java text
//#endif</code></pre>
<p>or block comments like:</p>
<pre><code>/*#if FOO
... text in comment ...
#endif*/</code></pre>
<p>When using the block comment approach the text inside the directive block will not be compiled in the original file. However when the condition is satisfied the resulting file will contain the text without the wrapping comment, i.e. it will be compiled.</p>
<h2 id="examples">Examples</h2>
<pre><code>/*#if FOO
... text in comment ...
#else*/
... text outside comment ...
//#endif
//#if !FOO
... text to be excluded when FOO is true ...
//#endif</code></pre>
<h2 id="ant-integration">Ant integration</h2>
<pre><code><project name="YourProjectName" ... >
<!-- Register the jpp ant task -->
<taskdef resource="jpp.xml" classpath="lib/jpp/1.0.3/jpp-1.0.3.jar" />
...
<!-- defined properties to control the preprocessing -->
<property name="NO_FOO" value="true" />
<property name="WITH_BLA" value="true" />
...
<!-- call the jpp tool inside a target -->
<target name="preprocess">
<jpp destdir="src-gen" readonly="true" verbose="false">
<fileset dir="src/" includes="**/*.java" excludesfile="config/excludes.txt" />
<fileset dir="src/" includesfile="config/includes.txt" />
</jpp>
</target>
...
</project></code></pre>
<h2 id="license">License</h2>
<p>jpp is distributed under a BSD license of <a href="http://www.abego-software.de/index.html">abego Software</a>.</p>
<h2 id="links">Links</h2>
<p>Sources: <a href="https://github.com/abego/jpp">https://github.com/abego/jpp</a></p>
</body>
</html>