blob: 7e28ee0e53056eb3d2695a5a8daba61a7689bab5 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
<HEAD>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="../book.css" CHARSET="ISO-8859-1" TYPE="text/css">
<title>Saving &amp; Reusing Ant options</title>
</HEAD>
<BODY BGCOLOR="#ffffff">
<h3>Saving &amp; Reusing Ant options</h3>
<P CLASS="Para">When we ran the HelloWorld.xml Ant buildfile in the last section,
the choice of targets, along with all other options in the Run Ant dialog were
saved in an entity called a 'launch configuration'. Launch configurations contain
all details necessary to run a single Ant buildfile in a particular way. It is
perfectly valid to have multiple launch configurations associated with a single
Ant buildfile. So, in addition to the launch configuration that was created in
the last step, specifying that our HelloWorld.xml buildfile should execute the
targets Hello &amp; World in that order, we could create a second launch configuration
for this same buildfile specifying the same targets but in the reverse order. So
far so good. But the really nice thing about launch configurations is that now
you can quickly run your Ant buildfile in either configuration by simply specifying
the corresponding launch configuration.</P>
<ol>
<li>From the Workbench toolbar, select <b>Run &gt; External Tools &gt; External Tools...</b>.</li>
<li>The External Tools dialog opens and presents a choice of launch configurations
to view and edit. The launch configuration we created when we ran the HelloWorld.xml
buildfile is selected in the tree at the left, and the tabs on the right show
the options for this launch configuration.<br>
<img src="../images/et_dialog.png" alt="External tools dialog" border="0" >
</li>
<li>At the top of the dialog, change the Name to 'Hello World' and <b>Apply</b>
the change.</li>
<li>In the tree at left, bring up on the context menu on the selected launch
configuration and choose <b>Duplicate</b>. A copy of the launch configuration
for the Hello World buildfile is created, '(1)' is appended to the name, and
the new launch configuration is selected in the tree.</li>
<li>Rename the new configuration to 'World Hello'.</li>
<li>In the <b>Targets</b> tab, click the <b>Order...</b> button, change the
order of the targets so that the World target executes first, and <b>Apply</b>
the change.</li>
<li>Click <b>Run</b>.</li>
<li>As before, the HelloWorld.xml buildfile runs and sends its output to the
Console view. This time however, because the targets were reversed, the output
is reversed as well.</li>
<li>Go back to the External Tools drop down in the toolbar. <br>
<img src="../images/et_dropdown.png" alt="External tools drop-down menu" border="0" ><br>
Notice now that there are two entries in the history, one for Hello World
and one for World Hello. In order to rerun the Ant buildfile so that it outputs
Hello World, just select this launch configuration in the history. To rerun
the launch configuration that outputs World Hello, select this configuration
in the history.<br>
<strong>Note</strong>: The history is ordered so that the most frequently
run configurations are at the top of the dropdown.</li>
</ol>
<p>This concludes our quick look at the basics of Ant integration in Eclipse.
In the next chapters, we consider several real-world use cases for running Ant
buildfiles inside Eclipse.</p>
</BODY>
</HTML>