<?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>Jabbering Giraffe &#187; ant</title>
	<atom:link href="http://happygiraffe.net/blog/tag/ant/feed/" rel="self" type="application/rss+xml" />
	<link>http://happygiraffe.net/blog</link>
	<description></description>
	<lastBuildDate>Wed, 19 Oct 2011 10:40:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>jslint4maven</title>
		<link>http://happygiraffe.net/blog/2009/07/28/jslint4maven/</link>
		<comments>http://happygiraffe.net/blog/2009/07/28/jslint4maven/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 21:13:52 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[jslint4java]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1570</guid>
		<description><![CDATA[A real maven plugin for jslint4java would be nice. I will write one, but until then, you can always get away with using the antrun plugin. This is fairly simple to do now that jslint4java is available in the central &#8230; <a href="http://happygiraffe.net/blog/2009/07/28/jslint4maven/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A real maven plugin for jslint4java would be nice.  I will write one, but until then, you can always get away with using the <a href="http://maven.apache.org/plugins/maven-antrun-plugin">antrun plugin</a>.  This is fairly simple to do now that jslint4java is <a href="http://repo1.maven.org/maven2/com/googlecode/jslint4java/">available</a> in the central maven repository.</p>
<p>Here&#8217;s a plugin definition of how to do it.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-antrun-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.googlecode.jslint4java<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jslint4java-ant<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jslint<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>run<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tasks<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ant</span> <span style="color: #000066;">antfile</span>=<span style="color: #ff0000;">&quot;${basedir}/jslint.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;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;root&quot;</span> <span style="color: #000066;">location</span>=<span style="color: #ff0000;">&quot;${basedir}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jslint&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ant<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tasks<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Notice how you can add the jslint4java-ant dependency to the antrun plugin without affecting the dependencies of the project.</p>
<p>At the test phase, maven will now run jslint for you.  This relies on a small external ant build file to actually perform the jslint task.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- jslint.xml --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">xmlns:jsl</span>=<span style="color: #ff0000;">&quot;antlib:com.googlecode.jslint4java&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jslint&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jsl:jslint<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;formatter</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;plain&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;${root}/src/main/webapp&quot;</span> <span style="color: #000066;">includes</span>=<span style="color: #ff0000;">&quot;**/*.js&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jsl:jslint<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>We can use the nice <a href="http://ant.apache.org/manual/CoreTypes/antlib.html#antlibnamespace">antlibs namespace</a> style of declaration because the jslint4java jar is in the classpath already.</p>
<p>Here, I&#8217;m assuming that we&#8217;re in a war project and want to validate all the files under <code>src/main/webapp</code>.  If this goes wrong, you&#8217;ll get an error and the build will stop.  For example:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">…
Tests run: 26, Failures: 0, Errors: 0, Skipped: 0
&nbsp;
[INFO] [antrun:run {execution: jslint}]
[INFO] Executing tasks
&nbsp;
jslint:
[jsl:jslint] contact.js:1:8:Bad line breaking before '+'.
[jsl:jslint]         + &quot; Nulla in felis Aliquam luctus Proin tincidunt nisi Donec suscipit&quot;
[jsl:jslint]         ^
…
[jsl:jslint] load.js:17:6:Missing semicolon.
[jsl:jslint]     })
[jsl:jslint]       ^
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] An Ant BuildException has occured: The following error occurred while executing this line:
/Users/dom/work/someproj/jslint.xml:4: 3 files did not pass JSLint</pre></div></div>

