Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling javac debugging for Apache ANT

Just a simple question. For ANT builds, if I leave the the debuglevel parameter completely out will it compile with ALL debugging information? Or would it be better to include debuglevel="lines,vars,source" in javac task? I want to enable the maximum level of debugging possible. Here's a snippet:

<javac srcdir="${dir.source}"
     destdir="${dir.classes}"
     deprecation="${javac.deprecation}"
     debug="${veracode.release.mode}"
     debuglevel="lines,vars,source" <-- should I leave this line out? -->
     optimize="${javac.optimize}">
like image 628
minhaz1 Avatar asked Aug 09 '12 20:08

minhaz1


People also ask

How do I enable Ant debugging?

To run Ant build in debug or verbose mode in command prompt, we can simply use the -d or -debug (for debug mode) and -verbose (for verbose mode).

How do I debug an Ant script?

Open the Ant view (Window -> Show view -> Ant). If the build file isn't in the view then you can simply add it. Once added right click on the ant target you want to run and select Debug as -> Ant build. The Debug perspective should open up and the process should stop at your breakpoint where you can step through it.

What is includeAntRuntime in Ant?

includeAntRuntime. Whether to include the Ant run-time libraries in the classpath. It is usually best to set this to false so the script's behavior is not sensitive to the environment in which it is run. No; defaults to yes , unless build.sysclasspath property is set.


1 Answers

Short answer: Yes, you may leave the debuglevel attribute out as long as you set the debug attribute to true.

From the javac Ant task documentation:

debug

Indicates whether source should be compiled with debug information; defaults to off. If set to off, -g:none will be passed on the command line for compilers that support it (for other compilers, no command line argument will be used). If set to true, the value of the debuglevel attribute determines the command line argument.

debugLevel

Keyword list to be appended to the -g command-line switch. This will be ignored by all implementations except modern, classic(ver >= 1.2) and jikes. Legal values are none or a comma-separated list of the following keywords: lines, vars, and source. If debuglevel is not specified, by default, nothing will be appended to -g. If debug is not turned on, this attribute will be ignored.

Therefore, setting debug to true and omitting debugLevel is the same as passing the flag -g with no options appended. According to the javac documentation, passing the -g flag with nothing appended is equivalent to specifying sources, lines, and vars.

like image 53
Christopher Peisert Avatar answered Oct 16 '22 03:10

Christopher Peisert