Saving & Reusing Ant Options

When we ran the HelloWorld.xml Ant buildfile in the last section, the choice of targets, along with all other options in the launch configuration dialog were saved in an entity called a 'launch configuration'. Launch configurations contain all details necessary to run an Ant buildfile in a particular way. It is perfectly valid to have multiple launch configurations associated with a single Ant buildfile. Therefore, in addition to the launch configuration that was created in the last step, specifying that our HelloWorld.xml buildfile should execute the targets "Hello" and "World" in that order, a second launch configuration could be created for the same buildfile specifying different targets or just different ordering. Creating multiple launch configurations in this manner allows you to quickly run your Ant buildfile in any configuration by simply specifying the corresponding launch configuration.

  1. From the Workbench toolbar, select Run > External Tools > Open External Tools Dialog....
  2. 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.

    External tools dialog

  3. At the top of the dialog, change the Name to Hello World and Apply the change.
  4. In the tree at left, bring up on the context menu on the selected launch configuration and choose Duplicate, or select the Duplicate on the toolbar above the tree. 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.
  5. Rename the new configuration to World Hello.
  6. In the Targets tab, click the Order... button, change the order of the targets so that the World target executes first, and Apply the change.
  7. Click Run.
  8. 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.
  9. Go back to the External Tools drop down in the toolbar.

    External tools drop-down menu

    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.
    Note: The history is ordered so that the most frequently run configurations are at the top of the drop-down.
Creating Ant buildfiles
Editing Ant buildfiles
Running Ant buildfiles
Creating a project builder Ant buildfile
Ant buildfiles as project builders
Executing project builders
External tools
Non-Ant project builders
Stand-alone external tools