<?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>Shizzle &#187; error</title>
	<atom:link href="http://lenni.info/blog/tag/error/feed/" rel="self" type="application/rss+xml" />
	<link>http://lenni.info/blog</link>
	<description>My little notebook</description>
	<lastBuildDate>Sun, 29 Jan 2012 20:47:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Mavens&#8217;s &#8220;The artifact has no valid ranges&#8221;</title>
		<link>http://lenni.info/blog/2009/10/mavenss-the-artifact-has-no-valid-ranges/</link>
		<comments>http://lenni.info/blog/2009/10/mavenss-the-artifact-has-no-valid-ranges/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 07:10:05 +0000</pubDate>
		<dc:creator>Leonard</dc:creator>
				<category><![CDATA[Mixed]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://lenni.info/blog/?p=189</guid>
		<description><![CDATA[I have just learned to use the really great Java build and project management tool Maven. It makes managing large projects with dozens of components a lot easier and its build configuration is simpler and less imperative compared to Ant, since it relies a lot on convention over configuration. Basically, Maven knows that pretty much [...]]]></description>
			<content:encoded><![CDATA[<p>I have just learned to use the really great Java build and project management tool <a href="http://maven.apache.org/">Maven</a>. It makes managing large projects with dozens of components a lot easier and its build configuration is simpler and less imperative compared to Ant, since it relies a lot on convention over configuration. Basically, Maven knows that pretty much every project needs to be</p>
<ul>
<li>compiled</li>
<li>JavaDoc&#8217;d</li>
<li>unit tested</li>
</ul>
<p>These things don&#8217;t need to be declared and are automatically done by Maven. Maven&#8217;s great advantage over Ant is it&#8217;s ability to handle the dependencies of your project, ie. the old &#8220;Hunt the JAR&#8221; game is a thing of the past as Maven will simply download whatever libraries or frameworks you will need. Most of the time your build will run smoothly and Maven will spit out a nice JAR or WAR without problems.</p>
<h3>The curious error message</h3>
<p>However, if there are build errors they tend to be on the cryptic side. &#8220;The artifact has no valid ranges&#8221; is one of those. Basically it means that you <em>do have</em> a valid range, however you have defined two (or more) <em>different version ranges of an artifact</em> in a fixed way. Most likely you haven&#8217;t defined those dependencies in the same project but through a transitive dependency.</p>
<p>Let&#8217;s have an example. Your project <em>my-app</em>, depends on an artifact <em>super-framework</em> at version 1.0, and only 1.0, nothing else. <em>my-app</em> also depends on another of your apps called<em> my-app2</em>. <em>my-app2</em> has a dependency on <em>super-framework</em> but only for versions 0.5 to 0.9. This means that you have incompatible version ranges and you need to resolve this. You will have to edit <em>my-app</em> or <em>my-app2</em> and change their version ranges for <em>super-framework</em>.</p>
<p>This took me a little while to figure out myself since the error kinda suggests to look in the wrong place. The range is perfectly valid, it&#8217;s just that there is too many of them.</p>
<h3>Debugging this message</h3>
<p>That is a little tricky. You can try running Maven with the -X flag, which will show a running log of how the version is chosen. Also, sometimes the Maven plugin for Eclipse can give you some clues, but sometimes it is way off.</p>
<p>One word of advice though, it seems to matter in which order you include your dependencies in the the POM file. So, if you include a dependency on</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">super-framework [0.5,1.5)</pre></div></div>

<p>it will fetch the latest available version, say 1.1.</p>
<p>If you then have a transitive dependency further down that includes</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">super-framework [0.5, 1.0)</pre></div></div>

<p>Maven will generate this misleading error, since it will not select anything other than the 1.1 it already has, even though it could just select 0.9 without producing a version conflict. If you swap the order, weirdly, it works.</p>
]]></content:encoded>
			<wfw:commentRss>http://lenni.info/blog/2009/10/mavenss-the-artifact-has-no-valid-ranges/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

