I have following ant mail task -
<target name="sendtestreport" >
<mail mailhost="smtp.com" mailport="1025" subject="Test build" >
<from address="test@gmail.com" />
<replyto address="test@gmail.com" />
<to address="test@gmail.com" />
<message>test message</message>
<attachments>
</attachments>
</mail>
</target>
And I have both activation and mail jar available in my project "lib" folder. I want to be able to send mail with out having to keep these jars in ant download location. Is it possible to let ant know about my "lib" folder to see javaxmail and activation jars. Some thing like If I could specify class path from with in this target.
Right now when I execute this target I always encounter exception -
BUILD FAILED
java.lang.ClassNotFound
Exception: javax.mail.internet.MimeMessage
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.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:
You could also call ant from ant itself with that info, which may be a bit ugly:
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.
There is a nice approach which is already answered here. It solves this problem with the Ant Tasks Classloader: