Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Replacing tokens in Java code is working for me. I use something like this, prior to the compile task:</p> <pre><code>&lt;copy todir="${target.dir}/java" filtering="false"&gt; &lt;fileset dir="${src.dir}/java"/&gt; &lt;/copy&gt; &lt;replace dir="${target.dir}/java" value="DEMO_MODE = ${demo.mode}"&gt; &lt;replacetoken&gt;DEMO_MODE = true&lt;/replacetoken&gt; &lt;/replace&gt; </code></pre> <p>First I copy Java files into a temporary location, then I replace tokens. Javac these copied files. ${demo.mode} can be given as a parameter even in command line or property file. DEMO_MODE is a public static final boolean variable in a class.</p> <p>Two more things which can be useful for you:</p> <p>You can set up conditinal property assignments in targets:</p> <pre><code>&lt;condition property="distribution.postfix" value="-demo" else=""&gt; &lt;equals arg1="${demo.mode}" arg2="true" /&gt; &lt;/condition&gt; </code></pre> <p>And you can use <strong>if</strong> and <strong>unless</strong> conditions for targets:</p> <pre><code>&lt;target name="demotarget" depends="jar" if="demo.mode"&gt; ... &lt;/target&gt; </code></pre> <p>Actually, I would prefer modularization and different targets for PRO and DEMO releases, maybe switchable functions, but we use this tricks for something else, particularly Development vs. Production releases: Development code contains more debug logging which we don't want to be visible in production software with a logLevel=DEBUG config. Furthermore, production code obfuscated, development isn't, thus the latter throws readable stack traces for example.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload