Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7437017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:19:55+00:00 2026-05-29T10:19:55+00:00

I’ve been tasked with creating automated notifications for our Ant build scripts. This is

  • 0

I’ve been tasked with creating automated notifications for our Ant build scripts. This is so that when someone pushes out a deployment, our team can automatically receive an email about it.

The obvious choice was to use Ant’s mail task, which comes predefined with Ant:

<target name="notify" description="notify team">
    <mail subject="latest deployment">
        <from address="me@gmail.com" />
        <to address="jimmy@yahoo.com" />
        <message>A new build has been pushed out to prod</message>
    </mail>
</target>

However this results in the following runtime exception:

java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage

This is because Ant’s mail task depends on JavaMail and JavaBeans Activation Framework, libraries which are apparently not included with its distribution. Why Ant would define a task that depended on a library but not include that library is unclear to me.

This issue has already been discussed on this post: ant mail task using mail and activation jar in external location. Based on the answers there seem to be two solutions.

The first is to manually put these library dependencies on the ant classpath. This can be done using the -lib command line argument, or in eclipse one can use Window > Preferences > Ant > Runtime > Global Entries, and then add mail.jar and activation.jar (I’m pretty sure this amounts to the same thing as -lib, correct me if I’m wrong). But this solution is undesirable for our team because it would mean every one of us would have to manually carry out these steps. I’m looking for a way to simply commit my notification code, and it should work on another eclipse install after svn update.

The other solution in the linked post mentions a way to do the above programmatically, by calling Ant from itself:

<exec executable="ant">
    <arg value="-lib"/>
    <arg value="PATH_TO_MY_LIB"/>
    <arg value="target"/>
</exec>

The problem with this is that the Ant command line tool is apparently only included with the full install, not the eclipse distribution. So again there’s no way to make it work without some manual action by anyone wanting to use the mail task.

Is there any way I can automate this without adding another annoying step to project setup? I really don’t understand why this is so hard to achieve – it seems like if the mail task wasn’t predefined by Ant this would be easier. Hopefully I’m missing something.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:19:55+00:00Added an answer on May 29, 2026 at 10:19 am

    Mail is one of the optional tasks in ANT. To install these additional libraries ANT 1.7 added a fetch.xml script, invoked as follows:

    ant -f $ANT_HOME/fetch.xml -Ddest=user -Dm2.url=http://repo1.maven.org/maven2 
    

    On windows you could try:

    ant -f %ANT_HOME%/fetch.xml -Ddest=user -Dm2.url=http://repo1.maven.org/maven2 
    

    For a full explanation, see the ANT Manual documentation.


    Update

    The following ANT file has an install-jars target that can be used to install the missing ANT jars used by the mail task.

    <project name="demo" default="notify">
    
        <target name="install-jars" description="Install ANT optional jars">
            <mkdir dir="${user.home}/.ant/lib"/>
            <get dest="${user.home}/.ant/lib/mail.jar"       src="http://search.maven.org/remotecontent?filepath=javax/mail/mail/1.4.4/mail-1.4.4.jar"/>
            <get dest="${user.home}/.ant/lib/activation.jar" src="http://search.maven.org/remotecontent?filepath=javax/activation/activation/1.1/activation-1.1.jar"/>
        </target>
    
        <target name="notify" description="notify team">
            <mail subject="latest deployment">
                <from address="me@gmail.com" />
                <to address="jimmy@yahoo.com" />
                <message>A new build has been pushed out to prod</message>
            </mail>
        </target>
    
    </project>
    

    I discovered that the ANT mail task task loads it’s dependent classes from the ANT system classpath. This means the build has to be run in two steps:

    $ ant install-jars
    $ ant
    

    Most ANT tasks allow you to specify a classpath reference. The Mail task does not. Trying to research this issue lead me to the following mailing list thread:

    • http://ant.1045680.n5.nabble.com/Mail-task-with-mail-jar-amp-activation-jar-out-of-lib-folder-td3347501.html

    The solution is convoluted and not worth the effort. I’d recommend living with the inconvenience… (The install-jars target only needs to be run once)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.