<?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; Mercury</title>
	<atom:link href="http://blog.sonatype.com/people/tag/mercury-maven/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>Maven Virtual Versions: Let&#039;s Fix this Mess!</title>
		<link>http://blog.sonatype.com/people/2009/03/maven-virtual-versions-lets-fix-this-mess/</link>
		<comments>http://blog.sonatype.com/people/2009/03/maven-virtual-versions-lets-fix-this-mess/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 18:35:04 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[Mercury]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=1767</guid>
		<description><![CDATA[Maven introduced a very useful idea &#8211; &#8220;virtual&#8221; versions: SNAPSHOT, LATEST, RELEASE. While this is an interesting and powerful feature, I&#8217;ve found that people still don&#8217;t have a firm grasp of how virtual version work and of some of the problems with SNAPSHOT versions. Depending on how you use and/or understand it, this feature can [...]]]></description>
				<content:encoded><![CDATA[<p><img src="http://www.sonatype.com/people/wp-content/uploads/2009/01/maven.png" alt="maven" title="maven" width="180" height="77" class="alignright size-full wp-image-1488" />Maven introduced a very useful idea &#8211; &#8220;virtual&#8221; versions: SNAPSHOT, LATEST, RELEASE.    While this is an interesting and powerful feature, I&#8217;ve found that people still don&#8217;t have a firm grasp of how virtual version work and of some of the problems with SNAPSHOT versions.  Depending on how you use and/or understand it, this feature can cut both ways.   In this post, I take a closer look at Maven&#8217;s Virtual Versions and try to provide some clarity and definition.
<span id="more-1767"></span>
In theory, any dependency can specify a virtual version:</p>

<ul>
<li>Modifier  <strong>SNAPSHOT</strong> is a modifier for a &#8220;base&#8221; version. If you specify <em>1.0-SNAPSHOT</em>, this translates to &#8220;give me the latest development version for the base 1.0&#8243;.    The assumption behind the SNAPSHOT modifier is that developers are continuously pumping out version after version in order to get to <em>1.0</em>.   A development team is constantly and repeatedly deploying snapshot into repositories, and others can use them without requesting the exact version.</li>
<li>Version name  <strong>LATEST</strong>.  This is used without a <em>base</em> version and simply means &#8211; find and give me the latest possible version of an artifact be it a SNAPSHOT or a RELEASE.</li>
<li>Version name  <strong>RELEASE</strong> . Same as <strong>LATEST</strong>, but excludes any <strong>SNAPSHOT</strong>  dependencies.</li>
</ul>

<p>The last two are true virtual versions as there is no POM with such version set.  In Maven 2, virtual versions are only used by plugin dependencies, <strong>Mercury</strong> treats them as first class citizens and can process virtual versions anywhere in artifact metadata (with the exception of version range definitions).</p>

<p>SNAPSHOT is a much more convoluted virtual version, and there are a lot of problems and contradictions involved in the resolution of SNAPSHOT dependencies:</p>

<p>The local repository could house both timestamped snapshot binaries and -SNAPSHOT binaries, like  mercury-artifact-1.0-alpha-6-20090305.234653-4.jar and mercury-artifact-1.0-alpha-6-SNAPSHOT.jar. <strong>Let&#8217;s call them timestamped snapshots (TS) and non-timestamped snapshots (SN) respectively</strong> .   While the install plugin does create non-timestamped (SN) binaries, the deploy plugin only creates timestamped snapshots (TS) binaries in the remote repopository.  Remote repositories usually contain only timestamped (TS) snapshots, but I saw several cases where people copied the contents of a local repository to a server and hoped to use it as a remote repository.</p>

<p>The file&#8217;s last modification date on timestamped snapshot (TS ) could be before or after the non-timestamped snapshot (SN), if one exists. And it&#8217;s hard to select a correct version based on either name or modification date.</p>

<p>All these different options prevent consistent processing of virtual versions by repository management code. While LATEST and RELEASE are more or less well defined and allow formal processing, SNAPSHOT leaves a lot to wish for. The above listed scenario&#8217;s don&#8217;t allow a consistent treatment of snapshots. Take for example Mercury &#8211; if it uses a <em>select non-timestamped (SN) artifacts if they exist</em> strategy, there is a good chance that the non-timestamped artifact isn&#8217;t as recent as the timestamped artifact &#8211; leading to possible compilation errors.   On the other hand, if Mercury tries to avoid this situation by looking at file timestamps, one bad file date could wreak havoc.</p>

<p>To summarize &#8211; there is no &#8220;right&#8221; solution, as each approach could be broken easily by primitive and often inevitable repository modifications.  By removing these literal &#8220;SNAPSHOT&#8221; files and requiring all snapshots to be timestamped, we can make the SNAPSHOT virtual version as consistent and reliable as the RELEASE and LATEST virtual version.   Mercury, tries to be as backward-compatible as possible, recreating the already established algorithm for resolving SNAPSHOT dependencies.</p>

<p>The real solution, the way to fix this mess, is to get rid of literal &#8220;SNAPSHOT&#8221; files in the repository altogether.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2009/03/maven-virtual-versions-lets-fix-this-mess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mercury Ant tasks &#8211; HowTo</title>
		<link>http://blog.sonatype.com/people/2008/12/mercury-ant-tasks-howto/</link>
		<comments>http://blog.sonatype.com/people/2008/12/mercury-ant-tasks-howto/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 01:18:04 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[m2eclipse]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Mercury]]></category>

		<guid isPermaLink="false">http://blogs.sonatype.com/people/?p=1065</guid>
		<description><![CDATA[mercury-ant-tasks is an Ant wrapper for Mercury functionality, that provides a lot of Mercury functionality inside ant scripts. Please check this posting first. It contains the latest information on the subject. &#60;br/> &#60;br/> What exactly is provided: Configuration named authentication elements to be used by repository or proxy authentication supports both name/password or certificate pointer [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright size-thumbnail wp-image-995" title="repo-conservation" src="http://blogs.sonatype.com/people/wp-content/uploads/2008/12/mercury-logo.png" alt="Mercury logo" width="150" height="90" />mercury-ant-tasks is an Ant wrapper for Mercury functionality, that provides a lot of Mercury functionality inside ant scripts.
<span id="more-1065"></span></p>

<hr />

<h2>Please check <a href="http://people.apache.org/~ogusakov/sites/mercury-ant/mercury-ant-tasks/howto.html">this posting</a> first. It contains the latest information on the subject.</h2>

<p>&lt;br/>
&lt;br/></p>

<p>What exactly is provided:</p>

<ul>
    <li><strong>Configuration</strong>
<ul>
    <li>named authentication elements to be used by repository or proxy authentication</li>
    <li>supports both name/password or certificate pointer (file or URL) plus optional password</li>
    <li>named repository configurations</li>
    <li>local repositories (not limited to one)</li>
    <li>remote repositories</li>
    <li>stream verification per repository &#8211; separate for reading and writing</li>
    <li>currently supported SHA-1 and PGP (.asc)</li>
</ul>
</li>
    <li><strong>named dependency sets</strong>
<ul>
    <li>lists dependencies and optionally &#8211; their Maven scopes</li>
    <li>standardized on a one-string naming convention</li>
    <li>supports OSGi-syntax version ranges</li>
</ul>
</li>
    <li><strong>ant path creation/alteration</strong>
<ul>
    <li>a task that either creates a new ant path or adds to existing one</li>
    <li>optionally allows to specify Maven-like scope for the path resolution</li>
</ul>
</li>
    <li><strong>repository writes</strong>
<ul>
    <li>allows to write named files into repositories</li>
    <li>optional classifiers, types</li>
    <li>signature generation is configured per repository</li>
    <li>SHA1, PGP</li>
</ul>
</li>
</ul>

<hr />

<h3>Where to get mercury-ant-tasks?</h3>

<p>All the development releases will be deployed to <a href="http://people.apache.org/~ogusakov/repos/test/org/apache/maven/mercury/mercury-ant-tasks/1.0-alpha-1-SNAPSHOT/">this site</a>; grab the latest snapshot and:</p>

<ul>
    <li>put it into ${user.home}/.ant/lib</li>
    <li>if you plan to use PGP signatures &#8211; also put there bcpg-jdk15-140.jar and bcprov-jdk15-140.jar from <a href="http://repo1.maven.org/maven2/bouncycastle/">this central repository location</a></li>
    <li>if interested &#8211; my test <a href="http://people.apache.org/~ogusakov/repos/test/org/apache/maven/mercury/mercury-ant-tasks/1.0-alpha-1-SNAPSHOT/build.xml">build.xml</a> contains all the unit test scripts</li>
</ul>

<hr />

<h3> mercury-ant-tasks howto-by-example</h3>

<p>&nbsp;&nbsp;</p>

<p>This snippet shows how to define mercury namespace in the ant project markup</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;mercury-ant-test&quot;</span> <span style="color: #000066;">default</span>=<span style="color: #ff0000;">&quot;compile&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">xmlns:merc</span>=<span style="color: #ff0000;">&quot;antlib:org.apache.maven.mercury.ant.tasks&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>&nbsp;&nbsp;</p>

<p>This snippet shows how to define two repositories &#8211; one remote, one local. <strong>You don&#8217;t have to always define a local repository</strong>, but in this case binaries would reside in temp. location and will be reloaded from the remote on each invocation of the merc:resolve task</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;merc:config</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;conf&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merc:repo</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;localRepo&quot;</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;/maven.repo&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merc:repo</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;central&quot;</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;http://repo1.maven.org/maven2&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/merc:config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>


<p>&nbsp;&nbsp;</p>

<p>This snippet shows how to define authenticated repository and hide the password in the external file, so that each OS user can have their own credentials</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;property</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;~/.secret/secret.properties&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;merc:config</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;conf&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merc:auth</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;repo-auth&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;${repo.user}&quot;</span> <span style="color: #000066;">pass</span>=<span style="color: #ff0000;">&quot;${repo.pass}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merc:repo</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;localRepo&quot;</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;/maven.repo&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merc:repo</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;central&quot;</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;http://repo1.maven.org/maven2&quot;</span></span>
<span style="color: #009900;">             <span style="color: #000066;">authid</span>=<span style="color: #ff0000;">&quot;repo-auth&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/merc:config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>


<p>&nbsp;&nbsp;</p>

<p>This snippet shows how to configure a repository for PGP signature generation and checking; here secret keyring password is also kept in external file. Key ID always is a 16-digit hex number &#8211; use <a href="http://www.gnupg.org/">GnuPG</a> GUI to look it up (and also generate/manipulate your keys). The verifier will accept any key from pubring.gpg for the signature</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;property</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;~/.secret/secret.properties&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;merc:config</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;conf&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;merc:auth</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;repo-auth&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;${repo.user}&quot;</span> <span style="color: #000066;">pass</span>=<span style="color: #ff0000;">&quot;${repo.pass}&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;merc:repo</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;localRepo&quot;</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;/maven.repo&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;merc:repo</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;central&quot;</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;http://repo1.maven.org/maven2&quot;</span></span>
<span style="color: #009900;">                    <span style="color: #000066;">authid</span>=<span style="color: #ff0000;">&quot;repo-auth&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;merc:verifywrite</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;pgp&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;keyring&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/home/me/pgp/secring.gpg&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;pass&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${secret.keyring.pass}&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;key&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;0EDB5D91141BC4F2&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/merc:verifywrite<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merc:verifyread</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;pgp&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;keyring&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/home/me/pgp/pubring.gpg&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/merc:verifyread<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/merc:repo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/merc:config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>


<p>&nbsp;&nbsp;</p>

<p>This snippet shows how to define authenticated repository and hide the password in the external file, so that each OS user can have their own credentials</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;property</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;~/.secret/secret.properties&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merc:config</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;conf&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merc:auth</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;repo-auth&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;${repo.user}&quot;</span> <span style="color: #000066;">pass</span>=<span style="color: #ff0000;">&quot;${repo.pass}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merc:repo</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;localRepo&quot;</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;/maven.repo&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merc:repo</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;central&quot;</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;http://repo1.maven.org/maven2&quot;</span></span>
<span style="color: #009900;">                    <span style="color: #000066;">authid</span>=<span style="color: #ff0000;">&quot;repo-auth&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/merc:config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>


<p>&nbsp;&nbsp;</p>

<p>This snippet shows how to define a dependency set. Junit will only be added to paths that define scope=&#8221;test&#8221;</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;merc:dep</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;my-libs&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merc:dependency</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;asm:asm:[2.0,3.0)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merc:dependency</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;junit:junit:[4.0.1,):::test&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/merc:dep<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>


<p>&nbsp;&nbsp;</p>

<p>This snippet shows how to resolve a dependency set and add the resulting binaries to &#8220;compile-path&#8221; path. This path will not include JUnit from previous snippet</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;merc:resolve</span> <span style="color: #000066;">pathid</span>=<span style="color: #ff0000;">&quot;compile-path&quot;</span> <span style="color: #000066;">depid</span>=<span style="color: #ff0000;">&quot;my-libs&quot;</span> <span style="color: #000066;">configid</span>=<span style="color: #ff0000;">&quot;conf&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;javac</span> <span style="color: #000066;">srcdir</span>=<span style="color: #ff0000;">&quot;${src}&quot;</span> <span style="color: #000066;">destdir</span>=<span style="color: #ff0000;">&quot;${target}&quot;</span> <span style="color: #000066;">classpathref</span>=<span style="color: #ff0000;">&quot;compile-path&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>


<p>&nbsp;&nbsp;</p>

<p>This snippet shows how to resolve a dependency set in test scope and add the resulting binaries to &#8220;test-compile-path&#8221; path. This path will have JUnit</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;merc:resolve</span> <span style="color: #000066;">pathid</span>=<span style="color: #ff0000;">&quot;test-compile-path&quot;</span></span>
<span style="color: #009900;">                      <span style="color: #000066;">depid</span>=<span style="color: #ff0000;">&quot;my-libs&quot;</span></span>
<span style="color: #009900;">                      <span style="color: #000066;">configid</span>=<span style="color: #ff0000;">&quot;conf&quot;</span></span>
<span style="color: #009900;">                      <span style="color: #000066;">scope</span>=<span style="color: #ff0000;">&quot;test&quot;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>


<p>&nbsp;&nbsp;</p>

<p>This snippet shows how to write a jar file and it&#8217;s sources to a repository</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;merc:write</span> <span style="color: #000066;">repoid</span>=<span style="color: #ff0000;">&quot;remoteRepo&quot;</span></span>
<span style="color: #009900;">                   <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;t:t:1.0&quot;</span></span>
<span style="color: #009900;">                   <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${basedir}/target/t.jar&quot;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merc:write</span> <span style="color: #000066;">repoid</span>=<span style="color: #ff0000;">&quot;remoteRepo&quot;</span></span>
<span style="color: #009900;">                   <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;t:t:1.0:sources&quot;</span></span>
<span style="color: #009900;">                   <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${basedir}/target/t-src.jar&quot;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>


<p>&nbsp;</p>

<hr/>

<p>&nbsp;</p>

<h3>mercury-ant-tasks reference</h3>

<p>Now, let&#8217;s have a closer look at ant mercury markup. To make it available to ant, provide a namespace definition on the project level, for example:
<code>&lt;project name="test" default="compile" xmlns:merc="antlib:org.apache.maven.mercury.ant.tasks"&gt;</code></p>

<p>Everywhere here I mention <em>named</em> &#8211; named configuration, named set. It means named in ant sense: something that has an <em>id</em> attribute value, and then we can reference that particular object (configuration, set, etc) by this value.</p>

<table border="0" style="width: 600px; border: 1px solid black; padding: 5px;">
<tbody style="width: 600px;">
<tr>
<th>Tag</th>
<th>Attribute<br/>(<b>required</b>)</th>
<th>Description</th>
</tr>
<tr bgcolor="#f6f6f6">
<td>merk:config</td>
<td></td>
<td>defines a named configuration, for now it&#8217;s just a set of named repositories and authentications</td>
</tr>
<tr>
<td></td>
<td><b>id</b></td>
<td>the name of this configuration</td>
</tr>
<tr bgcolor="#f6f6f6">
<td>merc:auth</td>
<td></td>
<td>defines a named authentication</td>
</tr>
<tr>
<td></td>
<td><b>id</b></td>
<td>name of this authentication</td>
</tr>
<tr>
<td></td>
<td>user</td>
<td>user name to use in this authentication</td>
</tr>
<tr>
<td></td>
<td>certfile</td>
<td>a pointer to certificate file or URL. Can take a form of just a file pointer, or URL: file:///home/me/certificate. Or regular URL http://my.site.com/certificates/file. <strong>Note:</strong> currently SSL client does not support client certificates</td>
</tr>
<tr>
<td></td>
<td>pass</td>
<td>password to use with either user or certificate</td>
</tr>
<tr bgcolor="#f6f6f6">
<td>merc:repo</td>
<td></td>
<td>defines a named repository that may contain dependencies. <strong>It can only reside inside merc:config element</strong></td>
</tr>
<tr>
<td></td>
<td><b>id</b></td>
<td>defines a unique id for this repository. Use consistent IDs as the are used by cache to speed up access to repository metadata</td>
</tr>
<tr>
<td></td>
<td>type</td>
<td>repository type, used internally to find repository implementation. Default is M2 repository implementations from Mercury <b>(default: &#8220;m2&#8243;)</b></td>
</tr>
<tr>
<td></td>
<td>dir</td>
<td>defines a local repository. Point to the root of the local repository directory</td>
</tr>
<tr>
<td></td>
<td>url</td>
<td>defines a remote repository and contains it&#8217;s URL</td>
</tr>
<tr>
<td></td>
<td>authid</td>
<td>contains a reference to the <em>merc:auth</em> element that defines how to access authenticated repository</td>
</tr>
<tr>
<td></td>
<td>proxyauthid</td>
<td>contains a reference to the <em>merc:auth</em> element that defines how to access authenticated proxy for a repository</td>
</tr>
<tr>
<td></td>
<td>readable</td>
<td>boolean, defines this repository as suitable for reading from it</td>
</tr>
<tr>
<td></td>
<td>writeable</td>
<td>boolean, defines this repository as suitable for writing to it</td>
</tr>
<tr bgcolor="#f6f6f6">
<td>merc:verifyread</td>
<td></td>
<td>defines a read verification configuration.<strong>It can only reside inside merc:repo element</strong></td>
</tr>
<tr>
<td></td>
<td><b>type</b></td>
<td>define the verification algo to use. Supported today are <strong>pgp</strong> and <strong>sha1</strong></td>
</tr>
<tr>
<td></td>
<td>lenient</td>
<td>boolean, if set to true &#8211; verification failure does not stop the repository operation <b>(default: true)</b></td>
</tr>
<tr>
<td></td>
<td>sufficient</td>
<td>boolean, if set to true and there are multiple verificators &#8211; success of this verification stops all others <b>(default: false)</b></td>
</tr>
<tr bgcolor="#f6f6f6">
<td>merc:verifyread</td>
<td></td>
<td>defines a read verification configuration.<strong>It can only reside inside merc:repo element</strong></td>
</tr>
<tr>
<td></td>
<td><b>type</b></td>
<td>define the verification algo to use. Supported today are <strong>pgp</strong> and <strong>sha1</strong></td>
</tr>
<tr>
<td></td>
<td>lenient</td>
<td>boolean, if set to true &#8211; verification failure does not stop the repository operation <b>(default: true)</b></td>
</tr>
<tr>
<td></td>
<td>sufficient</td>
<td>boolean, if set to true and there are multiple verificators &#8211; success of this verification stops all others <b>(default: false)</b></td>
</tr>
<tr bgcolor="#f6f6f6">
<td>merc:deps</td>
<td></td>
<td>defines a named set of dependencies</td>
</tr>
<tr>
<td></td>
<td><b>id</b></td>
<td>the name of this set</td>
</tr>
<tr bgcolor="#f6f6f6">
<td>merc:dependency</td>
<td></td>
<td>a path element query, that could be resolved by <strong>merc:resolve</strong> task</td>
</tr>
<tr>
<td></td>
<td><b>name</b></td>
<td>a query in the format <strong>groupId:artifactId:versionRange:classifier:type:scope</strong>, required are only the first 3 fields, the rest can be omitted. Examples: <strong>ant:ant:1.7.0</strong> &#8211; search for this dependency, <strong>ant:ant:[1.7.0,)</strong> - search for any version, greater or eq. to 1.7.0, <strong>ant:ant:[1.7.0,)::test</strong> - search for these version and resolve them in the test scope (see merc:resolve), <strong>ant:ant:[1.7.0,1.7.1]</strong> &#8211; search for ant versions between 1.7.0 and 1.7.1 inclusive, <strong>my.apps:app:1.1::zip</strong> &#8211; find and store locally my.app/app/app-1.1.zip</td>
</tr>
<tr bgcolor="#f6f6f6">
<td>merc:resolve</td>
<td></td>
<td>ant path manipulation: create new path or append to the existing path</td>
</tr>
<tr>
<td></td>
<td><b>depid</b></td>

<td>id of the dependency set that should be resolved and added to the path</td>
</tr>
<tr>
<td></td>
<td><b>configid</b></td>
<td>id of the configuration to be used by this resolution</td>
</tr>
<tr>
<td></td>
<td>pathid</td>
<td>id of the newly created path. This path should not have been previously defined</td>
</tr>
<tr>
<td></td>
<td>refpathid</td>
<td>id of the existing path. This path should already exist</td>
</tr>
<tr>
<td></td>
<td>scope</td>
<td>scope, for which this path should be resolved. <b>(default: compile)</b></td>
</tr>
<tr bgcolor="#f6f6f6">
<td>merc:write</td>
<td></td>
<td>this task writes a file to the specified repository under specified name</td>
</tr>
<tr>
<td></td>
<td><b>repoid</b></td>
<td>id of the repository to write this file into</td>
</tr>
<tr>
<td></td>
<td>name</td>
<td>repository name of the atrifact to write to the repository (see dependency name desc., exclude ranges)</td>
</tr>
<tr>
<td></td>
<td>pom</td>
<td>pom file to use instead of the name attribute</td>
</tr>
<tr>
<td></td>
<td><b>file</b></td>
<td>file to be written to the repository</td>
<td></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2008/12/mercury-ant-tasks-howto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dependency Resolution as a Diagram</title>
		<link>http://blog.sonatype.com/people/2008/12/dependency-resolution-as-a-diagram/</link>
		<comments>http://blog.sonatype.com/people/2008/12/dependency-resolution-as-a-diagram/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 00:40:03 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[Mercury]]></category>

		<guid isPermaLink="false">http://blogs.sonatype.com/people/?p=1016</guid>
		<description><![CDATA[They say that one picture is worth a thousand words, so I shut up:]]></description>
				<content:encoded><![CDATA[<p>They say that one picture is worth a thousand words, so I shut up:</p>

<p><img src="http://blogs.sonatype.com/people/wp-content/uploads/2008/12/sat4.png" alt="" title="sat" width="500" height="1480" class="aligncenter size-full wp-image-1028" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2008/12/dependency-resolution-as-a-diagram/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is Mercury?</title>
		<link>http://blog.sonatype.com/people/2008/11/what-is-mercury/</link>
		<comments>http://blog.sonatype.com/people/2008/11/what-is-mercury/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 16:42:31 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[Mercury]]></category>

		<guid isPermaLink="false">http://blogs.sonatype.com/people/?p=1262</guid>
		<description><![CDATA[Mercury is a serious attempt to: Decouple major Maven components, making them available as stand-alone building blocks rather then having Maven as as one big monolith, not usable outside of its environment. Artifact &#8211; clearly separate an Artifact from its metadata. Repository &#8211; convert a repository into active component. It used to give back just [...]]]></description>
				<content:encoded><![CDATA[<p>Mercury is a serious attempt to:</p>

<ul>
<li>Decouple major Maven components, making them available as stand-alone building blocks rather then having Maven as as one big monolith, not usable outside of its environment.</li>
<li><strong>Artifact</strong> &#8211; clearly separate an Artifact from its metadata.</li>
<li><strong>Repository</strong> &#8211; convert a repository into active component. It used to give back just pathOf(), now it accepts GAV collections and gives back either metadata or full blown Artifacts.</li>
<li><strong>Transport</strong> &#8211; an API in development.</li>
<li><strong>DependencyTreeBuilder</strong> main API for dependency graph creation and conflict resolution.</li>
<li>Decouple container, so that these components are just plain pojos.</li>
<li>Introduce <strong>Jetty</strong>-based HTTP/HTTPS and WebDAV transactional transport layer.</li>
<li>Asynchronous downloads and uploads. One of the few successful usages of Java NIO in OSS.</li>
<li>Transactional operations &#8211; all-or-nothing for file sets.</li>
<li>Move integrity control into transport layer, upper level components should not care about these details.</li>
<li>Abstract out metadata cache, provide at least one implementation there.</li>
<li>Integrate these changes back to Maven 3.x to make it even better platform than it is right now (if it is possible to be better <img src='http://blog.sonatype.com/people/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )</li>
</ul>

<p>Currently Mercury can already be used for accessing repositories, and conflict resolution is under testing.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2008/11/what-is-mercury/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mercury event framework design notes</title>
		<link>http://blog.sonatype.com/people/2008/11/mercury-events-framework-design-notes/</link>
		<comments>http://blog.sonatype.com/people/2008/11/mercury-events-framework-design-notes/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 03:27:17 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[Mercury]]></category>

		<guid isPermaLink="false">http://blogs.sonatype.com/people/oleg/?p=71</guid>
		<description><![CDATA[For a long time I&#8217;ve been perplexed by what is going inside Maven, what&#8217;s there under the hood. Later I started learning the code and it gave me some perspective. Then I wrote a chunk of code &#8211; Mercury, but the exact understanding of what is happening inside is still hard to grasp: the code [...]]]></description>
				<content:encoded><![CDATA[<p>For a long time I&#8217;ve been perplexed by what is going inside Maven, what&#8217;s there under the hood. Later I started learning the code and it gave me some perspective. Then I wrote a chunk of code &#8211; Mercury, but the exact understanding of what is happening inside is still hard to grasp: the code base is rather big and logic rather complex for a human mind to follow all the details.</p>

<p>All that, plus the necessity to provide tool integration, led to the idea to introduce an event framework into Mercury. All major processing object implement EventGenerator interface, that allows client code to register MercuryEventListener implementations and unRegister them as well.<span id="more-859"></span></p>

<p><strong>MercuryEvent</strong> in itself has</p>

<ul>
<li>local TZ based start timestamp</li>
<li>long duration in millis</li>
<li>enumeration based type, which is also used for event partitioning</li>
<li>name &#8211; obviously to identify this event</li>
<li>tag to record lightweight information about event</li>
<li>result to record the outcome of the event</li>
<li>Map based payload &#8211; for tool integration to get access to typed objects, event wants to carry to the tool</li>
</ul>

<p>Client code has several options to play with:</p>

<ul>
<li>event listener can declare a BitSet based mask of event types it wants to be notified about</li>
<li>event manager could be configured with a mask of event types it will propagate</li>
<li>there is a system property to define which event types should be propagated by the event manager, if one is created by the client code</li>
</ul>

<p>The event manager itself separates event dispatching from event generator code via a thread pool, so that events are only placed into an event queue in the event generator thread, and then are sent out to listeners in parallel to the main code.</p>

<p>There is also a <strong>DumbListener</strong>, implemented to just peek at the events &#8211; prints them out to system.out or any other output stream.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2008/11/mercury-events-framework-design-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>To Mercury and Beyond</title>
		<link>http://blog.sonatype.com/people/2008/11/to-mercury-and-beyond/</link>
		<comments>http://blog.sonatype.com/people/2008/11/to-mercury-and-beyond/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 21:08:33 +0000</pubDate>
		<dc:creator>shane</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[Mercury]]></category>

		<guid isPermaLink="false">http://blogs.sonatype.com/people/shane/?p=22</guid>
		<description><![CDATA[Last month, I went down to Sonatype&#8217;s offices to meet up with the guys down there. I soon found myself being cornered by a serious looking Oleg, who wanted Maven integration with Mercury ASAP, and who I believed I promised Maven integration two weeks prior. We setup our laptops outside to work on Mercury, in [...]]]></description>
				<content:encoded><![CDATA[<p>Last month, I went down to Sonatype&#8217;s offices to meet up with the guys down there. I soon found myself being cornered by a serious looking Oleg, who wanted Maven integration with Mercury ASAP, and who I believed I promised Maven integration two weeks prior. We setup our laptops outside to work on Mercury, in what later proved to be a mistake as the burning California sun beat down on us.</p>

<p>Oleg needed a version of project builder that didn&#8217;t require a bunch of dependencies from the Maven trunk, as he designed Mercury to be a standalone module, resolving of any type of artifact, not just Maven specific ones. The bulk of the project builder work was already standalone and isolated into maven-shared-model, a component that handles inheritance and interpolation of generic models (including XML ones). So I stripped out some of the interfaces and a few classes from the maven-project component, which had unneeded tie-ins with the rest of Maven core.</p>

<p>Next came the implementation. Mercury has an interface called DependencyProcessor, with the following method that I needed to implement (MavenDependencyProcessor):</p>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">List</span> getDependencies<span style="color: #009900;">&#40;</span>ArtifactBasicMetadata bmd, MetadataReader mdReader<span style="color: #009900;">&#41;</span></pre></div></div>


<p>The point of this method is to build a full project model, including inheritance, interpolation and profiles, returning the list of ArtifactBasicMetadata dependencies of the processed model to Mercury.</p>

<p>The ArtifactBasicMetadata is a simple value class, giving the MavenDependencyProcessor instance information like version, groupId, artifactId of the artifact for which to process the returned dependency list. The MetadataReader allows the MavenDependencyProcessor instance a way to call back into Mercury to get the parent of the project.</p>

<p>Since the project builder uses basic property lists to store all Maven properties, converting from dependencies to ArtifactBasicMetadata couldn&#8217;t be simpler: The core of the conversion is:</p>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">List</span> modelProperties <span style="color: #339933;">=</span> container.<span style="color: #006633;">getProperties</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
ArtifactBasicMetadata metadata <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArtifactBasicMetadata<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> ModelProperty mp <span style="color: #339933;">:</span> modelProperties <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>mp.<span style="color: #006633;">getUri</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>ProjectUri.<span style="color: #006633;">Dependencies</span>.<span style="color: #006633;">Dependency</span>.<span style="color: #006633;">groupId</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       metadata.<span style="color: #006633;">setGroupId</span><span style="color: #009900;">&#40;</span>mp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>mp.<span style="color: #006633;">getUri</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>ProjectUri.<span style="color: #006633;">Dependencies</span>.<span style="color: #006633;">Dependency</span>.<span style="color: #006633;">artifactId</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       metadata.<span style="color: #006633;">setArtifactId</span><span style="color: #009900;">&#40;</span>mp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>  <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>mp.<span style="color: #006633;">getUri</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>ProjectUri.<span style="color: #006633;">Dependencies</span>.<span style="color: #006633;">Dependency</span>.<span style="color: #006633;">version</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       metadata.<span style="color: #006633;">setVersion</span><span style="color: #009900;">&#40;</span>mp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>mp.<span style="color: #006633;">getUri</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>ProjectUri.<span style="color: #006633;">Dependencies</span>.<span style="color: #006633;">Dependency</span>.<span style="color: #006633;">classifier</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       metadata.<span style="color: #006633;">setClassifier</span><span style="color: #009900;">&#40;</span>mp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>mp.<span style="color: #006633;">getUri</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>ProjectUri.<span style="color: #006633;">Dependencies</span>.<span style="color: #006633;">Dependency</span>.<span style="color: #006633;">scope</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       metadata.<span style="color: #006633;">setScope</span><span style="color: #009900;">&#40;</span>mp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>mp.<span style="color: #006633;">getUri</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>ProjectUri.<span style="color: #006633;">Dependencies</span>.<span style="color: #006633;">Dependency</span>.<span style="color: #006633;">type</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       metadata.<span style="color: #006633;">setType</span><span style="color: #009900;">&#40;</span>mp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>mp.<span style="color: #006633;">getUri</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>ProjectUri.<span style="color: #006633;">Dependencies</span>.<span style="color: #006633;">Dependency</span>.<span style="color: #006633;">optional</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       metadata.<span style="color: #006633;">setOptional</span><span style="color: #009900;">&#40;</span>mp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


<p>One problem we did encounter was how to handle passing in system and user properties for interpolation and profile activation to the MavenDependencyProcessor, as these properties are currently passed by the MavenEmbedder to the project builder. This requires that Maven core explicitly initialize the MavenDependencyProcessor, passing in all properties through the MavenDependencyProcessor constructor.</p>

<p>Mercury integration is pretty exciting because it will allow us to hemorrhage a lot of resolving code which we have to use in the core, as well as providing a deterministic resolver. Full Mercury integration is not slated for the Maven-3.0-alpha1 release and will likely be a core focus of the alpha-2 release. Initial integration looks promising, as Mercury is already able to process classpaths and dependencies from POMs.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2008/11/to-mercury-and-beyond/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mercury &#8211; externalized dependencies</title>
		<link>http://blog.sonatype.com/people/2008/10/mercury-externalized-dependencies/</link>
		<comments>http://blog.sonatype.com/people/2008/10/mercury-externalized-dependencies/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 15:35:57 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[Mercury]]></category>

		<guid isPermaLink="false">http://blogs.sonatype.com/people/?p=1258</guid>
		<description><![CDATA[Inspiration In Mercury we made an attempt to bring some contemporary ideas into Maven, make Maven not a monolithic build system, but rather a lego-like construction set that allows users to create systems they need. One set of building blocks in particular &#8211; implementation of the idea that dependencies is a universal commodity, that exists [...]]]></description>
				<content:encoded><![CDATA[<h2>Inspiration</h2>

<p>In Mercury we made an attempt to bring some contemporary ideas into Maven, make Maven not a monolithic build system, but rather a lego-like construction set that allows users to create systems they need. One set of building blocks in particular &#8211; implementation of the idea that dependencies is a universal commodity, that exists outside of Maven world. And operation of resolving conflicts on those dependencies can apply to a broader range of dependencies, not just &lt;dependencies/&gt; tag in the POM file.</p>

<p>For example &#8211; it should be relatively easy to plug in an implementation to read OSGi bundle dependencies. Or read a .properties file with dependencies.</p>

<p>Or &#8211; my favorite &#8211; keep dependencies in a <a href="http://www.jboss.org/drools/" title="Drools home page">Drools</a>-backed DSL file. I will try to create this implementation after we integrate Maven POM dependency reader into Mercury.</p>

<p>How is it done:</p>

<ul>
<li>Dependency trees and manipulated by <strong>DependencyTreeBuilder</strong> object</li>
<li>DependencyTreeBuilder instance is created out of a collection of <strong>Repositories</strong> (to find Artifacts) and and instance of <strong>DependencyProcessor</strong>.</li>
<li>DependencyProcessor abstraction is that externalization component for reading/processing depedencies, making the builder independent of actual dependency information storage</li>
</ul>

<h2>Example code</h2>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">    DependencyTreeBuilder dtb
        <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DependencyTreeBuilder<span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #000066; font-weight: bold;">null</span>, reps, processor <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    MetadataTreeNode root
        <span style="color: #339933;">=</span> dtb.<span style="color: #006633;">buildTree</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> ArtifactBasicMetadata<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;org.apache.maven:maven-core:2.0.9&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">List</span> cp
        <span style="color: #339933;">=</span> dtb.<span style="color: #006633;">resolveConflicts</span><span style="color: #009900;">&#40;</span> ArtifactScopeEnum.<span style="color: #006633;">compile</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<p>This example demonstrates full dependency resolution cycle:</p>

<ul>
<li>full tree is created in <strong>root</strong> variable</li>
<li>compile classpath is stored in variable <strong>cp</strong>.</li>
</ul>

<p>The two initialization steps required:</p>

<ul>
<li>create a collection of repositories in <strong>reps</strong></li>
<li>get an instance of DependencyProcessor into <strong>processor</strong></li>
</ul>

<p>Also interesting &#8211; resulting classpath is a list of artifact metadata objects, not artifact binaries. So in order to actually bring the binaries to local machine, we&#8217;ll need one more call &#8211; to VirtualRepositoryReader, which I will describe it in a separate posting.</p>

<p>What&#8217;s important here is the fact that operation of fetching binaries from remote repositories is separated from building dependency tree as well as from resolving conflicts.  Which means that you can call all of those operations independently to construct a workflow you need for a particular application. All the metadata that was fetched in the process of creating dependency tree is cached by a <strong>RepositoryMetadataCache</strong> component, that complies with repository update policy.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2008/10/mercury-externalized-dependencies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
