I have following ant mail task -
Unforunately you can't. You have to put Library Dependencies into the ant classpath somehow.
This could be the ANTH_HOME/lib dir or a change to the command line arguments.
Ant has a command-line argument to specify a lib dir:
-lib <path> specifies a path to search for jars and classes
You could also call ant from ant itself with that info, which may be a bit ugly:
<exec executable="ant">
<arg value="-lib"/>
<arg value="PATH_TO_MY_LIB"/>
<arg value="target"/>
</exec>
If you execute this task from eclipse, you can add the libs to the run definition of the task and share this run definition with other developers.
See this answer to a similar question for a solution of library dependencies in ant.
In short, put all your ant addon libs, e.g. mail.jar,activation.jar, commons in a special folder and make it available for all your ant scripts via ANT_ARGS.
Being forced to use the exec task in ant to resolve a library dependency seems VERY strange.
In Eclipse common practice is to create a module in your repository (cvs,subversion,git). Then every team member has that module in his workspace and simply uses
Window > Preferences > Ant > Runtime > Global Entries
to make those dependencies available for ant.
There is a nice approach which is already answered here. It solves this problem with the Ant Tasks Classloader:
<taskdef resource="net/jtools/classloadertask/antlib.xml"
classpath="ant-classloadertask.jar"/>
<!-- now you can load activation.jar and mail.jar into the project's classpath -->
<classloader loader="project">
<classpath>
<pathelement path="lib/activation.jar"/>
<pathelement path="lib/mail.jar"/>
</classpath>
</classloader>