<?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>What I Learned Today &#187; ant</title>
	<atom:link href="http://christiansons.net/mike/blog/tag/ant/feed/" rel="self" type="application/rss+xml" />
	<link>http://christiansons.net/mike/blog</link>
	<description>Mike Christianson&#039;s journal of Java, Ant, SVN, Jetty, cygwin and other stuff.</description>
	<lastBuildDate>Wed, 04 Aug 2010 22:24:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Obfuscating a webapp .war file with yGuard and Ant</title>
		<link>http://christiansons.net/mike/blog/2009/02/obfuscating-a-webapp-war-file-with-yguard-and-ant/</link>
		<comments>http://christiansons.net/mike/blog/2009/02/obfuscating-a-webapp-war-file-with-yguard-and-ant/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 19:07:03 +0000</pubDate>
		<dc:creator>Mike Christianson</dc:creator>
				<category><![CDATA[ant]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[yguard]]></category>

		<guid isPermaLink="false">http://blog.christiansons.net/?p=178</guid>
		<description><![CDATA[One way to protect Java software from casual reverse engineering is obfuscation. Essentially, an obfuscator renames classes, variables, and packages with random/meaningless names. The application still functions correctly; the decompiled code becomes difficult to read. There are quite a few obfuscators for Java &#8212; at least a dozen when I looked &#8212; most of which [...]]]></description>
			<content:encoded><![CDATA[<p>One way to protect Java software from casual reverse engineering is obfuscation.  Essentially, an obfuscator renames classes, variables, and packages with random/meaningless names.  The application still functions correctly; the decompiled code becomes difficult to read.</p>
<p>There are quite a few obfuscators for Java &#8212; at least a dozen when I looked &#8212; most of which are easily used from an Ant script.  </p>
<p>For my use I selected one with a ready-to-use Ant task: <a href="http://www.yworks.com/en/products_yguard_about.html">yGuard</a>.  Unfortunately, yGuard operates on .jar files only, not individual .class files or webapp .war files.  Thus, I have written my own Ant script which uses yGuard and built-in Ant tasks to obfuscate .war files.<span id="more-178"></span></p>
<p style="border: thin dashed;">Before you try using my Ant script, read <a href="http://www.yworks.com/products/yguard/yguard_ant_howto.html">yGuard&#8217;s documentation</a> and be sure you fully understand how it works.  You should pay special attention to the <a href="http://www.yworks.com/products/yguard/yguard_ant_howto.html#inoutpairs">inoutpairs</a>, <a href="http://www.yworks.com/products/yguard/yguard_ant_howto.html#keep">keep</a>, and <a href="http://www.yworks.com/products/yguard/yguard_ant_howto.html#hints">hints and troubleshooting</a> sections.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- prepare a temporary directory in which the war file is expanded and obfuscated --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tempfile</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;unwar.dir&quot;</span> <span style="color: #000066;">destdir</span>=<span style="color: #ff0000;">&quot;${java.io.tmpdir}&quot;</span> <span style="color: #000066;">deleteonexit</span>=<span style="color: #ff0000;">&quot;yes&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mkdir</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${unwar.dir}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;unwar</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;webapp.war&quot;</span> <span style="color: #000066;">dest</span>=<span style="color: #ff0000;">&quot;${unwar.dir}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- create a jar of webapp classes (required by yguard) for obfuscation --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jar</span> <span style="color: #000066;">destfile</span>=<span style="color: #ff0000;">&quot;${unwar.dir}/WEB-INF/lib/webapp.jar&quot;</span> <span style="color: #000066;">whenempty</span>=<span style="color: #ff0000;">&quot;fail&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;zipfileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${unwar.dir}/WEB-INF/classes&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jar<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;delete</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${unwar.dir}/WEB-INF/classes&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- create a fileset of internal libraries to be obfuscated --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${unwar.dir}/WEB-INF/lib&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;internal.lib.set&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;myLibrary.jar&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;myOtherLibrary.jar&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fileset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- move the internal libraries to a temporary directory and make a fileset out of them --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tempfile</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;obfuscation.dir&quot;</span> <span style="color: #000066;">destDir</span>=<span style="color: #ff0000;">&quot;${java.io.tmpdir}&quot;</span> <span style="color: #000066;">deleteonexit</span>=<span style="color: #ff0000;">&quot;yes&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mkdir</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${obfuscation.dir}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;move</span> <span style="color: #000066;">todir</span>=<span style="color: #ff0000;">&quot;${obfuscation.dir}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">refid</span>=<span style="color: #ff0000;">&quot;internal.lib.set&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/move<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- create a jar of web.xml (required by yguard) for obfuscation --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jar</span> <span style="color: #000066;">destfile</span>=<span style="color: #ff0000;">&quot;${obfuscation.dir}/web.xml.jar&quot;</span> <span style="color: #000066;">whenempty</span>=<span style="color: #ff0000;">&quot;fail&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;zipfileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${unwar.dir}/WEB-INF&quot;</span> <span style="color: #000066;">includes</span>=<span style="color: #ff0000;">&quot;web.xml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jar<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;delete</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${unwar.dir}/WEB-INF/web.xml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- make a fileset of all jars to be obfuscated --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${obfuscation.dir}&quot;</span> <span style="color: #000066;">includes</span>=<span style="color: #ff0000;">&quot;*.jar&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;in-out.set&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- make a fileset of the remaining libraries, these are not obfuscated --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;path</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;external.lib.path&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${unwar.dir}/WEB-INF/lib&quot;</span> <span style="color: #000066;">includes</span>=<span style="color: #ff0000;">&quot;*.jar&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/path<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;taskdef</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;yguard&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">classname</span>=<span style="color: #ff0000;">&quot;com.yworks.yguard.YGuardTask&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">classpath</span>=<span style="color: #ff0000;">&quot;yguard.jar&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;yguard<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;inoutpairs<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #808080; font-style: italic;">&lt;!-- these filesets are inputs to be obfuscated --&gt;</span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">refid</span>=<span style="color: #ff0000;">&quot;in-out.set&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/inoutpairs<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;externalclasses</span> <span style="color: #000066;">refid</span>=<span style="color: #ff0000;">&quot;external.lib.path&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>  <span style="color: #808080; font-style: italic;">&lt;!-- external libs, not obfuscated --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rename<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;adjust</span> <span style="color: #000066;">replaceContent</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;web.xml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>  <span style="color: #808080; font-style: italic;">&lt;!-- modified to reference the obfuscated Servlet --&gt;</span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/adjust<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;keep<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #808080; font-style: italic;">&lt;!-- classes, packages, methods, and fields which should not obfuscated are specified here --&gt;</span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/keep<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rename<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/yguard<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- move our newly obfuscated classes back into the lib area --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;move</span> <span style="color: #000066;">todir</span>=<span style="color: #ff0000;">&quot;${unwar.dir}/WEB-INF/lib&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${obfuscation.dir}&quot;</span> <span style="color: #000066;">includes</span>=<span style="color: #ff0000;">&quot;*_obf.jar&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/move<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- unjar the adjusted web.xml --&gt;</span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;unzip</span> <span style="color: #000066;">dest</span>=<span style="color: #ff0000;">&quot;${unwar.dir}/WEB-INF/&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;${unwar.dir}/WEB-INF/lib/web.xml_obf.jar&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;patternset</span> <span style="color: #000066;">includes</span>=<span style="color: #ff0000;">&quot;web.xml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/unzip<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;delete<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${unwar.dir}/WEB-INF/lib&quot;</span> <span style="color: #000066;">includes</span>=<span style="color: #ff0000;">&quot;web.xml*.jar&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/delete<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- rebuild the war file --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;war</span> <span style="color: #000066;">destfile</span>=<span style="color: #ff0000;">&quot;webapp_obf.war&quot;</span> <span style="color: #000066;">basedir</span>=<span style="color: #ff0000;">&quot;${unwar.dir}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p><a href="http://www.yworks.com/">yWorks</a>, the creator of yGuard, is perhaps best known for <a href="http://www.yworks.com/en/products_ydoc.html">yDoc a UML diagram generator for JavaDocs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://christiansons.net/mike/blog/2009/02/obfuscating-a-webapp-war-file-with-yguard-and-ant/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Automate Advanced Installer with Ant</title>
		<link>http://christiansons.net/mike/blog/2009/01/automate-advanced-installer-with-ant/</link>
		<comments>http://christiansons.net/mike/blog/2009/01/automate-advanced-installer-with-ant/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 05:04:13 +0000</pubDate>
		<dc:creator>Mike Christianson</dc:creator>
				<category><![CDATA[ant]]></category>
		<category><![CDATA[advancedinstaller]]></category>
		<category><![CDATA[automation]]></category>

		<guid isPermaLink="false">http://blog.christiansons.net/?p=106</guid>
		<description><![CDATA[Note: this post was updated in light of discussion on the Advanced Installer forum. At work, we use Advanced Installer to create easy-to-use Windows installers for internal and external customers. I wrote a short Ant script for building the installer to save time and minimize mistakes. If you use Advanced Installer with your Java projects, [...]]]></description>
			<content:encoded><![CDATA[<p>Note: this post was updated in light of <a href="http://www.advancedinstaller.com/forums/viewtopic.php?f=2&#038;t=8586">discussion on the Advanced Installer forum</a>.</p>
<p>At work, we use <a href="http://www.advancedinstaller.com/">Advanced Installer</a> to create easy-to-use Windows installers for internal and external customers.  I wrote a short Ant script for building the installer to save time and minimize mistakes.</p>
<p style="border: thin dashed;">
<em>If you use Advanced Installer with your Java projects, be sure to read my post on <a href="http://christiansons.net/2009/02/use-advanced-installer-licensing-within-a-java-application/">using the Advanced Installer licensing feature within a Java application</a>.</em>
</p>
<p>Here is a partial Ant script for executing Advanced Installer builds.  It&#8217;s not fancy, but it gets the job done.<span id="more-106"></span>  Notice the script has two parts &#8212; one for setting the version number of the product and another for doing the actual build.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;installer.command&quot;</span> <span style="color: #000066;">location</span>=<span style="color: #ff0000;">&quot;C:/Caphyon/Advanced Installer/AdvancedInstaller.com&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;filename&quot;</span> <span style="color: #000066;">location</span>=<span style="color: #ff0000;">&quot;C:/build/product.aip&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;${installer.command}&quot;</span> <span style="color: #000066;">failonerror</span>=<span style="color: #ff0000;">&quot;yes&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/edit&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${filename}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/SetVersion&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${installerVersion}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;${installer.command}&quot;</span> <span style="color: #000066;">failonerror</span>=<span style="color: #ff0000;">&quot;yes&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/build&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${filename}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>In the next snippet, which should be executed first, I&#8217;ve made the version number dynamic based on the current time, day, and month (but not year)!  (The pattern may seem a little odd; it conforms to <a href="http://msdn.microsoft.com/en-us/library/aa370859.aspx">what Windows Installer expects</a>.)  Of course, this is completely optional and can be overridden using <a href="http://ant.apache.org/manual/running.html">Ant command-line properties</a>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tstamp<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;format</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;installerVersion&quot;</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;MM.dd.HHmm&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tstamp<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>When this script is combined with continuous integration, we have a repeatable, consistent, fully automated build of our software and its installer.  And that rocks.</p>
]]></content:encoded>
			<wfw:commentRss>http://christiansons.net/mike/blog/2009/01/automate-advanced-installer-with-ant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ant on Ubuntu without GCJ</title>
		<link>http://christiansons.net/mike/blog/2009/01/ant-on-ubuntu-without-gcj/</link>
		<comments>http://christiansons.net/mike/blog/2009/01/ant-on-ubuntu-without-gcj/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 22:23:33 +0000</pubDate>
		<dc:creator>Mike Christianson</dc:creator>
				<category><![CDATA[ant]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[gcj]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.christiansons.net/?p=76</guid>
		<description><![CDATA[You may be surprised to learn Ant requires GCJ when installed through Synaptic or apt on Ubuntu.  GCJ is GNU&#8217;s Java compiler.  When you&#8217;re using Sun&#8217;s JDK and compiler, GCJ can get in the way &#8212; at worst it creates conflicts; at best it causes confusion. Here&#8217;s how I installed Ant on Ubuntu without GCJ. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://christiansons.net/mike/blog/wp-content/uploads/2009/01/ant_logo_large.gif"><img class="alignleft size-medium wp-image-88" title="Ant logo" src="/mike/blog/wp-content/uploads/2009/01/ant_logo_large.gif" alt="" width="190" height="120" /></a>You may be surprised to learn <a title="Ant website" href="http://ant.apache.org/">Ant</a> requires GCJ when installed through Synaptic or <tt>apt</tt> on Ubuntu.  GCJ is <a title="GCJ homepage" href="http://gcc.gnu.org/java/">GNU&#8217;s Java compiler</a>.  When you&#8217;re using Sun&#8217;s JDK and compiler, GCJ can get in the way &#8212; at worst it creates conflicts; at best it causes confusion.</p>
<p>Here&#8217;s how I installed Ant on Ubuntu without GCJ.<span id="more-76"></span>  <em>Be sure to check out (easier) alternatives suggested in the <a href="#comments">comments, below</a></em>.</p>
<ol>
<li>Download the current <tt>.tar.bz2</tt> distribution of Ant from <a title="Ant mirror" href="http://www.ibiblio.org/pub/mirrors/apache/ant/binaries/">http://www.ibiblio.org/pub/mirrors/apache/ant/binaries/</a>.</li>
<li>Unpack archive using <tt>tar</tt>.</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xjvf</span> apache-ant-<span style="color: #000000; font-weight: bold;">*</span>-bin.tar.bz2</pre></div></div>

<li>Move the unpacked directory to <tt>/usr/local/ant</tt>.</li>
<li>Change that directory&#8217;s owner to <tt>root</tt>.</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> root:root <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>ant</pre></div></div>

<li>Add the following lines to <tt>/etc/bash.bashrc</tt>.</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ANT_HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>ant
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #800000;">${PATH}</span>:<span style="color: #800000;">${ANT_HOME}</span><span style="color: #000000; font-weight: bold;">/</span>bin</pre></div></div>

</ol>
<p>From a new shell, run <tt>ant</tt>.  You should see the following:</p>
<pre>Buildfile: build.xml does not exist!
Build failed</pre>
<p>Yes, it&#8217;s a failure message.  But it means Ant is working as expected.  <img src='http://christiansons.net/mike/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://christiansons.net/mike/blog/2009/01/ant-on-ubuntu-without-gcj/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
