<?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>The Bruised Edge &#187; Clojure</title>
	<atom:link href="http://weblog.kevinclarke.info/category/clojure/feed/" rel="self" type="application/rss+xml" />
	<link>http://weblog.kevinclarke.info</link>
	<description>Digital Libraries, Repositories, Programming, Technology, Librarianship, etc.</description>
	<lastBuildDate>Wed, 28 Jul 2010 03:19:41 +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>Howto: Experiment with Clojure Eclipse Maven</title>
		<link>http://weblog.kevinclarke.info/2009/07/05/howto-clojure-eclipse-maven/</link>
		<comments>http://weblog.kevinclarke.info/2009/07/05/howto-clojure-eclipse-maven/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 22:38:00 +0000</pubDate>
		<dc:creator>ksclarke</dc:creator>
				<category><![CDATA[Clojure]]></category>

		<guid isPermaLink="false">http://weblog.kevinclarke.info/?p=255</guid>
		<description><![CDATA[So&#8230; I&#8217;ve gotten interested in Clojure and, since I&#8217;m a native Eclipse/Maven user, my first instinct was to try out Clojure from within my old familiar environment&#8230;. Thinks I to myself, &#8220;That shouldn&#8217;t be too hard since Clojure runs on the JVM.&#8221; Luckily for me, it turns out to be very easy to get clojure-dev [...]]]></description>
			<content:encoded><![CDATA[<p>So&#8230; I&#8217;ve gotten interested in Clojure and, since I&#8217;m a native Eclipse/Maven user, my first instinct was to try out Clojure from within my old familiar environment&#8230;. Thinks I to myself, &#8220;That shouldn&#8217;t be too hard since Clojure runs on the JVM.&#8221;  Luckily for me, it turns out to be very easy to get <a href="http://code.google.com/p/clojure-dev/">clojure-dev</a> (the Eclipse Clojure plugin) working with <a href="http://m2eclipse.codehaus.org/">m2eclipse</a> (the Eclipse Maven plugin I use).</p>
<p>First, I <a href="http://code.google.com/p/clojure-dev/wiki/Documentation#Install_clojure-dev_plugin">installed the Eclipse Clojure plugin</a>.  Installation was easy thanks to the Eclipse update site that they provide.  I should note that I already had the Eclipse Maven plugin installed, but that can be <a href="http://m2eclipse.codehaus.org/">installed in the same way</a>. Next, I had to install the clojure jars that come with the clojure-dev plugin into my local maven repository.</p>
<p>Maven provides a standard way of installing third party jars.  First, I cd&#8217;ed into my Eclipse plugins directory (mine is at <em>/opt/eclipse/plugins</em>), then I typed:</p>
<p><code>mvn install:install-file -Dfile=clojure_1.0.0/clojure.jar -DgroupId=org.clojure -DartifactId=clojure-lang -Dversion=1.0 -Dpackaging=jar</code></p>
<p>The clojure jar is the one that comes with clojure-dev, version 0.0.36; later versions of the plugin might include different versions of clojure.  Next, I wanted to install clojure&#8217;s contributed libraries, so I typed:</p>
<p><code>mvn install:install-file -Dfile=clojurecontrib_0.0.0.20090504_r756/clojure-contrib.jar -DgroupId=org.clojure -DartifactId=clojure-contrib -Dversion=0.0.0.20090504_r756 -Dpackaging=jar</code></p>
<p>Like the main jar, the name of the contributed jar (and its parent directory) will most definitely change over time. So, with this done, I should be ready to go.</p>
<p>All I needed to do then was to modify my pom.xml to use the clojure jars (and any other jars I might want to use).  I added a dependencies section to my pom.xml:</p>
<p><code>&lt;dependencies&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.clojure&lt;/groupId&gt;<br />
&lt;artifactId&gt;clojure-lang&lt;/artifactId&gt;<br />
&lt;version&gt;1.0&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.clojure&lt;/groupId&gt;<br />
&lt;artifactId&gt;clojure-contrib&lt;/artifactId&gt;<br />
&lt;version&gt;0.0.0.20090504_r756&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.ccil.cowan.tagsoup&lt;/groupId&gt;<br />
&lt;artifactId&gt;tagsoup&lt;/artifactId&gt;<br />
&lt;version&gt;0.9.7&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;/dependencies&gt;</code></p>
<p>Then I created .clj file with a simple test:</p>
<p><code>(ns info.freelibrary.test)<br />
(. (new org.ccil.cowan.tagsoup.Parser) (toString))</code></p>
<p>It worked! So, the next step was to see if adding a jar with just .clj files would work (I had no reason to think it wouldn&#8217;t).  I downloaded <a href="http://github.com/cgrand/enlive/tree/master">enlive</a> and then jar&#8217;ed up the contents of the <em>src</em> directory.</p>
<p>The next step was to add that new jar (enlive.jar) to the local maven repository which I did with:</p>
<p><code>mvn install:install-file -Dfile=enlive.jar -DgroupId=net.cgrand.enlive-html -DartifactId=enlive-html -Dversion=1.0-SNAPSHOT -Dpackaging=jar</code></p>
<p>Then I added a new dependency to my pom.xml by including:</p>
<p><code>&lt;dependency&gt;<br />
&lt;groupId&gt;net.cgrand.enlive-html&lt;/groupId&gt;<br />
&lt;artifactId&gt;enlive-html&lt;/artifactId&gt;<br />
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;<br />
&lt;/dependency&gt;</code></p>
<p>Next, to test that everything was working, I modified my .clj file to:</p>
<p><code>(ns info.freelibrary.test<br />
	(:refer-clojure :exclude [empty complement])<br />
	(:use net.cgrand.enlive-html)<br />
)<br />
(select<br />
	(html-resource<br />
		(java.net.URL. "http://library.appstate.edu/")<br />
	) [:#main [:a (attr? :href)]]<br />
)</code></p>
<p>And I ran it from within Eclipse using Ctrl-L.  It ran and gave me valid output. Hurray!  So, that&#8217;s it&#8230;  I can now continue experimenting with Clojure using Eclipse and the Maven plugin.</p>
<p><em>Caveat: Though the above worked, the tagsoup dependency for enlive is really 1.2 (but there is no tagsoup-1.2 in the maven repository).  I used an older version for testing but you can, of course, add the 1.2 version to your local maven repository in the same way you added the clojure jars (above).</em></p>
]]></content:encoded>
			<wfw:commentRss>http://weblog.kevinclarke.info/2009/07/05/howto-clojure-eclipse-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
