Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse, ant and custom tasks

Sorry, I'm not terribly experienced with Ant.

I like the eclipse "Export ant buildfile" function, but I need to insert a few custom tasks (Copying files, calculating checksums that are used at runtime, etc).

How do I integrate custom ant tasks with the antfile that Eclipse exports? Also, once I've done so, will the internal build (Run...) pick it up or will I always have to use the external ant file to build from now on?

Oh, and I don't want to edit the build.xml that is exported from Eclipse, because I'd like to be able to regenerate it later.

Edit/Update:

It took me a while to figure out what was going on--so I thought I'd put some notes here to clarify.

When you create a new ant file in your directory and put <?eclipse.ant.import ?> on the first line of your custom ant script (I called mine test.xml), next time you export the buildfile from Eclipse into that directory, it'll see that tag and add <import file="test.xml"/>

With that Import, the targets in your "Custom" file (test.xml) become valid targets in your exported build.xml (or whatever name you chose when you exported it).

After this, anytime you select "build.xml" in Eclipse, the targets pane will also include targets from "test.xml"

Also, after that, you can go into your project properties/Builders and add a new builder of type "Ant Build", then select targets to use for building, clean, etc.

like image 514
Bill K Avatar asked Jan 09 '09 22:01

Bill K


1 Answers

The ant export filter will include any xml file in the same directory which has the special

<?eclipse.ant.import?>

element as its first child.

Example:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse.ant.import?>
<project name="project" default="default" basedir=".">
    ...
</project>

Eclipse will now include the following line in build.xml:

<import file="custom_build.xml"/>
like image 95
JesperE Avatar answered Sep 30 '22 13:09

JesperE