<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>vincentkong.com &#187; Ant</title>
	<atom:link href="http://www.vincentkong.com/tag/ant/feed" rel="self" type="application/rss+xml" />
	<link>https://www.vincentkong.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 07 Jul 2010 00:32:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>If-Else in Ant</title>
		<link>https://www.vincentkong.com/2010/01/if-else-in-ant</link>
		<comments>https://www.vincentkong.com/2010/01/if-else-in-ant#comments</comments>
		<pubDate>Mon, 18 Jan 2010 00:59:31 +0000</pubDate>
		<dc:creator>Vincent Kong</dc:creator>
				<category><![CDATA[Ant]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.vincentkong.com/?p=1084</guid>
		<description><![CDATA[When I need to write quick script to perform a simple task, I opt to use Ant instead of a shell script. Unfortunately, the Ant core tasks doesn&#8217;t provide any flow logic like the everyday if-else statements. Ant-Contrib provides a collection of useful tasks missing in the Ant core. Installing Ant-Contrib There are 2 methods [...]


Related posts:<ol><li><a href='https://www.vincentkong.com/2008/12/sending-email-with-ant' rel='bookmark' title='Permanent Link: Sending Email with Ant'>Sending Email with Ant</a></li>
<li><a href='https://www.vincentkong.com/2007/05/some-useful-ant-tasks' rel='bookmark' title='Permanent Link: Some Useful Ant Tasks'>Some Useful Ant Tasks</a></li>
<li><a href='https://www.vincentkong.com/2007/06/java-code-snippet-for-sending-email-using-gmail-smtp-server' rel='bookmark' title='Permanent Link: Java Code Snippet for Sending Email using Gmail SMTP Server'>Java Code Snippet for Sending Email using Gmail SMTP Server</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>When I need to write quick script to perform a simple task, I opt to use <a href="http://ant.apache.org">Ant</a> instead of a shell script. Unfortunately, the Ant core tasks doesn&#8217;t provide any flow logic like the everyday if-else statements.</p>
<p><a href="http://ant-contrib.sourceforge.net">Ant-Contrib</a> provides a collection of useful tasks missing in the Ant core.</p>
<h3>Installing Ant-Contrib</h3>
<p>There are 2 methods to install ant-contrib:</p>
<p>Copy <code>ant-contrib-1.0b3.jar</code> to the <code>lib</code> directory of your Ant installation. If you want to use one of the tasks in your own project, add the lines</p>
<p><code>&lt;taskdef resource="net/sf/antcontrib/antcontrib.properties"/&gt;</code></p>
<p>Keep <code>ant-contrib-1.0b3.jar</code> in a separate location. You now have to tell Ant explicitly where to find it e.g. a <code>lib</code> directory relative to the <code>build.xml</code></p>
<p><code>&lt;taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="lib/ant-contrib-1.0b3.jar"/&gt;</code></p>
<h3>Example Using If-Else Task</h3>
<pre>&lt;if&gt;
  &lt;equals arg1="${status}" arg2="OFFLINE"/&gt;
  &lt;then&gt;
    [...]
  &lt;/then&gt;
  &lt;else&gt;
    [...]
  &lt;/else&gt;
  &lt;/if&gt;</pre>


<p>Related posts:<ol><li><a href='https://www.vincentkong.com/2008/12/sending-email-with-ant' rel='bookmark' title='Permanent Link: Sending Email with Ant'>Sending Email with Ant</a></li>
<li><a href='https://www.vincentkong.com/2007/05/some-useful-ant-tasks' rel='bookmark' title='Permanent Link: Some Useful Ant Tasks'>Some Useful Ant Tasks</a></li>
<li><a href='https://www.vincentkong.com/2007/06/java-code-snippet-for-sending-email-using-gmail-smtp-server' rel='bookmark' title='Permanent Link: Java Code Snippet for Sending Email using Gmail SMTP Server'>Java Code Snippet for Sending Email using Gmail SMTP Server</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>https://www.vincentkong.com/2010/01/if-else-in-ant/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending Email with Ant</title>
		<link>https://www.vincentkong.com/2008/12/sending-email-with-ant</link>
		<comments>https://www.vincentkong.com/2008/12/sending-email-with-ant#comments</comments>
		<pubDate>Tue, 16 Dec 2008 02:19:44 +0000</pubDate>
		<dc:creator>Vincent Kong</dc:creator>
				<category><![CDATA[Ant]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.vincentkong.com/?p=205</guid>
		<description><![CDATA[Sometimes it&#8217;s useful for an Ant script to send out an email. This can be easily done using the mail task which is part of the Core Tasks in Ant. Before using the mail task, the JavaBean Activiation Framework jar file (activation.jar), and JavaMail jar file (mail.jar) needs to be copied into the Ant lib [...]


Related posts:<ol><li><a href='https://www.vincentkong.com/2007/06/java-code-snippet-for-sending-email-using-gmail-smtp-server' rel='bookmark' title='Permanent Link: Java Code Snippet for Sending Email using Gmail SMTP Server'>Java Code Snippet for Sending Email using Gmail SMTP Server</a></li>
<li><a href='https://www.vincentkong.com/2008/11/problem-using-mysql-jdbc-on-tomcat-55-and-ubuntu-804' rel='bookmark' title='Permanent Link: Problem using MySQL JDBC on Tomcat 5.5 and Ubuntu 8.04'>Problem using MySQL JDBC on Tomcat 5.5 and Ubuntu 8.04</a></li>
<li><a href='https://www.vincentkong.com/2010/01/if-else-in-ant' rel='bookmark' title='Permanent Link: If-Else in Ant'>If-Else in Ant</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Sometimes it&#8217;s useful for an Ant script to send out an email.  This can be easily done using the <code>mail</code> task which is part of the Core Tasks in Ant. Before using the <code>mail</code> task, the <a href="http://java.sun.com/javase/technologies/desktop/javabeans/jaf/index.jsp">JavaBean Activiation Framework</a> jar file (activation.jar), and <a href="http://java.sun.com/products/javamail/index.jsp">JavaMail</a> jar file (mail.jar) needs to be copied into the Ant <code>lib</code> directory. Here is a <code>mail</code> task example which sends an email using a GMail account.</p>
<pre>&lt;target name="sendmail"&gt;
  &lt;mail
    tolist="nobody@gmail.com"
    from="nobody@gmail.com"
    subject="Email subject"
    mailhost="smtp.gmail.com"
    mailport="465"
    ssl="true"
    user="nobody@gmail.com"
    password="password"&gt;
    &lt;message&gt;Example email sent by Ant Mail task.&lt;/message&gt;
  &lt;/mail&gt;
&lt;/target&gt;</pre>
<h4>Troubleshooting Ant mail task in Ubuntu</h4>
<p><strong>Failed to initialise MIME mail: org.apache.tools.ant.taskdefs.email.MimeMailer not found in java.net.URLClassLoader</strong></p>
<p>If you downloaded Ant from the Ubuntu packages repository, not all the core Ant tasks are available. <a href="http://www.apache.org/dist/ant/binaries/">Download</a> and extract Ant from the <a href="http://ant.apache.org/">Apache Ant</a> website.</p>
<p><code>$ wget http://www.apache.org/dist/ant/binaries/apache-ant-1.7.0-bin.tar.gz<br />
$ tar -zxvf apache-ant-1.7.0-bin.tar.gz</code></p>
<p>Copy the <code>ant-javamail.jar</code> into the <code>lib</code> directory of the Ubuntu Ant installation</p>
<p><code>$ cp ./apache-ant-1.7.0/lib/ant-javamail.jar /usr/share/ant/lib</code></p>
<p><strong>Failed to send email: could not instantiate ssl security provider, check that you have JSSE in your classpath</strong></p>
<p>If the <code>ssl</code> attribute is set to true, then the <a href="http://java.sun.com/products/archive/jsse/">Java Secure Socket Extension</a> (jsse.jar) jar file is required, which is already part of J2SE 1.4.x and later. Ubuntu uses GNU Compiler for Java (gcj) as the default JVM which doesn&#8217;t have JSSE as the part of the distribution, therefore the jsse.jar file needs to be copied into the Ant lib directory.  An alternative solution is to <a href="http://www.vincentkong.com/2007/06/setting-default-jvm-in-ubuntu/">set the default JVM</a> to use another Java distribution which already has JSSE bundled.</p>


<p>Related posts:<ol><li><a href='https://www.vincentkong.com/2007/06/java-code-snippet-for-sending-email-using-gmail-smtp-server' rel='bookmark' title='Permanent Link: Java Code Snippet for Sending Email using Gmail SMTP Server'>Java Code Snippet for Sending Email using Gmail SMTP Server</a></li>
<li><a href='https://www.vincentkong.com/2008/11/problem-using-mysql-jdbc-on-tomcat-55-and-ubuntu-804' rel='bookmark' title='Permanent Link: Problem using MySQL JDBC on Tomcat 5.5 and Ubuntu 8.04'>Problem using MySQL JDBC on Tomcat 5.5 and Ubuntu 8.04</a></li>
<li><a href='https://www.vincentkong.com/2010/01/if-else-in-ant' rel='bookmark' title='Permanent Link: If-Else in Ant'>If-Else in Ant</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>https://www.vincentkong.com/2008/12/sending-email-with-ant/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some Useful Ant Tasks</title>
		<link>https://www.vincentkong.com/2007/05/some-useful-ant-tasks</link>
		<comments>https://www.vincentkong.com/2007/05/some-useful-ant-tasks#comments</comments>
		<pubDate>Wed, 09 May 2007 15:22:24 +0000</pubDate>
		<dc:creator>Vincent Kong</dc:creator>
				<category><![CDATA[Ant]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://wordpress.vincentkong.com/?p=78</guid>
		<description><![CDATA[Copying a File to a Server Running SSH Daemon Download the jsch jar file from (http://www.jcraft.com/jsch/) &#62; wget http://prdownloads.sourceforge.net/jsch/jsch-x.x.x.jar Copy the jar file into the lib directory of your ANT HOME &#62; cp jsch-x.x.x.jar ${ANT_HOME}/lib Use the scp ant task in the build script &#60;scp file="file.txt" todir="user:password@hostname:/remotedir"/&#62; Selecting Files by Size The &#60;size&#62; tag in [...]


Related posts:<ol><li><a href='https://www.vincentkong.com/2007/05/scheduling-tasks-in-ubuntulinux' rel='bookmark' title='Permanent Link: Scheduling Tasks in Ubuntu/Linux'>Scheduling Tasks in Ubuntu/Linux</a></li>
<li><a href='https://www.vincentkong.com/2008/12/sending-email-with-ant' rel='bookmark' title='Permanent Link: Sending Email with Ant'>Sending Email with Ant</a></li>
<li><a href='https://www.vincentkong.com/2010/01/if-else-in-ant' rel='bookmark' title='Permanent Link: If-Else in Ant'>If-Else in Ant</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Copying a File to a Server Running SSH Daemon</strong></p>
<ol>
<li>Download the jsch jar file from (<a href="http://www.jcraft.com/jsch/">http://www.jcraft.com/jsch/</a>)<br />
<code>&gt; wget http://prdownloads.sourceforge.net/jsch/jsch-x.x.x.jar</code></li>
<li>Copy the jar file into the lib directory of your ANT HOME<br />
<code>&gt; cp jsch-x.x.x.jar ${ANT_HOME}/lib</code></li>
<li>Use the scp ant task in the build script<code><br />
&lt;scp file="file.txt" todir="user:password@hostname:/remotedir"/&gt; </code></li>
</ol>
<p><strong>Selecting Files by Size</strong></p>
<p>The <code>&lt;size&gt;</code> tag in a FileSet will determine if the files should be included or not depending on the size limit specified.</p>
<pre>&lt;fileset dir="${jar.path}"&gt;
    &lt;patternset&gt;
        &lt;include name="**/*.jar"/&gt;
    &lt;/patternset&gt;
    &lt;size value="0" units="k" when="more"/&gt;
&lt;/fileset&gt;</pre>
<p>value &#8211; is the size of the value to be tested<br />
units &#8211; unit to be tested against: k, M, G<br />
when &#8211; type of comparison to be used: less, equal, more</p>
<p><strong>Execute Target Based on Conditional Logic</strong></p>
<p>Ant doesn&#8217;t support true conditional logic, such as if/then/else. However, you can execute targets depending on the state of properties. For example the target executes if the <code>dummy</code> property is set:</p>
<p><code>&lt;target name="run" if="dummy"/&gt; </code></p>
<p>If the property is not set, the target is ignored. You can also specify that a target should execute unless a property is set:</p>
<p><code>&lt;target name="run" unless="dummy"/&gt; </code></p>


<p>Related posts:<ol><li><a href='https://www.vincentkong.com/2007/05/scheduling-tasks-in-ubuntulinux' rel='bookmark' title='Permanent Link: Scheduling Tasks in Ubuntu/Linux'>Scheduling Tasks in Ubuntu/Linux</a></li>
<li><a href='https://www.vincentkong.com/2008/12/sending-email-with-ant' rel='bookmark' title='Permanent Link: Sending Email with Ant'>Sending Email with Ant</a></li>
<li><a href='https://www.vincentkong.com/2010/01/if-else-in-ant' rel='bookmark' title='Permanent Link: If-Else in Ant'>If-Else in Ant</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>https://www.vincentkong.com/2007/05/some-useful-ant-tasks/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
