<?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>Sonatype Blog &#187; groovy</title>
	<atom:link href="http://blog.sonatype.com/people/tag/groovy/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sonatype.com/people</link>
	<description>Sonatype is transforming software development with tools, information and services that enable organizations to build better software, faster, using open-source components.</description>
	<lastBuildDate>Tue, 18 Jun 2013 15:30:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Maven: Integration and Distributed, Open Innovation</title>
		<link>http://blog.sonatype.com/people/2009/05/maven-integration-and-distributed-open-innovation/</link>
		<comments>http://blog.sonatype.com/people/2009/05/maven-integration-and-distributed-open-innovation/#comments</comments>
		<pubDate>Fri, 08 May 2009 13:08:49 +0000</pubDate>
		<dc:creator>Tim O'Brien</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=2161</guid>
		<description><![CDATA[Brian Murphy wrote a long blog post about the PAX Plugin which provides a good example of the power of Maven to act as an integration &#8220;bridge&#8221; between a number of unrelated technologies. In this post, Brian is using the PAX Maven Plugin from ops4j together with the gmaven-plugin and the maven-scala-plugin, he concludes with [...]]]></description>
				<content:encoded><![CDATA[<p>Brian Murphy wrote a <a href="http://tr.im/kP9w">long blog post about the PAX Plugin</a> which provides a good example of the power of Maven to act as an integration &#8220;bridge&#8221; between a number of unrelated technologies.   In this post, Brian is using the <a href="http://tr.im/kPcB">PAX Maven Plugin</a> from ops4j together with the <a href="http://groovy.codehaus.org/GMaven">gmaven-plugin</a> and the <a href="http://tr.im/kPbE">maven-scala-plugin</a>, he concludes with praise for Maven as an essential time saver:</p>

<blockquote>&#8220;This ended up being a much longer article than I anticipated but we&#8217;ve covered a lot of ground. Maven has worked it&#8217;s dependency voodoo which saved an enormous amount of time downloading jars and messing with classpaths. We&#8217;ve seen how the PAX toolkit from OPS4J makes creating, modifying and provisioning OSGi bundles a breeze. While the actual code examples were pretty trivial, we successfully managed to code up bundles in Java, Scala and Groovy. I think this displays a lot of the power that is offered by OSGi and points to a bright future for enterprise development on the JVM.&#8221;</blockquote>

<p><span id="more-2161"></span></p>

<h3>Project-driven Plugins: Distributed, Open Innovation</h3>

<p>In this case Maven is bridging a number of popular projects that have all created well-documented Maven plugins.    Maven is the essential &#8220;glue&#8221; that allows someone like Brian to take a number of unrelated technologies and use them in ways that the designers of GMaven or the Scala plugin could never have predicted.   As Maven matures and continues to evolve its Plugin API, we&#8217;re starting to see more projects and more systems commit to using it as an enabling &#8220;platform&#8221; for development.  Those projects that have adopted Maven have found it beneficial to host and drive the Maven plugins that relate to their project or technology.  <strong>Better support for Maven increases the adoption of Groovy, Scala, and (in this case) OSGi.</strong></p>

<p>The PAX plugin is maintained and hosted by the Ops4J project, the Scala plugin is hosted and maintained by the Scala community, and the GMaven plugin is hosted and maintained by the Groovy community.  Each community feels strongly enough about providing Maven support for their technology that they have made it a part of their project.   This is important because it suggests an evolving approach to the way Maven plugins are created and supported.   Four years ago, it was unlikely to see a project like Scala or Ops4J creating and hosting a Maven plugin.  While Maven was already ubiquitous, projects still didn&#8217;t see Maven support as a primary concern.  Instead, the plugin development would happen as part of the Maven community or in an ancillary community of Maven plugins known as the Mojo project at Codehaus.</p>

<p>Mojo is an important bridge.  It allows third-party actors to craft support for tools like JBoss and GWT, but it is an aggregate, disjoint community with a single mailing list, perfunctory release votes, and little shared discussion about architecture or planning.   It is a free-for-all.  While Mojo does host some essential plugins it is also a dumping grounds for half-finished, owner-less plugins.   As more projects provide their own Maven support, people should consider moving project from Mojo to the projects that develop the specific technologies in question.   This is the &#8220;distributed&#8221; open innovation that will encourage quality, well-documented plugins.</p>

<h3>Why Companies and Projects Need to &#8220;Own&#8221; Their Maven Support</h3>

<p>We&#8217;ve transitioned into a point where projects need to start hosting and owning the Maven plugins that enable developers to use their software.   Google would have been better off if they had invested a day or two crafting a solid Maven plugin for AppEngine before they announced Java support.   Similarly, they should think about driving the development of the GWT plugin.   If your project&#8217;s artifacts are available through the Central Maven repository, that is a first step, but if your project also publishes an artifact and a really compelling Maven plugin, you&#8217;ve made it trivial and easy for people to adopt your technology.   &#8220;Going to market&#8221; without good Maven support no longer makes sense, and you should know that more and more developers are start with the question &#8220;how does this fit into my Maven build?&#8221;  If your answer is &#8220;shrug, we don&#8217;t use Maven&#8221;, it is very likely that they will seek out other solutions that provide better integration.</p>

<p>If you are a tool vendor or create an open source framework, you should be hosting your own Maven plugin as a part of your project.   If you support an SCM like Perforce or Clearcase, you should make sure that your software provides a solid SCM provider for Maven.  If your company or project develops a server, you should be working with the Maven project to make sure that it integrates with Maven.   To do otherwise is to invite your customers or users to look elsewhere for better integration.    If you let someone else drive your Maven plugin, you are really just delegating an essential support function to the community.   The message you are sending is, &#8220;we don&#8217;t really care that you use Maven, it isn&#8217;t a priority, someone will do the integration work for us&#8221;.   This is true, but when that happens, you lose an opportunity to interact with your users and your customers.</p>

<p>PS: Brian&#8217;s post also inspired me to file <a href="https://issues.sonatype.org/browse/MVNDEF-96">this JIRA issue on the MVNDEF book project</a>.   Our book&#8217;s need code examples that can be more easily copied to the clipboard.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2009/05/maven-integration-and-distributed-open-innovation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Now Playing: Grails 1.1b2 w/ &quot;Improved Maven Support&quot;</title>
		<link>http://blog.sonatype.com/people/2008/12/now-playing-grails-11b2-with-improved-maven-support/</link>
		<comments>http://blog.sonatype.com/people/2008/12/now-playing-grails-11b2-with-improved-maven-support/#comments</comments>
		<pubDate>Sat, 27 Dec 2008 22:11:04 +0000</pubDate>
		<dc:creator>Tim O'Brien</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[g2one]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[springsource]]></category>

		<guid isPermaLink="false">http://blogs.sonatype.com/people/?p=1344</guid>
		<description><![CDATA[Graeme Rocher has never been a fan of Maven, and (as far as I can tell) he still isn&#8217;t.     In &#8220;Grails &#38; Maven Kiss and Make-up with Grails 1.1 Beta 2&#8220;, Graeme writes: So Grails 1.1 Beta 2 is out. Rejoice! There are many new features that are detailed in the release notes. However, [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright size-medium wp-image-1346" title="grails" src="http://blogs.sonatype.com/people/wp-content/uploads/2008/12/grails.png" alt="" width="208" height="64" />Graeme Rocher has never been a fan of Maven, and (as far as I can tell) he still isn&#8217;t.     In &#8220;<a href="http://graemerocher.blogspot.com/2008/12/grails-maven-kiss-and-make-up-with.html">Grails &amp; Maven Kiss and Make-up with Grails 1.1 Beta 2</a>&#8220;, Graeme writes:</p>

<blockquote>So <a href="http://grails.org/">Grails</a> 1.1 Beta 2 is out. Rejoice! There are many new features that are detailed in the r<a href="http://grails.org/1.1-Beta2+Release+Notes">elease notes</a>. However, one of the main ones in this beta is the new support for <a href="http://maven.apache.org/">Maven</a>&#8230;.Regular readers of my blog will probably be aware of my long history as one who, ahem, is not particularily fond of Maven. Granted I am <span style="font-weight: bold;">still</span> not [particularly] fond of Maven, but it is the Christmas period and in the spirit of &#8220;why can&#8217;t we all just get [along]&#8221; I am proud to say that Grails <a href="http://grails.org/Maven+Integration">integrates nicely with Maven</a> now <img src='http://blog.sonatype.com/people/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </blockquote>

<p><span style="color: #ff0000;">Merry</span> <span style="color: #008000;">Christmas</span>, indeed.
<span id="more-1344"></span></p>

<p>
In the same spirit of &#8220;why can&#8217;t we all just get along&#8221;, I&#8217;ve had a similar shift in my opinion of Groovy over the years, I used to talk about Groovy as the wrong choice when compared to something like Jython or JRuby, but after having used Groovy in a number of projects, I ready to admit defeat.  While I&#8217;m still interested in Java inoperability with Ruby and Python, it is often much more straightforward to use Groovy than it is to deal with the &#8220;impedance mismatch&#8221; between something like JRuby and Java.  Groovy has turned into a mature and valuable language that offers tight integration with the JVM thanks to the continued efforts of Graeme and Guillame at G2One (recently acquired by SpringSource).</p>

<p><a href="http://groovy.codehaus.org/GMaven">GMaven</a> provides a great option for people interested in <a href="http://groovy.codehaus.org/GMaven+-+Implementing+Maven+Plugins">writing Maven Plugins in Groovy</a> and also as a quick way to extend a Maven build with a Groovy script.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2008/12/now-playing-grails-11b2-with-improved-maven-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Searching with the Sonatype Nexus REST API: Groovy</title>
		<link>http://blog.sonatype.com/people/2008/11/searching-with-the-sonatype-nexus-rest-api-groovy/</link>
		<comments>http://blog.sonatype.com/people/2008/11/searching-with-the-sonatype-nexus-rest-api-groovy/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 21:25:30 +0000</pubDate>
		<dc:creator>Tim O'Brien</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[Nexus]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://blogs.sonatype.com/people/book/?p=284</guid>
		<description><![CDATA[This post is a follow-up to the previous post which provided some sample Ruby scripts that can be used to list repositories and search for artifacts in a Nexus instance.   Today, we&#8217;re going to see how to complete the same tasks using the Groovy scripting language.   The Groovy scripting language is a scripting language that [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright size-thumbnail wp-image-285" src="http://cms.sonatype.com/wordpress/wp-content/uploads/2008/11/scripting-nexus-groovy.png" alt="" width="115" height="99" />This post is a follow-up to the <a href="http://blogs.sonatype.com/people/book/2008/11/19/searching-with-the-nexus-rest-api-ruby/">previous post</a> which provided some sample Ruby scripts that can be used to list repositories and search for artifacts in a Nexus instance.   Today, we&#8217;re going to see how to complete the same tasks using the Groovy scripting language.   The Groovy scripting language is a scripting language that has gained popularity due to the ease of integration with the JVM.</p>

<p>The following scripts are in Groovy and they can be invoked from the command line using groovy.  For example, if you want to run the QuickSearch.groovy script, you would run &#8220;groovy QuickSearch.groovy activemq&#8221; to search for artfiacts that contain the string &#8220;activemq&#8221;.   I tested these Ruby scripts using the latest Groovy 1.5.7 distribution.  Go to the <a href="http://groovy.codehaus.org">Groovy page</a>, click on Download, and download the Cross-platform Installer, this will install Groovy on your machine and also tell you what you&#8217;ll need to add to your PATH.<span id="more-320"></span></p>

<h2>The Nexus REST API</h2>

<p>The UI of Nexus is written in ExtJS and it makes heavy use of AJAX callbacks to REST services.  In fact, if you load up Nexus in a tool like Firebug, an extension for Firefox which allows you to trace all network activity, you will see that almost every action in Nexus triggers a call to a REST service. For more details about the Nexus REST services and for a pointer to the documentation, read the <a href="http://blogs.sonatype.com/people/book/2008/11/19/searching-with-the-nexus-rest-api-ruby/">previous blog post</a> in this series which was focused on a similar set of Ruby scripts.</p>

<p>If you would like to download the sample scripts in this blog post, you can download this ZIP file which contains four Groovy scripts: <a href="http://books.sonatype.com/tutorial-files/nexus-rest-groovy.zip">http://books.sonatype.com/tutorial-files/nexus-rest-groovy.zip</a></p>

<h2>Listing Repositories</h2>

<p>The first script simply lists all of the repositories in a Nexus installation.  Here it is:</p>


<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> xml <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;http://repository.sonatype.org/service/local/repositories&quot;</span>.<span style="color: #CC0099;">toURL</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">text</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">def</span> root <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XmlParser<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">parseText</span><span style="color: #66cc66;">&#40;</span> xml <span style="color: #66cc66;">&#41;</span>
root.<span style="color: #006600;">data</span>.<span style="color: #ff0000;">'repositories-item'</span>.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;${it.name.text()} (${it.id.text()})&quot;</span>
  <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>${it.resourceURI.text()}<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>


<p>This script sets the pattern for the scripts to follow.  We construct a URL in String, then we call toURL() and get the text attribute from the method call.   In one line we fetch the response body.  then we use the XmlParser in Groovy to print out the Repository name, id, and URL.  This script could not be more straightforward.  This post is simply a pointer to the service and a quick demonstration so I&#8217;m not going to dive into the meaning of every single element in the XML document returned by the repositories service.   If you are interested in see the full set of elements that are available, load up the results of this service in a web browser by click on this: <a href="http://repository.sonatype.org/service/local/repositories">http://repository.sonatype.org/service/local/repositories</a>.</p>

<h2>Performing a &#8220;Quick Search&#8221;</h2>


<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> xml <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://repository.sonatype.org/service/local/data_index?q=&quot;</span> <span style="color: #66cc66;">+</span> args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #CC0099;">toURL</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">text</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">def</span> root <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XmlParser<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">parseText</span><span style="color: #66cc66;">&#40;</span> xml <span style="color: #66cc66;">&#41;</span>
root.<span style="color: #006600;">data</span>.<span style="color: #006600;">artifact</span>.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;${it.groupId.text()}:${it.artifactId.text()}:${it.version.text()}&quot;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>


<p>This script follows the pattern of the previous script to list all repositories with the exception that it reads an argument from the command line.   This script performs a quick search by hitting the <em>data_index</em> service and passing in the <em>q</em> parameter.   This script simply prints out the <em>groupId:artifactId:version</em> of all the artifacts located.</p>

<p>If you would like to see an example of the XML that this service produces click here: <a title="http://repository.sonatype.org/service/local/data_index?q=activemq" href="http://repository.sonatype.org/service/local/data_index?q=activemq">http://repository.sonatype.org/service/local/data_index?q=activemq</a>. In the full results, you&#8217;ll see more information such as the number of search hits available, the resource URL for each artifact found, and the context (or repository) in which the artifact is available.</p>

<h2>Searching by Class Name</h2>


<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> xml <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://repository.sonatype.org/service/local/data_index?cn=&quot;</span> <span style="color: #66cc66;">+</span> args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #CC0099;">toURL</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">text</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">def</span> root <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XmlParser<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">parseText</span><span style="color: #66cc66;">&#40;</span> xml <span style="color: #66cc66;">&#41;</span>
root.<span style="color: #006600;">data</span>.<span style="color: #006600;">artifact</span>.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;${it.groupId.text()}:${it.artifactId.text()}:${it.version.text()}&quot;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>


<p>This script is almost exactly the same as the prior script that performed a quick search.  The difference in this script is that instead of passing the q parameter, this script passes the cn parameter.   Passing the cn parameter causes Nexus to search for artifacts which contain classes that match the given value.   The results are going to look the same as the quick search query script.     To see the XML yourself, search for all artifacts which contain a class named HibernateDaoSupport: <a href="http://repository.sonatype.org/service/local/data_index?cn=HibernateDaoSupport">http://repository.sonatype.org/service/local/data_index?cn=HibernateDaoSupport</a>.</p>

<h2>Performing a GAV Search</h2>


<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> xml <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;http://repository.sonatype.org/service/local/data_index?g=${args[0]}&amp;amp;a=${args[1]}&amp;amp;v=${args[2]}&quot;</span>.<span style="color: #CC0099;">toURL</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">text</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">def</span> root <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XmlParser<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">parseText</span><span style="color: #66cc66;">&#40;</span> xml <span style="color: #66cc66;">&#41;</span>
root.<span style="color: #006600;">data</span>.<span style="color: #006600;">artifact</span>.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;${it.groupId.text()}:${it.artifactId.text()}:${it.version.text()}&quot;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>


<p>This final script takes three command line arguments: groupId, artifactId, version, and it performs a GAV (groupId, artifactId, version) coordinate search over the repository.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2008/11/searching-with-the-sonatype-nexus-rest-api-groovy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
