2

I have Eclipse Ganymede and would like to use the auto content assist feature for ant. I have the ant-contrib-1.0b3.jar with me.

What configuration is required in eclipse to use auto content assist which can include tasks for ant-contrib as well?

When I use the following the ant can recognize tasks for ant-contrib but content assist doesn't work?

<!-- Define classpath for ant-contrib tasks -->
<path id="ant.contrib.classpath">
    <fileset dir="/path/to/lib/">
        <include name="ant-contrib-1.0b3.jar" />
    </fileset>
</path>

<!-- Task definition -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath refid="ant.contrib.classpath" />
</taskdef>
Bharat Sinha
  • 13,973
  • 6
  • 39
  • 63

1 Answers1

4

Please try the following.

I understand that for Ant 1.6 and later you need to reference the antcontrib XML file instead of the properties file like so :

<!-- Task definition -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
    <classpath refid="ant.contrib.classpath" />
</taskdef>

This is also detailed here.

Besides that, in Preferences -> Ant -> Editor -> Content Assist check that Provide proposals for user defined tasks is checked like so (this is also the default) :

enter image description here

If both of the above are in place you should get the content assist as shown here (This is the code from your post, the only difference being, that have replaced the reference to antcontrib.properties with antlib.xml) :

enter image description here

Replacing the reference to the properties file with the xml one made all the difference for me on Eclipse Indigo SR2 (64 Bit).

I checked to make sure that this feature ( Content assist for user-defined ant tasks) is available at least since Eclipse 3.3. There were performance problems in the Ant Editor related specifically to this feature in Eclipse 3.3 but the same have since been resolved.

Ashutosh Jindal
  • 18,501
  • 4
  • 62
  • 91
  • Doesn't seem to work for me. If I write `if` or `var` no `content-assist` shows up. – Bharat Sinha Aug 08 '12 at 09:34
  • Then must have something to do with your Eclipse version. I assume when you say that nothing shows up, you mean even after using the XML file ? Try this in a new workspace. What happens if you try this with Eclipse Indigo SR2 ? – Ashutosh Jindal Aug 08 '12 at 09:43
  • 2
    Works well (even with content assist) on the newest Eclipse Kepler and Ubuntu 13.04 - firstly I installed `ant-contrib` package (`sudo apt-get install ant-contrib`) than added installed jar into the classpath in Eclipse's preferences dialog (`/user/share/java/ant-contrib.jar`) and in build files I'm using only ``. – Ondřej Doněk Aug 27 '13 at 04:38