<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vitor Rodrigues &#187; tip</title>
	<atom:link href="http://www.vitorrodrigues.com/blog/tag/tip/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vitorrodrigues.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 28 Sep 2009 18:05:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Debugging Ant tasks in Eclipse</title>
		<link>http://www.vitorrodrigues.com/blog/2009/07/10/debugging-ant-tasks-in-eclipse/</link>
		<comments>http://www.vitorrodrigues.com/blog/2009/07/10/debugging-ant-tasks-in-eclipse/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 08:16:31 +0000</pubDate>
		<dc:creator>vitor</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jpda]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[trick]]></category>

		<guid isPermaLink="false">http://www.vitorrodrigues.com/blog/?p=138</guid>
		<description><![CDATA[Today I came  an issue that required me to debug a custom Ant task that we have. While the Eclipse integrated debugger allows you to step through the targets and tasks in the build.xml file using the action Debug As -&#62; Ant Script, it doesn&#8217;t actually let you step into the java class that implements [...]]]></description>
			<content:encoded><![CDATA[<p>Today I came  an issue that required me to debug a custom Ant task that we have. While the Eclipse integrated debugger allows you to step through the targets and tasks in the build.xml file using the action <em>Debug As -&gt; Ant Script</em>, it doesn&#8217;t actually let you step into the java class that implements the task. This is a major drawback, as most of the complexity (and issues <img src='http://www.vitorrodrigues.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> ) tend to be in the task implementation code.</p>
<p>After searching around for a bit, I came across the Eclipse Remote Debugger debug configuration. This configuration allows you to remotely debug applications, by establishing a JDWP (Java Debug Wire Protocol, part of JPDA &#8211; <a href="http://en.wikipedia.org/wiki/Java_Platform_Debugger_Architecture">Java Platform Debug Architecture</a>) connection between the running application and the debugger. After learning about this, setting up the environment to debugg Ant tasks from within Eclipse was pretty straightforward.</p>
<p>The first step is to setup the Ant script launcher to run in debug mode and attach to the debug server. The following should be used as JRE arguments for the Ant configuration:</p>
<p>-Xdebug -agentlib:jdwp=transport=dt_socket,server=y,address=8000</p>
<p>You can setup your Ant configuration by going to <em>Run -&gt; External Tools -&gt; External Tools Configurations</em> and creating a new <em>Ant Build</em> configuration. Inser the location of the build file in the <em>main</em> tab and setup the arguments in the <em>JRE</em> tab:</p>
<p><a href="http://www.vitorrodrigues.com/blog/wp-content/uploads/2009/07/ant_jre_arguments.jpg"><img title="ant_jre_arguments" src="http://www.vitorrodrigues.com/blog/wp-content/uploads/2009/07/ant_jre_arguments.jpg" alt="" /><br />
 </a></p>
<p>After the Ant configuration is setup, we need to take care of the remote debugger configuration. Go to <em>Run -&gt; Debug Configurations&#8230;</em> and create a new configuration for <em>Remote Java Application</em>. Make sure you set the same port number that you used in the Ant configuration, and you are good to go.</p>
<p><img src="http://www.vitorrodrigues.com/blog/wp-content/uploads/2009/07/remoteantdebugger.jpg" alt="" /></p>
<p>Now, place the breakpoints in your build.xml and java classes. In order to debug, you need to first launch the Ant script and then attach the debugger to it. Do right click in the build.xml file and select <em>Debug As -&gt; Ant Script</em>. Then go to <em>Run -&gt; Debug Configurations&#8230;</em> select the <em>Remote Ant Debugger </em>and click <em>Debug</em>. The debugger will now attach to the running proccess and let you step through both the xml file and the java classes:</p>
<p><a href="http://www.vitorrodrigues.com/blog/wp-content/uploads/2009/07/debug_ant_task.jpg"><img title="debug_ant_task" src="http://www.vitorrodrigues.com/blog/wp-content/uploads/2009/07/debug_ant_task.jpg" alt="" /></a></p>
<p><a href="http://www.vitorrodrigues.com/blog/wp-content/uploads/2009/07/debug_ant_task.jpg"><img title="debug_ant_task" src="http://www.vitorrodrigues.com/blog/wp-content/uploads/2009/07/debugging_ant_task.jpg" alt="" /></a></p>
<p>Have fun!</p>
<img src="http://www.vitorrodrigues.com/blog/?ak_action=api_record_view&id=138&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.vitorrodrigues.com/blog/2009/07/10/debugging-ant-tasks-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