<p>One side note: originally, I tried to fold the <code>jslint.xml</code> file into the POM as well.  But this failed to load the antlib.  I suspect that xmlns attributes were not being passed in to the tasks definition.  It&#8217;s not a big deal..</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2009/07/28/jslint4maven/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AntUnit inside Maven</title>
		<link>http://happygiraffe.net/blog/2008/09/15/antunit-inside-maven/</link>
		<comments>http://happygiraffe.net/blog/2008/09/15/antunit-inside-maven/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 19:50:52 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jslint4java]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1387</guid>
		<description><![CDATA[I&#8217;m in the middle of converting jslint4java to use maven as its build system (yes, really). Part of this is ensuring that the antunit tests I wrote continue to work. Maven has the antrun plugin, but it&#8217;s not 100% obvious &#8230; <a href="http://happygiraffe.net/blog/2008/09/15/antunit-inside-maven/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in the middle of converting <a href="http://code.google.com/p/jslint4java/">jslint4java</a> to use maven as its build system (yes, really).  Part of this is ensuring that the <a href="http://ant.apache.org/antlibs/antunit/">antunit</a> tests I wrote continue to work.  Maven has the <a href="http://maven.apache.org/plugins/maven-antrun-plugin/">antrun plugin</a>, but it&#8217;s not 100% obvious how to use an antlib inside it.</p>
<p>Normally, to run an <a href="http://ant.apache.org/manual/CoreTypes/antlib.html">antlib</a> extension as part of your build, you first dump the jar in <code>~/.ant/lib</code> (or on the command line using a <code>-lib</code> flag) and then reference it in a namespace.  e.g.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;foo&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">xmlns:au</span>=<span style="color: #ff0000;">&quot;antlib:org.apache.ant.antunit&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    …
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This relies on ant being able to pick out <code>org/apache/ant/antunit/antlib.xml</code> from the classpath.</p>
<p>When doing this in maven through the antrun plugin, you can&#8217;t just dump stuff into <code>~/.ant/lib</code> however.  You need to tell ant where everything is. Originally, I was following the example of the <a href="http://svn.apache.org/repos/asf/incubator/rat/main/trunk/rat/rat-anttasks/pom.xml">rat ant task</a>.  This attempts to invoke a second copy of ant with the correct <code>-lib</code> argument.  It&#8217;s ugly though.  Why should we fork a second copy of the JVM?  And ant may not even be installed (in maven, it&#8217;s just jar files in the local repository).</p>
<p>Eventually, I looked closer at the antlib documentation and found <a href="http://ant.apache.org/manual/CoreTypes/antlib.html#loadFromInside">Load antlib from inside of the buildfile</a>.  This shows how a <a href="http://ant.apache.org/manual/CoreTasks/typedef.html">typedef</a> is the key: You can associate a given antlib URI with a particular classpath entry.  Thankfully, maven-antrun-plugin provides <code>${maven.test.classpath}</code> (amongst others) which contains every entry that we need.  So the solution now looks something like this.</p>
<p>Firstly, <a href="http://code.google.com/p/jslint4java/source/browse/trunk/jslint4java-ant/pom.xml"><code>pom.xml</code></a>.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.ant<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ant-antunit<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-antrun-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>run<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tasks<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ant</span> <span style="color: #000066;">antfile</span>=<span style="color: #ff0000;">&quot;${build.testOutputDirectory}/antunit/tests.xml&quot;</span></span>
<span style="color: #009900;">                  <span style="color: #000066;">inheritAll</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">inheritRefs</span>=<span style="color: #ff0000;">&quot;false&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;test.classpath&quot;</span> <span style="color: #000066;">refid</span>=<span style="color: #ff0000;">&quot;maven.test.classpath&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ant<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tasks<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #808080; font-style: italic;">&lt;!-- Force an upgrade to a newer ant version.  Required by antunit. --&gt;</span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.ant<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ant<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.7.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>So, when we get to the test phase, we automatically run <a href="http://code.google.com/p/jslint4java/source/browse/trunk/jslint4java-ant/src/test/resources/antunit/tests.xml"><code>antunit/tests.xml</code></a>, passing in the correct classpath.  This is what the ant file looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jslint-antunit&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">xmlns:au</span>=<span style="color: #ff0000;">&quot;antlib:org.apache.ant.antunit&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;taskdef</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;antlib:org.apache.ant.antunit&quot;</span></span>
<span style="color: #009900;">               <span style="color: #000066;">resource</span>=<span style="color: #ff0000;">&quot;org/apache/ant/antunit/antlib.xml&quot;</span></span>
<span style="color: #009900;">               <span style="color: #000066;">classpath</span>=<span style="color: #ff0000;">&quot;${test.classpath}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      …
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This appears to work quite well, and runs my tests a sight quicker than before.  If anybody from the <a href="http://incubator.apache.org/rat/">apache rat project</a> is listening, you might want to update your POMs.  <img src='http://happygiraffe.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2008/09/15/antunit-inside-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jslint4java 1.2</title>
		<link>http://happygiraffe.net/blog/2008/09/07/jslint4java-12/</link>
		<comments>http://happygiraffe.net/blog/2008/09/07/jslint4java-12/#comments</comments>
		<pubDate>Sun, 07 Sep 2008 00:07:25 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jslint4java]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1369</guid>
		<description><![CDATA[I&#8217;ve finally gotten around to finishing off the code that I&#8217;ve had sitting around in google code for over a year, and released jslint4java 1.2. The changes are actually pretty small: Update to jslint 2008-09-04. This adds several new options. &#8230; <a href="http://happygiraffe.net/blog/2008/09/07/jslint4java-12/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve <em>finally</em> gotten around to finishing off the code that I&#8217;ve had sitting around in google code for over a year, and released <a href="http://code.google.com/p/jslint4java/">jslint4java 1.2</a>.  The changes are actually pretty small:</p>
<ul>
<li>Update to <a href="http://www.jslint.com/">jslint</a> 2008-09-04.  This adds several new options.</li>
<li>Several updates to the ant task:
<ul>
<li>Move the antlib definition to &#8220;antlib:net.happygiraffe.jslint&#8221; <strong>(incompatible change)</strong>.</li>
<li>Default to failing the build if validation fails <strong>(incompatible change)</strong>.</li>
<li>Allow use of the <a href="http://ant.apache.org/manual/CoreTypes/fileset.html">fileset</a> element to be more flexible about specifying where your javascript files are. This replaces several attributes on the jslint task <strong>(incompatible change)</strong>.</li>
<li>Add a formatter sub-element, which can output either XML or plain text, either to the console or to a file.</li>
<li>See the <a href="http://code.google.com/p/jslint4java/wiki/JSLintAntTask">documentation</a> for some examples of the new usage.</li>
</ul>
</li>
<li>Allow access to the HTML report produced by JSLint through an API.</li>
</ul>
<p>I&#8217;ve also uploaded the <a href="http://jslint4java.googlecode.com/svn/apidoc/1.2/index.html">javadoc</a> directly into subversion on google code, so it&#8217;s permanently online.  The google-collections guys seem to do this, so it can&#8217;t be a bad idea, right?</p>
<p>Typical.  Five minutes after I release, I notice that it&#8217;s been compiled with 1.6 instead of 1.5.  So, I&#8217;ve just released v1.2.1…</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2008/09/07/jslint4java-12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One-Jar</title>
		<link>http://happygiraffe.net/blog/2006/08/02/one-jar/</link>
		<comments>http://happygiraffe.net/blog/2006/08/02/one-jar/#comments</comments>
		<pubDate>Wed, 02 Aug 2006 07:43:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/08/02/one-jar/</guid>
		<description><![CDATA[I was trying to fix the build of a project last night. It used to unpack several dependent jar files before repackaging them along with the project code. How ugly. Then I remembered about one-jar, which lets you package things &#8230; <a href="http://happygiraffe.net/blog/2006/08/02/one-jar/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was trying to fix the build of a project last night.  It used to unpack several dependent jar files before repackaging them along with the project code.  How ugly.  Then I remembered about <a href="http://one-jar.sourceforge.net/">one-jar</a>, which lets you package things in a slightly more sensible manner, retaining the individual files.</p>
<p>The documentation isn&#8217;t as good as it could be.  But after a bit of poking around, I came up with this ant task to build my jar.</p>
<pre>
  &lt;property name="onejar" value="one-jar-boot-0.95.jar"/&gt;

    &lt;target name="dist" depends="compile"&gt;
        &lt;!-- Set up the on-jar directory structure. --&gt;
        &lt;mkdir dir="${build.onejar.dir}" /&gt;
        &lt;mkdir dir="${build.onejar.dir}/boot" /&gt;
        &lt;mkdir dir="${build.onejar.dir}/lib" /&gt;
        &lt;mkdir dir="${build.onejar.dir}/main" /&gt;
        &lt;!-- First, build just our code into a jar of its own. --&gt;
        &lt;jar destfile="${build.onejar.dir}/main/main.jar"
             basedir="${build.prod.dir}"&gt;
            &lt;manifest&gt;
                &lt;attribute name="Main-Class"
                           value="net.happygiraffe.Main" /&gt;
            &lt;/manifest&gt;
        &lt;/jar&gt;
        &lt;!-- Next, copy in the libs we depend upon. --&gt;
        &lt;copy todir="${build.onejar.dir}/lib"&gt;
            &lt;fileset dir="${vendor.lib.dir}"&gt;
                &lt;include name="*.jar" /&gt;
                &lt;exclude name="${onejar}" /&gt;
            &lt;/fileset&gt;
        &lt;/copy&gt;
        &lt;!-- Extract the One-Jar bits on top. --&gt;
        &lt;unjar src="${vendor.lib.dir}/${onejar}"
               dest="${build.onejar.dir}" /&gt;
        &lt;!-- And finally, repackage. --&gt;
        &lt;jar destfile="${jar.path}"
             basedir="${build.onejar.dir}"
             manifest="${build.onejar.dir}/META-INF/MANIFEST.MF" /&gt;
    &lt;/target&gt;
</pre>
<p>And then when I tried to run the jar, it fell over.</p>
<pre>
  Exception in thread "main" java.util.zip.ZipException: No such file or directory
          at java.util.zip.ZipFile.open(Native Method)
          at java.util.zip.ZipFile.&lt;init&gt;(ZipFile.java:203)
          at java.util.jar.JarFile.&lt;init&gt;(JarFile.java:132)
          at java.util.jar.JarFile.&lt;init&gt;(JarFile.java:70)
          at com.simontuffs.onejar.Boot.run(Boot.java:179)
          at com.simontuffs.onejar.Boot.main(Boot.java:105)
</pre>
<p>After substantial amounts of time messing around, it turned out that it&#8217;s a buug when you&#8217;re using Mac <span class="caps">OS X</span> and Java 5.  The latest <span class="caps">CVS</span> code has a fix (<a href="http://one-jar.cvs.sourceforge.net/one-jar/one-jar/src/com/simontuffs/onejar/Boot.java?view=log#rev1.14">Boot.java 1.14</a>).  Once I&#8217;d got the latest version from <span class="caps">CVS</span>, everything worked wonderfully.  I only hope that it&#8217;s released soon.</p>
<p>Not only that, but when I looked through the <span class="caps">CVS</span> code, I noticed that there was an ant task as well.  That would certainly simplify the rather verbose script above.  I&#8217;ll have to look into that.</p>
<p>If you&#8217;re interested in the architecture of one-jar, check out the developerworks article <a href="http://www-128.ibm.com/developerworks/library/j-onejar/">Simplify your application delivery with One-JAR</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/08/02/one-jar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ant &amp; JUnit</title>
		<link>http://happygiraffe.net/blog/2005/09/03/ant-junit/</link>
		<comments>http://happygiraffe.net/blog/2005/09/03/ant-junit/#comments</comments>
		<pubDate>Sat, 03 Sep 2005 08:05:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[junit]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2005/09/03/ant-junit/</guid>
		<description><![CDATA[I&#8217;ve just been tripped up by ant &#38; JUnit. I&#8217;m appalled. All the proposed solutions are both hackish and ugly. I don&#8217;t actually care about the intricacies of ClassLoaders. I just want a simple way to tell ant &#8220;junit is &#8230; <a href="http://happygiraffe.net/blog/2005/09/03/ant-junit/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just been tripped up by <a href="http://ant.apache.org/faq.html#delegating-classloader">ant &amp; JUnit</a>.  I&#8217;m appalled.  All the proposed solutions are both hackish and ugly.  I don&#8217;t actually <em>care</em> about the intricacies of ClassLoaders.  I just want a simple way to tell ant &#8220;junit is over here&#8221; so that my build and tests will work on whatever system I check out on.  I don&#8217;t want to have to install stuff into the ant directory on each system.  I already have <code>junit.jar</code> in my codebase, and it should be able to use it.</p>
<p>I suppose I could get around it by writing a <code>build.sh</code> which sets the <span class="caps">CLASSPATH</span> correctly, but I thought ant was supposed to avoid all that?</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2005/09/03/ant-junit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

