I’m trying to get an ant build file to generate identical class files as the eclipse compiler
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
The first three of which correspond (I hope!) to debuglevel="vars,lines,source" in the javac task:
<javac includeantruntime="false" srcdir="${src.dir}" destdir="${build.dir}" debug="true" debuglevel="vars,lines,source" target="1.5" >
<classpath refid="master-classpath" />
</javac>
What about the last one?
For the first three, I think all you need to tell Ant javac is
debug="true". You will get vars, lines and source by default. Specifying them explicitly is fine too.For the last, this is particular to the Eclipse JDT compiler. I don’t think other compilers optimize unused local variables away. Certainly, I’ve never been caught with debugger out of step due to removed unused local variables.
Are you using the JDT compiler in your Ant build using the Ant javac adapter? Unless you do, I don’t think you can guarantee absolutely identical class files between the two environments. However, I would be a bit suspicious of a requirement to have such a level identical-ness.