Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add user libraries to Ant Builder classpath

I am having a problem with setting up an Ant Builder for my Eclipse projects.

I do have several 3rd party libs configured as user libraries within Eclipse. Those libraries are added to the build path of my projects and everything is working fine.

My problem is, that if I want to use the Ant Builder from Eclipse, I will have to add some of the user libraries to the classpath of the Ant Builder to get it working. I need those Libs because they include several task defs and type defs for Ant, NOT TO COMPILE MY PROJECTS. But how can I add those user libraries to the Ant Builder classpath? I don't want to "hard-code" them by adding them manually, because if I must change one those libs in the future, I will also have to maintain all Ant Builders. And I dont't know how load determine the path to the user libraries at runtime within Ant to load them dynamically, because I need those libs at the bootstrap of Ant to be able to define my needed Ant Tasks successfully.

like image 457
Nuker Avatar asked Sep 06 '10 12:09

Nuker


1 Answers

In that case, you may wish to add your JAR files (containing the taskdefs) to the Ant runtime.

Window -> Preferences, select "Ant -> Runtime" from the left. Focus on "Global Entries", then use the "Add JAR" button on the right to add JAR files.

The JAR files you add will be contributed to any Ant process running under Eclipse.

Your next question might be - "why do I have to add JARs? Can't I add my user library?". Good question, glad you (were almost about to) asked. Drives me bonkers too and I have no idea why Eclipse doesn't provide this functionality. Maybe it's time to open a feature request...

Edit February 2014: turns out that adding user libraries to Ant's classpath has already been requested (https://bugs.eclipse.org/bugs/show_bug.cgi?id=211669). By the looks of it, I was the one who reopened it...

like image 183
Isaac Avatar answered Sep 27 '22 19:09

Isaac