Use a precompiler with Java
Your Java code: //@START@// your code //@END@// <target name="compileprod"> <copy todir="out"> <filterchain> <tokenfilter> <replacestring from="//@START@//" to="/*" /> <replacestring from="//@END@//" to="*/" /> </tokenfilter> </filterchain> <fileset dir="."> <include name="**/*.java" /> </fileset> </copy> </target>