<?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; pom</title>
	<atom:link href="http://blog.sonatype.com/people/tag/pom/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>Thu, 16 May 2013 18:53:09 +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>How not to download the Internet</title>
		<link>http://blog.sonatype.com/people/2011/04/how-not-to-download-the-internet/</link>
		<comments>http://blog.sonatype.com/people/2011/04/how-not-to-download-the-internet/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 13:00:16 +0000</pubDate>
		<dc:creator>Tim O'Brien</dc:creator>
				<category><![CDATA[Nexus]]></category>
		<category><![CDATA[Sonatype]]></category>
		<category><![CDATA[dependencies]]></category>
		<category><![CDATA[pom]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=7399</guid>
		<description><![CDATA[A criticism I hear often about Maven is, &#8220;every time you run Maven, it downloads the internet.&#8221; I understand the criticism, as the first time you run Maven it has to populate your local repository. Maven downloads plugins and artifacts that your project depends on. Maven does in fact download artifacts from remote repositories, but [...]]]></description>
				<content:encoded><![CDATA[<p>A criticism I hear often about Maven is, &#8220;every time you run Maven, it downloads the internet.&#8221;   I understand the criticism, as the first time you run Maven it has to populate your local repository.  Maven downloads plugins and artifacts that your project depends on.    Maven does in fact download artifacts from remote repositories, but it downloads the artifact once and keeps a local cache.</p>

<p>Maven only downloads most of these dependencies because you&#8217;ve added them to your project.   If you are unhappy that Maven is &#8220;downloading the internet&#8221; then stop developing software that depends on external libraries.   Easy, right?   Stop using Spring and Hibernate, stop referencing the commons libraries, and do everything yourself.   This would be one way to avoid downloading any artifacts from a remote repository.   Stop using Maven to build your software and write your own build tool that has all of the capabilities of Maven and every imaginable Maven plugin baked into it.</p>

<p>Not a workable solution, right?   The fact of the matter is that your software has dependencies on external libraries.   If you find yourself constantly &#8220;downloading the internet&#8221; there&#8217;s a reason.   You are depending on projects that depend on &#8220;the internet&#8221; or, your projects have a very wide set of dependencies that may need to be trimmed.</p>

<p>How can we avoid creating projects and POMs that &#8220;download the internet&#8221;?    The simple answer is that everyone needs to start focusing on dependencies.    Library developers need to be smarter about creating leaner, meaner dependency lists, and you need to start evaluating your own dependencies with an eye on efficiency.</p>

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

<h3>Library Developers Need to Modularize</h3>

<p>Take a project like Spring as an example.  Spring&#8217;s libraries provide interoperability across a number of core enterprise APIs: JMS, JDBC, JTA.  Spring also allows people to plug-in different implementations for various feature: Hibernate, ehcache, MyBatis, log4j, slf4j, etc.   Picking on Spring in particular, artifacts from Spring tend to rely on the world.   If you use some of the core Spring libraries you&#8217;ll soon realize that that one simple dependency XML snippet actually translates to 30 or 40 dependencies.</p>

<p>If you are creating a library (Spring, Guice, or Hibernate) you need to start thinking about the dependencies that you are selecting.   Instead of just blindly adding in a dependency to ten artifacts, split up your projects so you don&#8217;t create that one, gigantic library which depends on the world.    I&#8217;ll bring the conversation back to Spring.  Spring is moving in the right direction, the most recent version of spring-core version 3 has five dependencies, while spring-core 2.5.6 has 13 dependencies.   If you&#8217;ve watched the progression of the Spring libraries over time, you&#8217;ll notice a trend toward modularization.   Take the Spring AWS as an example &#8211; there isn&#8217;t just one spring-aws library, there is a spring-aws-ant, spring-aws-ivy, spring-aws-maven library.   As more people within the Springsource use Maven as a build tool, more people are starting to realize the value of having more projects with lighter POMs.</p>

<p>This matters because low-level, almost universal libraries like Spring, Hibernate, log4j, Guice, Commons libraries.  These projects end up putting dependencies into everyone&#8217;s classpath.     If developers of popular libraries get the message and move toward more modular project scopes then you shouldn&#8217;t see so much bloat in your own project&#8217;s classpaths.</p>

<h3>Don&#8217;t just let any dependency into your project</h3>

<p>What can you do?   You need to have some standards.  Don&#8217;t just let anybody put some new dependency into your POM.  Have some process to evaluate and assess exactly what a new dependency is going to do to your classpath.   Is that new-fangled database library going to drop a dependency bomb and pull in 20 other libraries, some of which have incompatible licenses?</p>

<p>One tool you can use to make this process easier is Nexus Professional.   Nexus Professional has a new Maven Dependency report.   It is very easy to use, find an artifact in Nexus Professional, and then select the Maven Dependencies tab.   This report will allow you to see just how many dependencies a particular artifact is going to introduce into your project.   It will also list artifacts that may be missing from the public repositories, giving you a chance to assess the quality of an artifact&#8217;s dependencies.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2011/04/how-not-to-download-the-internet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Navigation improvements in the m2eclipse XML POM editor</title>
		<link>http://blog.sonatype.com/people/2011/02/navigation-improvements-in-the-m2eclipse-xml-pom-editor/</link>
		<comments>http://blog.sonatype.com/people/2011/02/navigation-improvements-in-the-m2eclipse-xml-pom-editor/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 17:00:18 +0000</pubDate>
		<dc:creator>mkleint</dc:creator>
				<category><![CDATA[m2eclipse]]></category>
		<category><![CDATA[Sonatype]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[pom]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=6869</guid>
		<description><![CDATA[If you use the m2eclipse POM XML editor, you will be interested to know that we&#8217;ve made a number of improvements to the interface.   Yesterday, we introduced some addition auto-correct options and automatic integration of the POM XML editor and the Artifact Search dialog.   Today, we focus on improved navigation options now available [...]]]></description>
				<content:encoded><![CDATA[<p>If you use the m2eclipse POM XML editor, you will be interested to know that we&#8217;ve made a number of improvements to the interface.   Yesterday, we introduced some addition auto-correct options and automatic integration of the POM XML editor and the Artifact Search dialog.   Today, we focus on improved navigation options now available in the m2eclipse POM XML Editor. By making use of the current effective POM, we are able to give you more information right at your fingertips.</p>

<p>The screenshot below shows options that are available to you by hovering over on an expression in the m2eclipse POM XML Editor.</p>

<p><img class="aligncenter size-full wp-image-6880" style="border: 1px solid black;" title="hover_expression" src="http://www.sonatype.com/people/wp-content/uploads/2011/01/hover_expression1.png" alt="" width="526" height="95" /></p>

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

<p>When hovering your mouse on top of a managed dependency, we show the currently resolved version of the artifact (dependency or plugin) and also where the artifact is managed (the model&#8217;s coordinates).</p>

<p>Invoking a hyperlink on the managed artifact gives you some new options as well. If the location is in another pom.xml file, that POM file is opened for you, and the cursor is placed at the location of the artifact&#8217;s definition.</p>

<p><img class="aligncenter size-full wp-image-6873" style="border: 1px solid black;" title="navigate_managed" src="http://www.sonatype.com/people/wp-content/uploads/2011/01/navigate_managed.png" alt="" width="408" height="91" /></p>

<p>Next to the preexisting option to open the artifact&#8217;s POM, you can now also navigate to the location where the artifact is managed. Let&#8217;s see where it leads us.</p>

<p><img class="aligncenter size-full wp-image-6874" style="border: 1px solid black;" title="hover_expression" src="http://www.sonatype.com/people/wp-content/uploads/2011/01/hover_expression.png" alt="" width="526" height="95" /></p>

<p>As you can see the artifact&#8217;s managed location is using an expression for declaring the version. Here you can again hover your mouse over the expression to see what it resolves to in the effective POM. To get to the definition of the property, just invoke the hyperlink again (Ctrl-Left Click on most platforms, Cmd-Left Click on MacOSX). See the next screenshot.</p>

<p><img class="aligncenter size-full wp-image-6875" style="border: 1px solid black;" title="navigate_expression" src="http://www.sonatype.com/people/wp-content/uploads/2011/01/navigate_expression1.png" alt="" width="370" height="81" /></p>

<p>After hyperlinking, you reach the definition of the antlr.version property and you can finally change the property value and upgrade your ant-antlr dependency.  If you find any issues with this feature or have a great idea for improvement, please don&#8217;t hesitate to file an issue in the <a rel="nofollow" href="https://bugs.eclipse.org/bugs/enter_bug.cgi?product=m2e&amp;component=editors" target="_blank">eclipse.org bugzilla</a>.</p>

<p>These improvements will be available from the <a href="http://download.eclipse.org/releases/indigo">Indigo repository</a> at the end of this week as part of the M5 release. If you are adventurous you can try the temporary Hudson build which can be found <a href="https://repository.sonatype.org/content/sites/forge-sites/m2e/0.13.0/N/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2011/02/navigation-improvements-in-the-m2eclipse-xml-pom-editor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inserting artifacts in the m2eclipse POM editor</title>
		<link>http://blog.sonatype.com/people/2011/01/inserting-artifacts-in-the-m2eclipse-pom-editor/</link>
		<comments>http://blog.sonatype.com/people/2011/01/inserting-artifacts-in-the-m2eclipse-pom-editor/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 07:00:30 +0000</pubDate>
		<dc:creator>mkleint</dc:creator>
				<category><![CDATA[m2eclipse]]></category>
		<category><![CDATA[Sonatype]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[pom]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=6860</guid>
		<description><![CDATA[In the upcoming m2eclipse release, we&#8217;ve reworked how inserting artifacts (dependencies, plugins, parents) works in the XML editor. Instead of generating a skeleton template snippet for you to populate with maven coordinates (groupId/artifactId/version) we reuse the Artifact Search dialog. This post is a glimpse into some of the functionality that will be available in the [...]]]></description>
				<content:encoded><![CDATA[<p>In the upcoming m2eclipse release, we&#8217;ve reworked how inserting artifacts (dependencies, plugins, parents) works in the XML editor. Instead of generating a skeleton template snippet for you to populate with maven coordinates (groupId/artifactId/version) we reuse the Artifact Search dialog.  This post is a glimpse into some of the functionality that will be available in the coming weeks.</p>

<p>Instead of expecting a user to supply these artifacts directly in the XML editor, you now have the option to search for an artifact and let m2eclipse take care of the details. We&#8217;ve also made some improvements to the Artifact Search dialog. Screenshots speak as thousands of words though so let&#8217;s take a look.</p>

<p><img class="aligncenter size-full wp-image-6862" style="border: 1px solid black;" title="insert" src="http://www.sonatype.com/people/wp-content/uploads/2011/01/insert.png" alt="" width="681" height="266" /></p>

<p>Read the rest of this post to learn more about this new way to insert artifact coordinates in a Maven POM using m2eclipse.</p>

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

<h2>Inserting a dependency using auto-complete</h2>

<p>In the POM shown in the previous figure, I have invoked completion within the &lt;project&gt; element. I haven&#8217;t started typing anything prior to invoking auto-complete and, as a result, m2eclipse shows me some extra insertion options: &#8220;Insert dependency&#8221;, &#8220;Insert plugin&#8221;, and &#8220;Insert reference to parent POM&#8221;.  In this particular example, I&#8217;m inserting a parent element.  Since I have no parent defined in this project, m2eclipse gives me the option to &#8220;Insert reference to parent POM&#8221; in this auto-complete menu. As a courtesy we will use the current groupId as the initial search term as it is likely that your parent shares the same groupId and we want save you some typing.</p>

<p>The dependency and plugin insertion proposals appear in multiple contexts. Here it&#8217;s &lt;project&gt;, but you will encounter them in &lt;depedencyManagement&gt;, &lt;pluginManagement&gt;, &lt;build&gt;, &lt;dependencies&gt;, and so on. If we are in &lt;project&gt; xml element, we will either generate the &lt;build&gt;/&lt;plugins&gt; elements as well (at the chosen location), or if you already have your &lt;build&gt;/&lt;plugins&gt; subelements defined, we will append the plugin definition there.</p>

<h2>Support for managed versions</h2>

<p>Child projects can inherit a set of default versions for both plugins and dependencies from parent projects that make use of dependencyManagement and pluginManagement elements. We call the versions defined in these elements &#8220;managed versions&#8221; &#8211; they allow you to specify a global version for any dependency or plugin at the top-level of a large multi-module project. If your dependency/plugin inherits managed versions (in parent POM for example) <em>and</em> you pick the managed version in the selection, we will omit the version element in the child POM.</p>

<p>Let&#8217;s take a look at the Selection dialog now, because we made it easier for you to spot and pick the managed versions of your artifacts as well.</p>

<p><img class="aligncenter size-full wp-image-6863" style="border: 1px solid black;" title="select" src="http://www.sonatype.com/people/wp-content/uploads/2011/01/select.png" alt="" width="355" height="434" /></p>

<p>We&#8217;ve reduced the amount of information shown, so for each dependency/plugin you only get to see the version, type and classifier If you want to see more details, like size or date of creation, just select the appropriate tree in the node.</p>

<p>As you can see the ant-antlr artifacts appear with the lock icon overlay and a decorator text. Both of these attempt to hint that this artifact is being managed in the current effective pom. <em>Note: effective pom is only calculated when the pom file is saved. So any unsaved changes will not be taken into account. </em></p>

<p>To make it really easy for you to pick the managed artifact, the top node (ant ant-antlr) represents the managed version in this case (otherwise it&#8217;s the latest version). So you don&#8217;t have to drill down to the list of version to select the managed one. Just go with the artifact&#8217;s top node.</p>

<p>If you find any issues with this feature or have a great idea for improvement, please don&#8217;t hesitate to file an issue in the <a href="https://bugs.eclipse.org/bugs/enter_bug.cgi?product=m2e&amp;component=editors" target="_blank">eclipse.org bugzilla</a>.   We look forward to your feedback.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2011/01/inserting-artifacts-in-the-m2eclipse-pom-editor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven How-To: Merging Plugin Configuration in Complex Projects</title>
		<link>http://blog.sonatype.com/people/2011/01/maven-how-to-merging-plugin-configuration-in-complex-projects/</link>
		<comments>http://blog.sonatype.com/people/2011/01/maven-how-to-merging-plugin-configuration-in-complex-projects/#comments</comments>
		<pubDate>Wed, 12 Jan 2011 15:00:02 +0000</pubDate>
		<dc:creator>Bentmann Benjamin</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[pom]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=6852</guid>
		<description><![CDATA[In projects with many parent POMs, profiles, and plugin management sections, one can easily end up in a situation where the effective configuration for a plugin is the result of merging many configuration blocks from the various POM sources together. Not knowing the details of this merge process naturally leads to some confusion about why [...]]]></description>
				<content:encoded><![CDATA[<p>In projects with many parent POMs, profiles, and plugin management sections, one can easily end up in a situation where the effective configuration for a plugin is the result of merging many configuration blocks from the various POM sources together.</p>

<p>Not knowing the details of this merge process naturally leads to some confusion about why an effective configuration looks the way it looks, or why changes to some parent POM&#8217;s configuration don&#8217;t have the desired effects in child POMs.</p>

<p>This post attempts to shed some light on this confusion, and provides you with a sense of how Maven merges plugin configuration from multiple sources.   This post uses attributes which are available in Maven 3.0.2.</p>

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

<h2>The Simplest Case: Merging Parent and Child POMs</h2>

<p>As a concrete example, let&#8217;s assume we have a parent POM with the following plugin configuration:</p>

<p><script src="https://gist.github.com/777699.js?file=Plugin%20Configuration%20Example"></script> Let&#8217;s further assume we have a child POM that inherits from the above parent and that specifies the following configuration for the same plugin:  <script src="https://gist.github.com/777703.js?file=Plugin%20Configuration%20Example%20%232"></script></p>

<p>Now, as an invocation of <tt>mvn help:effective-pom</tt> will show you, the effective plugin configuration for the child project will be:</p>

<p><script src="https://gist.github.com/777706.js?file=plugin-config-merge.xml"></script> This result demonstrates the default merge behavior. The configuration elements are recursively merged based on the element name, and elements from the parent POM are only added to the result when the child POM does not contain an equally named element.  Let me stress that merging of plugin configuration is purely an operation on the XML DOM tree. In particular, the merge process has no knowledge of the actual data structures in the plugin that will be configured nor their semantics. In other words, configuration values are generally not considered as merge keys when combining child and parent elements, only the name of the configuration elements is used to identify conflicting elements that need to be merged.</p>

<h2>Controlling the Merge Process with combine.children and combine.self</h2>

<p>Sometimes the default merge behavior doesn&#8217;t produce the intended configuration. In this case, one can use two attributes on the child configuration to adjust the behavior as shown in the next child POM:
<script src="https://gist.github.com/777709.js?file=controlling-merge-with-hints.xml"></script></p>

<p>Assuming the above child POM still inherits from the previously sketched parent POM, one would now get the following effective configuration:</p>

<script src="https://gist.github.com/777710.js?file=merge-hints-results.xml"></script>

<p>As you can see here, usage of <tt>combine.children="append"</tt> results in the concatenation of parent and child elements, in that order. The attribute <tt>combine.self="override"</tt> on the other hand completely suppresses parent configuration to be inherited. That said, it&#8217;s senseless to specify both <tt>combine.self="override"</tt> and <tt>combine.children="append"</tt> for a configuration element, the former directive takes precedence.</p>

<p>Note that these attributes only apply to the configuration element they are declared on, and are not propagated to nested elements. That is if the <tt>&lt;item&gt;</tt> element from our last child POM would be a complex structure instead of a mere string, its sub elements would still be subject to the default merge strategy.</p>

<p>The <tt>combine.*</tt> attributes are however inherited along a hierarchy of POMs. So some care must be taken when adding those attributes to a configuration snippet in a parent POM as this might affect child or grand-child POMs unless those explicitly override the attributes themselves.</p>

<p>Last but not least, please note that the attributes described here to control merging only apply to plugin configuration. You cannot use these attributes on other elements of the POM.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2011/01/maven-how-to-merging-plugin-configuration-in-complex-projects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enroll today for Maven 201: Development Infrastructure Design</title>
		<link>http://blog.sonatype.com/people/2011/01/enroll-today-for-maven-201-development-infrastructure-design/</link>
		<comments>http://blog.sonatype.com/people/2011/01/enroll-today-for-maven-201-development-infrastructure-design/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 15:00:00 +0000</pubDate>
		<dc:creator>hloney</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[Sonatype]]></category>
		<category><![CDATA[pom]]></category>
		<category><![CDATA[Sonatype training]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=6895</guid>
		<description><![CDATA[Sonatype Training You&#8217;ve completed Maven 101, learned about the Maven lifecycle, Maven plugins, goals and projects, all about the contents of the Project Object Model (POM) &#8211; so what&#8217;s next? For those wanting to dive even deeper into Maven, Sonatype is offering an online training course, Maven 201: Development Infrastructure Design. Maven 201 covers advanced [...]]]></description>
				<content:encoded><![CDATA[<!--dzoneZ=none-->

<h4>Sonatype Training</h4>

<p>You&#8217;ve completed Maven 101, learned about the Maven lifecycle, Maven plugins, goals and projects, all about the contents of the Project Object Model (POM) &#8211; so what&#8217;s next?</p>

<p>For those wanting to dive even deeper into Maven, Sonatype is offering an online training course, <a href="http://www.sonatype.com/mvn---201-development-infrastructure-design.html" target="_blank">Maven 201: Development Infrastructure Design</a>.</p>

<p>Maven 201 covers advanced topics such as:</p>

<ul>
    <li>Advanced multimodule project architecture</li>
    <li>Enforcing standards with the Enforcer plugin</li>
    <li>Installing and configuring a repository manager</li>
    <li>Installing and configuring a continuous integration server</li>
</ul>

<p>At the end of this training course, you will have advanced familiarity with the structure of a Maven POM and a Maven multi-module project.</p>

<h4>Next training course:</h4>

<ul>
    <li> MVN-201</li>
    <li>January 20 &amp; 21, 2011</li>
    <li>11:00 am &#8211; 4:00 pm EST (GMT &#8211; 05:00)</li>
    <li><strong><a href="http://store.sonatype.com/training/mvn-201-development-infrastructure-design" target="_blank">Enroll today</a></strong></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2011/01/enroll-today-for-maven-201-development-infrastructure-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Future of Maven</title>
		<link>http://blog.sonatype.com/people/2010/03/the-future-of-maven/</link>
		<comments>http://blog.sonatype.com/people/2010/03/the-future-of-maven/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 14:55:49 +0000</pubDate>
		<dc:creator>hloney</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[m2eclipse]]></category>
		<category><![CDATA[Maven 3]]></category>
		<category><![CDATA[Nexus]]></category>
		<category><![CDATA[Polyglot Maven]]></category>
		<category><![CDATA[pom]]></category>
		<category><![CDATA[Sonatype]]></category>
		<category><![CDATA[Tycho]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=4736</guid>
		<description><![CDATA[JAXenter talked to Sonatype&#8217;s Jason van Zyl about the future of Maven, and what users can expect when migrating from Maven 2 to Maven 3.  In this interview, van Zyl and Sonatype&#8217;s Brian Fox outline Maven 3, it&#8217;s backward compatibility with Maven 2, the introduction of POM mixins, and repository management with Nexus. The primary [...]]]></description>
				<content:encoded><![CDATA[<p><!--dzoneZ=none--><a href="http://jaxenter.com/" target="_blank"><img class="alignright size-full wp-image-1488" title="maven" src="http://www.sonatype.com/people/wp-content/uploads/2009/01/maven.png" alt="" width="180" height="77" />JAXenter</a> talked to Sonatype&#8217;s Jason van Zyl about the future of Maven, and what users can expect when migrating from Maven 2 to Maven 3.  In this interview, van Zyl and Sonatype&#8217;s Brian Fox outline Maven 3, it&#8217;s backward compatibility with Maven 2, the introduction of POM mixins, and repository management with Nexus.</p>

<blockquote>The primary goal is a way forward for all Maven users, efficient  embedding, increased performance, synchronizing the Maven 3.0 code base  with m2eclipse, and adding extension points for tools like Tycho, <a href="http://polyglot.sonatype.org/" target="_blank">Polyglot Maven</a>, and the <a href="http://shell.sonatype.org/" target="_blank">Maven Shell</a>.</blockquote>

<p><a href="http://jaxenter.com/maven-3-0-the-future-of-maven-10580.html" target="_blank">To read the full JAXenter interview, click here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2010/03/the-future-of-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>From Plexus to Guice (#2): The Guice/Plexus Bridge and Custom Bean Injection</title>
		<link>http://blog.sonatype.com/people/2010/01/from-plexus-to-guice-2-the-guiceplexus-bridge-and-custom-bean-injection/</link>
		<comments>http://blog.sonatype.com/people/2010/01/from-plexus-to-guice-2-the-guiceplexus-bridge-and-custom-bean-injection/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 08:00:05 +0000</pubDate>
		<dc:creator>Stuart McCulloch</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Sonatype]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[pom]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=3947</guid>
		<description><![CDATA[In the next few articles of the &#8220;Plexus to Guice&#8221; series I will look at the modular design of our replacement Plexus container and show how you can configure a POB (Plain Old Bean) from Guice with a simple code example. In the first article of this series, Jason discussed the need to move to [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.sonatype.com/people/wp-content/uploads/2010/01/from-plexus-to-guice1.png"><img class="alignright size-full wp-image-4024" title="from-plexus-to-guice" src="http://www.sonatype.com/people/wp-content/uploads/2010/01/from-plexus-to-guice1.png" alt="" width="250" height="62" /></a>In the next few articles of the &#8220;Plexus to Guice&#8221; series I will look at the modular design of our replacement Plexus container and show how you can configure a POB (Plain Old Bean) from Guice with a simple code example.   In the <a href="http://www.sonatype.com/people/2010/01/from-plexus-to-guice-1-why-guice/">first article</a> of this series, Jason discussed the need to move to a more widely used and support container, and the reasons why we chose to standardize on Guice.   As we migrate more Plexus-based applications (such as Maven) to Guice, we still to maintain backward-compatibility for all of the plugins and extensions which were developed using Plexus.  In this post, I start to discuss the scope and initial efforts to create something we&#8217;re calling the Guice/Plexus &#8220;shim&#8221;.   It is a library, a &#8220;container&#8221; that was developed to allow existing Plexus components to use Guice under the hood without any modification. <span id="more-3947"></span></p>

<h3>Scope, Architecture, and Conventions</h3>

<p>Our goal is to create a swap-in replacement for <a href="http://plexus.codehaus.org/plexus-containers/plexus-container-default/">Plexus</a> built on top of <a href="http://code.google.com/p/google-guice/">Guice</a>. Ideally this should be done without changing the core Guice code, but if this is not possible then any fixes or new functionality should be written up and reported on the Guice <a href="http://code.google.com/p/google-guice/issues/list">issues</a> page.   While there is no guarantee that these changes will make it into an official Guice release, improvements that benefit a wider audience should have a better chance of making it into Guice.</p>

<p>Sonatype currently maintains a <a href="http://svn.sonatype.org/spice/trunk/spice-inject/guice-patches">patched build</a> of Guice trunk with the following major patches:</p>

<ul>
    <li><a href="http://code.google.com/p/google-guice/issues/detail?id=436">Provide access to Guice&#8217;s own internal TypeConverters</a></li>
    <li><a href="http://code.google.com/p/google-guice/issues/detail?id=343">BytecodeGen and related AOP / bridge classloader fixes</a></li>
</ul>

<p>This build also contains some experimental changes which have not yet been written up because they are still being tested:</p>

<ul>
    <li>ability to turn off validation error about using @Singleton on an interface instead of an implementation class</li>
    <li>ability to turn off creation of parent JIT bindings when using child injectors (simplified version of <a rel="nofollow" href="http://code.google.com/p/google-guice/issues/detail?id=342">this issue</a>)</li>
</ul>

<h3>Guice/Plexus Integration Module Architecture</h3>

<p>The solution is separated into re-usable, pluggable modules that together provide a replacement for the existing Plexus container. There is also an artifact that combines these modules into a single JAR, as this would make it easier to swap between the old and new container. Each module has a specific responsibility and any dependencies between modules is kept at a minimum.   The following is a list of the components or modules that comprise the Guice/Plexus integration project.</p>

<p><a href="http://www.sonatype.com/people/wp-content/uploads/2010/01/guice-plexus-shim.png"><img class="size-full wp-image-3951 alignright" title="guice-plexus-shim" src="http://www.sonatype.com/people/wp-content/uploads/2010/01/guice-plexus-shim.png" alt="" width="337" height="301" /></a></p>

<dl> <dt>guice-bean-inject</dt> <dd>Extends Guice to support customized injection of named properties (fields and setter methods).</dd> <dt>guice-bean-reflect</dt> <dd>Provides utility methods and support code for reflection, bean properties, and resource scanning.</dd> <dt>guice-plexus-metadata</dt> <dd>Shared metadata interfaces, runtime implementations of Plexus annotations, and collection adapters.</dd> <dt>guice-plexus-scanners</dt> <dd>Annotation and XML scanners that provide metadata about components, requirements, and configuration.</dd> <dt>guice-plexus-converters</dt> <dd>Standard Plexus type conversion rules that can create instances from simple strings and XML markup.</dd> <dt>guice-plexus-locators</dt> <dd>Guice based registry that can locate components of a certain type, optionally ordered by name hints.</dd> <dt>guice-plexus-bindings</dt> <dd>Guice <a rel="nofollow" href="http://google-guice.googlecode.com/svn/trunk/javadoc/com/google/inject/Module.html">module</a> that uses: scanners to find and bind Plexus component beans, converters to turn configurations into instances, and locators to find components based on requirements. This component also provides a simple lifecycle management API.</dd> <dt>guice-plexus-shim</dt> <dd>Creates an <a rel="nofollow" href="http://google-guice.googlecode.com/svn/trunk/javadoc/com/google/inject/Injector.html">injector</a> with Plexus bean support, adds Plexus lifecycles, and provides the container API.</dd> </dl>

<h2>A Brief introduction to Guice and JSR330</h2>

<p><a rel="nofollow" href="http://code.google.com/p/google-guice/">Guice</a> is a <a rel="nofollow" href="http://martinfowler.com/articles/injection.html">Dependency Injection</a> framework that injects constructors, methods, and fields annotated with @Inject. Guice recognizes both the <a rel="nofollow" href="http://atinject.googlecode.com/svn/trunk/javadoc/javax/inject/Inject.html">JSR 330</a> and the original <a rel="nofollow" href="http://google-guice.googlecode.com/svn/trunk/javadoc/com/google/inject/Inject.html">Guice</a> form of this annotation.</p>

<p>Every injection point (constructor, method, or field) has a number of dependencies, each one represented by a key: the type to be injected plus an optional qualifier annotation that lets you choose between different implementations of the same type. For example:</p>

<div>
<div>
<pre>public class Car {
   // Injectable constructor
   @Inject public Car(Engine engine) { ... }

   // Injectable field
   @Inject @Named("Corinthian Leather") private Seat seat;

   // Injectable package-private method
   @Inject void install(Windshield windshield, Trunk trunk) { ... }
}</pre>
</div>
</div>

<p>Has the following injection points and dependency keys:</p>

<div>
<div>
<pre>Constructor      ---&gt; Key[ Engine ]
Field "seat"     ---&gt; Key[ Seat, @Named( "Corinthian Leather" ) ]
Method "install" ---&gt; Key[ Windshield ], Key[ Trunk ]</pre>
</div>
</div>

<p>The Guice injector maintains a set of bindings that map dependency keys to <a rel="nofollow" href="http://atinject.googlecode.com/svn/trunk/javadoc/javax/inject/Provider.html">providers</a> that supply instances of the key type. These providers may use different strategies to supply instances: per-lookup, singleton, per-conversation, even your own custom strategies.</p>

<p>When you configure Guice you are registering bindings from one key to another, or between keys and providers:</p>

<div>
<div>
<pre>// Key[ Seat ] ---&gt; Key[ FoamSeatImpl ]
bind( Seat.class ).to( FoamSeatImpl.class );

// Key[ Seat, @Named( "Corinthian Leather" ) ] ---&gt; Key[ LeatherSeatImpl ]
bind( Seat.class ).annotatedWith( Names.named( "Corinthian Leather" ) ).to( LeatherSeatImpl.class );

// Key[ Engine ] ---&gt; Key[ V8EngineImpl ]
bind( Engine.class ).to( V8EngineImpl.class );

// Key[ V8EngineImpl ] ---&gt; Provider[ V8EngineImpl, "singleton" ]
bind( V8EngineImpl.class ).in( Singleton.class );

// Key[ Windshield ] ---&gt; Provider[ Windshield, "custom" ]
bind( Windshield.class ).toProvider( WindshieldProvider.class );

// Key[ Trunk ] ---&gt; Provider[ TrunkImpl, "constant" ]
bind( Trunk.class ).toInstance( new TrunkImpl() );</pre>
</div>
</div>

<p>The injector can also create certain types of bindings on-demand when no such explicit binding already exists, such as:</p>

<div>
<div>
<pre>// Key[ FoamSeatImpl ] ---&gt; Provider[ FoamSeatImpl , "per-lookup" ]
// Key[ LeatherSeatImpl] ---&gt; Provider[ LeatherSeatImpl, "per-lookup" ]</pre>
</div>
</div>

<div>
<table><colgroup> <col width="24"></col> <col></col> </colgroup>
<tbody>
<tr>
<td valign="top"><img src="https://docs.sonatype.com/images/icons/emoticons/information.gif" border="0" alt="" width="16" height="16" align="absmiddle" /></td>
<td>The <tt>Key[...]</tt> and <tt>Provider[...]</tt> markup is pseudo-code</td>
</tr>
</tbody>
</table>
</div>

<p>So far so good, but what if you have classes that don&#8217;t mark dependencies with <tt>@Inject</tt>? What if they&#8217;re identified in XML or marked with custom annotations like <tt>@Requirement</tt> or <tt>@Configuration</tt>?</p>

<h2>TypeListeners, MembersInjectors, and InjectionListeners</h2>

<p>Since 2.0 Guice has provided a way to supplement the core injection process with your own <a rel="nofollow" href="http://code.google.com/p/google-guice/wiki/CustomInjections">custom injections</a>. Here&#8217;s what you need to do:</p>

<ol>
    <li>Register your custom <a rel="nofollow" href="http://google-guice.googlecode.com/svn/trunk/javadoc/com/google/inject/spi/TypeListener.html">TypeListener</a>, using a <a rel="nofollow" href="http://google-guice.googlecode.com/svn/trunk/javadoc/com/google/inject/matcher/Matcher.html">Matcher</a> to filter the specific types you are interested in, or <a rel="nofollow" href="http://google-guice.googlecode.com/svn/trunk/javadoc/com/google/inject/matcher/Matchers.html">Matchers.any()</a> if you want to process all types</li>
    <li>Guice will call your TypeListener once for each type that matches your chosen matcher, passing you a <a rel="nofollow" href="http://google-guice.googlecode.com/svn/trunk/javadoc/com/google/inject/spi/TypeEncounter.html">TypeEncounter</a></li>
    <li>You can then analyze the type to be injected, prepare any custom injection data, and use the TypeEncounter to register a<a rel="nofollow" href="http://google-guice.googlecode.com/svn/trunk/javadoc/com/google/inject/MembersInjector.html">MembersInjector</a> or <a rel="nofollow" href="http://google-guice.googlecode.com/svn/trunk/javadoc/com/google/inject/spi/InjectionListener.html">InjectionListener</a> for this type. Because the TypeListener is called per-type, and not per-instance, you should try to do as much preparation work here as possible to avoid spending too much time in the MembersInjector or InjectionListener</li>
    <li>Guice will call your MembersInjector once for each instance it injects, after it has performed the core injection. You can then use the data prepared by your TypeListener to perform any custom injection</li>
    <li>Finally Guice will call your InjectionListener once for each instance it injects, after all injections are complete. This is where you can hook in management code, such as start and stop life-cycle support</li>
</ol>

<p><a href="http://www.sonatype.com/people/wp-content/uploads/2010/01/custom-injection.png"><img class="aligncenter size-full wp-image-4032" title="custom-injection" src="http://www.sonatype.com/people/wp-content/uploads/2010/01/custom-injection.png" alt="" width="349" height="301" /></a></p>

<p>You&#8217;ll notice that Guice does not dictate how each type should be scanned or prepared for custom injection. While Guice does provide utility methods that can tell you which class members are annotated with @Inject, there&#8217;s no general-purpose mechanism to scan class members looking for custom annotations. On the one hand this is good, because it avoids bloating the core JAR with code you might not need. But on the other hand each custom injection client could end up implementing similar scanning code again and again. The recommended approach is to put optional code like this in an extension library that people can use if they need to, rather than keep folding it into the core.</p>

<p>We&#8217;re going to use custom injection to support Plexus components whose dependencies may be annotated or configured in XML. Plexus components are similar to Java beans in that they can have fields or setter methods, so rather than write a custom injector that&#8217;s closely tied to Plexus let&#8217;s see if we can develop an extension library for &#8220;beans&#8221; in general. That way we can build support for Plexus on top of it, and allow people to re-use it for other bean-style injections.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2010/01/from-plexus-to-guice-2-the-guiceplexus-bridge-and-custom-bean-injection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
