<?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; How-To</title>
	<atom:link href="http://blog.sonatype.com/people/category/how-to/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 to publish your Gradle project to the Central Repository</title>
		<link>http://blog.sonatype.com/people/2011/11/how-to-publish-your-gradle-project-to-the-central-repository/</link>
		<comments>http://blog.sonatype.com/people/2011/11/how-to-publish-your-gradle-project-to-the-central-repository/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 15:37:38 +0000</pubDate>
		<dc:creator>Terry Bernstein</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Sonatype]]></category>
		<category><![CDATA[Gradle]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=9514</guid>
		<description><![CDATA[Sonatype makes it easy to add your projects to the Central Repository with a free, public hosting service called OSSRH, that we recently wrote about here.  Many developers have found this a very useful service and easy to use with Apache Maven.  However, if you&#8217;ve started using Gradle, you may have wondered if you could [...]]]></description>
				<content:encoded><![CDATA[<p>Sonatype makes it easy to add your projects to the <a title="Central Repository" href="http://search.maven.org/">Central Repository</a> with a free, public hosting service called OSSRH, that we recently wrote about <a title="Blog on Sonatype OSSRH" href="http://www.sonatype.com/people/2011/10/publishing-your-artifacts-to-the-central-repository/">here</a>.  Many developers have found this a very useful service and easy to use with Apache Maven.  However, if you&#8217;ve started using Gradle, you may have wondered if you could continue using the service.  The answer is absolutely YES.</p>

<p>We were talking about creating a guide for this, but someone in the community beat us to it.  Yennick Trevels published an excellent guide in his blog that you can find <a href="http://jedicoder.blogspot.com/2011/11/automated-gradle-project-deployment-to.html">here</a>.  We highly recommend checking out his post if you want to use Gradle to deploy artifacts to the Central Repository.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2011/11/how-to-publish-your-gradle-project-to-the-central-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Publishing Your Artifacts to the Central Repository</title>
		<link>http://blog.sonatype.com/people/2011/10/publishing-your-artifacts-to-the-central-repository/</link>
		<comments>http://blog.sonatype.com/people/2011/10/publishing-your-artifacts-to-the-central-repository/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 08:03:22 +0000</pubDate>
		<dc:creator>Brian Fox</dc:creator>
				<category><![CDATA[Central]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Sonatype]]></category>
		<category><![CDATA[central]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[repository]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=9136</guid>
		<description><![CDATA[Sonatype makes it easy to add your projects to the Central Repository with a free, public hosting service called OSSRH. We first blogged about this back in 2009, but given the growth in the community, we thought some of you may not have seen that post, so we decided to update it. When you publish [...]]]></description>
				<content:encoded><![CDATA[<p>Sonatype makes it easy to add your projects to the Central Repository with a free, public hosting service called OSSRH.  We first blogged about this back in 2009, but given the growth in the community, we thought some of you may not have seen that post, so we decided to update it.
<span id="more-9136"></span>
<HR>
 When you publish your project&#8217;s artifacts to the Central Repository it will be easy for your users to add a dependency and start using it.  However, getting your project into Central can be a pain if its hosted somewhere like Sourceforge which doesn&#8217;t have a setup for synchronizing to the Central Repository. The old process for publishing your artifacts required several manual steps setup and enable an rsync location&#8230; assuming you can find a location to host your files at all.</p>

<p>At Sonatype, we want to make synchronizing and publishing your artifacts to Central easier and to improve the quality of repository metadata for everyone at the same time.  To facilitate this, we offer a dedicated instance of Sonatype Pro for Nexus at <a href="http://oss.sonatype.org">http://oss.sonatype.org</a> specifically to host the artifacts of open source projects.   In this post, I talk about the process of creating a repository for your open source projects and publishing artifacts so that they will be available from the Central Repository.</p>

<p>This service has been available since 2009 and includes many projects such as <a href="http://plexus.codehaus.org/">Plexus</a>, <a href="http://jetty.mortbay.org/jetty/index.html">Jetty</a>, Google Guice, Spring and <a href="http://ehcache.sourceforge.net">Ehcache</a> (Greg <a href="http://gregluck.com/blog/archives/2009/05/new-ehcache-and-sourceforge-maven-repo-on-oss-sonatype-org/">wrote</a> about his experience with migrating to oss.sonatype.org). We have tooling in place to make it easy for us to process a larger set of requests, so we invite everyone to use this resource. As of October, 2011, we have over 1,500 projects using this repository on a daily basis.</p>

<p>To get the process started, go <a href="https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide">here</a>. We&#8217;ll setup a release and snapshot repository for your project, along with the appropriate configuration to allow you to use the staging features for your releases. If you have an existing repository somewhere, we can migrate that for you too. We&#8217;ll even help you <a href="https://docs.sonatype.org/display/Repository/Uploading+3rd-party+Artifacts+to+Maven+Central">add artifacts</a> to Central that you use, but don&#8217;t necessarily own &#8212; assuming of course that it doesn&#8217;t violate the projects license.</p>

<p>The system allows customizable rules to be run during the staging process, which allows us to automatically check things like valid pgp signatures and correct POM parsing. This will ensure that your users have the best experience possible when using your artifacts, and relieve some of the manual validation on your side &#8212; a win for everyone.</p>

<p>On the technical details, this instance gets its network connection via <a href="http://www.contegix.com">Contegix</a>&#8216;s high availability network, the same one running Central, Codehaus.org and Atlassian.com. <a href="http://www.newrelic.com" target="_blank">New Relic</a> has donated monitoring services to help us monitor and tune this instance of Nexus.  Since OSSRH is hosted on the same infrastructure as the Central Repository, we are able to frequently synchronize the repositories.</p>

<p>Next time you need to add a project to the Central Repository, you&#8217;ll know <a href="https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide">how</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2011/10/publishing-your-artifacts-to-the-central-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Goodbye SVN, Hello Git</title>
		<link>http://blog.sonatype.com/people/2011/04/goodbye-svn-hello-git/</link>
		<comments>http://blog.sonatype.com/people/2011/04/goodbye-svn-hello-git/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 13:00:12 +0000</pubDate>
		<dc:creator>Brian Demers</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Sonatype]]></category>
		<category><![CDATA[GIT]]></category>
		<category><![CDATA[SVN]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=7844</guid>
		<description><![CDATA[We are moving both our public and private source repositories to Git for a few reasons: Git works better for people with slow or lagging connections Branch management is easy Submitting patches via a pull request is easier to deal with than a patch attached to a bug report We started out with SVN mostly [...]]]></description>
				<content:encoded><![CDATA[<p>We are moving both our public and private source repositories to Git for a few reasons:</p>

<ul>
    <li>Git works better for people with slow or lagging connections</li>
    <li>Branch management is easy</li>
    <li>Submitting patches via a pull request is easier to deal with than a patch attached to a bug report</li>
</ul>

<p>We started out with SVN mostly because that was what everyone was used to. A year ago or so, one of our remote developers started using a git-svn mirror to remove some of the latency issues they had with SVN. Someone else put together a ten page wiki on how to <em>easily</em> use a git-svn mirror and push back to the canonical SVN repo. As time went on, interest in git grew and new modules were created in git, instead of our SVN repositories.  Finally there was a push to move everything to git.</p>

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

<p>There were a couple different directory conventions used for our repositories.  Our Nexus SVN repository used the typical project-root/trunk,tags,branches, and git-svn worked nice right out of the box. Our other repositories lumped all modules under the trunk, tags, and branches folder (figure 1).</p>

<p>We decided to give each module its own git repository to better manage tags and branches related to the given module. This made the git import a pain, as you cannot just export tags/* (and tags/module-B-* will not work either), you need to be more selective and configure each tag to pull.</p>

<div id="attachment_8055" class="wp-caption alignnone" style="width: 495px"><a rel="attachment wp-att-8055" href="http://www.sonatype.com/people/2011/04/goodbye-svn-hello-git/spice-svn/"><img class="size-full wp-image-8055 " title="spice-svn" src="http://www.sonatype.com/people/wp-content/uploads/2011/04/spice-svn.png" alt="" width="485" height="679" /></a><p class="wp-caption-text">Figure 1.</p></div>

<!--more-->

<p>In a nut shell you need to:</p>

<p>(1) Create a new git repository.</p>

<p>$ git svn init &#8211;trunk=trunk/project &lt;svn-root&gt; &lt;repo-name&gt;</p>

<p>(2) Configure the specific tags you want to export (we use the Maven release plugin, so the tagging convention is the same)</p>

<p>$ git config &#8211;add svn-remote.svn.tags tags/{module-B-2.1, module-B-2.2}:refs/remotes/tags/*</p>

<p>(3) Fetch everything (for an automated way of generating an authors file see this <a href="http://technicalpickles.com/posts/creating-a-svn-authorsfile-when-migrating-from-subversion-to-git/" target="_blank">blog post</a>)</p>

<p>$ git svn fetch &#8211;authors-file=&lt;svn-authors-file&gt;</p>

<p>(4) Next you need to <a href="https://github.com/nothingmuch/git-svn-abandon" target="_blank">clean up the tags</a> and push.</p>

<p>If you script this, you end up with something like:</p>

<pre lang="bash" style="overflow:scroll;">
#!/bin/bash

CURRENT_PATH=`pwd`

# file based URL for reads
SVN_URL=file:///path/to/repositories/sonatype.org/spice
SVN_REMOTE_URL=https://svn.sonatype.org/spice
SVN_TAGS_DIR=tags
SVN_TAG_PREFIX=$1
SVN_TRUNK_DIR=trunk/${SVN_TAG_PREFIX}
SVN_AUTHORS=/path/to/svn-authors.txt

GIT_REPO_NAME=$1
GITHUB_USER=userid
GITHUB_TOKEN=xxx
GITHUB_TEAM_ID=1234
GITHUB_ORG=sonatype

# this is the magic, get the list of tags that match this project the output format looks like:
# tags/{module-1.0,module-1.2,module-2.1}
GIT_TAG_ARG=${SVN_TAGS_DIR}/\{`svn list ${SVN_URL}/${SVN_TAGS_DIR} | grep ${SVN_TAG_PREFIX} | sed 's_/__' | xargs -I {} echo -n ,{} | sed 's_^,__'`\}

#echo ${GIT_TAG_ARG}

# init git repo
git svn init --trunk=${SVN_TRUNK_DIR} ${SVN_URL} ${SVN_TAG_PREFIX}

#copy authors text to repo
cp ${SVN_AUTHORS} ${SVN_TAG_PREFIX}/.svn-authors.txt

# move to directory
cd ${SVN_TAG_PREFIX}

# make sure we have tags for this project
if [ `svn list ${SVN_URL}/${SVN_TAGS_DIR} | grep ${SVN_TAG_PREFIX} | wc -l` -gt 0 ]; then
  #configure the tags, we only want a subset of the tags, because we lumpped all the tags in a single place.
  git config --add svn-remote.svn.tags ${GIT_TAG_ARG}:refs/remotes/tags/*
fi

#fetch
git svn fetch --authors-file=.svn-authors.txt
# make sure there are no errors before we continue
if [ "$?" -ne "0" ]; then
  echo "Error while fetching, see above"
  exit 1
fi

git update-ref -d master

##########################################################
# fix the tags, from: https://github.com/nothingmuch/git-svn-abandon
##########################################################

# create annotated tags out of svn tags
git for-each-ref --format='%(refname)' refs/remotes/tags/* | while read tag_ref; do
    tag=${tag_ref#refs/remotes/tags/}
    tree=$( git rev-parse "$tag_ref": )

    # find the oldest ancestor for which the tree is the same
    parent_ref="$tag_ref";
    while [ $( git rev-parse --quiet --verify "$parent_ref"^: ) = "$tree" ]; do
        parent_ref="$parent_ref"^
    done
    parent=$( git rev-parse "$parent_ref" );

    # if this ancestor is in trunk then we can just tag it
    # otherwise the tag has diverged from trunk and it's actually more like a
    # branch than a tag
    merge=$( git merge-base "refs/remotes/trunk" $parent );
    if [ "$merge" = "$parent" ]; then
        target_ref=$parent
    else
        echo "tag has diverged: $tag"
        target_ref="$tag_ref"
    fi

    # create an annotated tag based on the last commit in the tag, and delete the "branchy" ref for the tag
    git show -s --pretty='format:%s%n%n%b' "$tag_ref" | \
    perl -ne 'next if /^git-svn-id:/; $s++, next if /^\s*r\d+\@.*:.*\|/; s/^ // if $s; print' | \
    env GIT_COMMITTER_NAME="$(  git show -s --pretty='format:%an' "$tag_ref" )" \
        GIT_COMMITTER_EMAIL="$( git show -s --pretty='format:%ae' "$tag_ref" )" \
        GIT_COMMITTER_DATE="$(  git show -s --pretty='format:%ad' "$tag_ref" )" \
        git tag -a -F - "$tag" "$target_ref"

    git update-ref -d "$tag_ref"
done

# create local branches out of svn branches
git for-each-ref --format='%(refname)' refs/remotes/ | while read branch_ref; do
    branch=${branch_ref#refs/remotes/}
    git branch "$branch" "$branch_ref"
    git update-ref -d "$branch_ref"
done

# remove merged branches
git for-each-ref --format='%(refname)' refs/heads | while read branch; do
    git rev-parse --quiet --verify "$branch" || continue # make sure it still exists
    git symbolic-ref HEAD "$branch"
    git branch -d $( git branch --merged | grep -v '^\*' )
done
##########################################################
# done fixing tags
##########################################################

# we should already be on the master, but lets make sure
git checkout master

##
# Use the Github API to create a repo and add it to the team.
##

#create github repo
curl -F "login=${GITHUB_USER}" -F "token=${GITHUB_TOKEN}" https://github.com/api/v2/json/repos/create -F "name=${GITHUB_ORG}/${GIT_REPO_NAME}" -F "has_issues=false" -F "has_downloads=false" -F "has_wiki=false"  --request POST

#add the dev team to the repo
curl -F "login=${GITHUB_USER}" -F "token=${GITHUB_TOKEN}" -F "name=${GITHUB_ORG}/${GIT_REPO_NAME}" http://github.com/api/v2/json/teams/${GITHUB_TEAM_ID}/repositories

# set the origin
git remote add origin git@github.com:${GITHUB_ORG}/${GIT_REPO_NAME}.git
#push it all
git push --tags origin master

#go back to where we started
cd ${CURRENT_PATH}

# some reminders so we do not forget the manual steps
echo "--${GIT_REPO_NAME}--" &gt;&gt; migrate.out
echo "You should now review the git repo at: https://github.com/${GITHUB_ORG}/${GIT_REPO_NAME} then remove the svn repo with:" &gt;&gt; migrate.out
echo "$ svn rm ${SVN_REMOTE_URL}/${SVN_TRUNK_DIR} -m  \"Moved to github: https://github.com/${GITHUB_ORG}/${GIT_REPO_NAME}\"" &gt;&gt; migrate.out
echo "Do not forget to update the grid: https://grid.sonatype.org/ci/\" to use: git://github.com/${GITHUB_ORG}/${GIT_REPO_NAME}.git &gt;&gt; migrate.out
echo "Add redirect from ${SVN_REMOTE_URL}/${SVN_TRUNK_DIR} to https://github.com/${GITHUB_ORG}/${GIT_REPO_NAME}" &gt;&gt; migrate.out
echo "" &gt;&gt; migrate.out</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2011/04/goodbye-svn-hello-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Nexus Open Source on a Windows Server</title>
		<link>http://blog.sonatype.com/people/2009/12/installing-nexus-open-source-on-a-windows-server/</link>
		<comments>http://blog.sonatype.com/people/2009/12/installing-nexus-open-source-on-a-windows-server/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 21:58:12 +0000</pubDate>
		<dc:creator>Tim O'Brien</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Nexus]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=3543</guid>
		<description><![CDATA[If you are considering Nexus Open Source, here is a quick-start video and PDF handout for installing Nexus on a Windows machine. The process takes about 3 minutes start to finish and can be summarized as &#8220;Download&#8221;, &#8220;Copy&#8221;, &#8220;Run a BAT Script&#8221;, &#8220;Go&#8221;. This PDF covers the same ground as the video for those of [...]]]></description>
				<content:encoded><![CDATA[<p>If you are considering Nexus Open Source, here is a quick-start video and PDF handout for installing Nexus on a Windows machine.     The process takes about 3 minutes start to finish and can be summarized as &#8220;Download&#8221;, &#8220;Copy&#8221;, &#8220;Run a BAT Script&#8221;, &#8220;Go&#8221;.</p>

<p><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/bLskAeXivPg&#038;hl=en_US&#038;fs=1&#038;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/bLskAeXivPg&#038;hl=en_US&#038;fs=1&#038;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></p>

<p>This PDF covers the same ground as the video for those of you who are looking for something simple to print out.</p>

<p><a title="View Quickstart Nexus Open Source on Windows on Scribd" href="http://www.scribd.com/doc/24191660/Quickstart-Nexus-Open-Source-on-Windows" style="margin: 12px auto 6px auto; font-family: Helvetica,Arial,Sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; display: block; text-decoration: underline;">Quickstart Nexus Open Source on Windows</a> <object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="doc_309322902042237" name="doc_309322902042237" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle"    height="500" width="100%" >     <param name="movie" value="http://d1.scribdassets.com/ScribdViewer.swf?document_id=24191660&#038;access_key=key-1s9h3u64z58xnt8khfgi&#038;page=1&#038;version=1&#038;viewMode=book">        <param name="quality" value="high">         <param name="play" value="true">        <param name="loop" value="true">        <param name="scale" value="showall">        <param name="wmode" value="opaque">         <param name="devicefont" value="false">     <param name="bgcolor" value="#ffffff">      <param name="menu" value="true">        <param name="allowFullScreen" value="true">         <param name="allowScriptAccess" value="always">         <param name="salign" value="">                      <param name="mode" value="book">                <embed src="http://d1.scribdassets.com/ScribdViewer.swf?document_id=24191660&#038;access_key=key-1s9h3u64z58xnt8khfgi&#038;page=1&#038;version=1&#038;viewMode=book" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" scale="showall" wmode="opaque" devicefont="false" bgcolor="#ffffff" name="doc_309322902042237_object" menu="true" allowfullscreen="true" allowscriptaccess="always" salign="" type="application/x-shockwave-flash" align="middle" mode="book" height="500" width="100%"></embed>  </object></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2009/12/installing-nexus-open-source-on-a-windows-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Special Character Encoding Properties</title>
		<link>http://blog.sonatype.com/people/2009/11/special-character-encoding-properties/</link>
		<comments>http://blog.sonatype.com/people/2009/11/special-character-encoding-properties/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 09:29:27 +0000</pubDate>
		<dc:creator>Anders Hammar</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Devoteam]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=3344</guid>
		<description><![CDATA[The other week I listened to Dennis Lundberg&#8217;s presentation &#8220;Site creation with Maven&#8221; and learned something new. As most of us living outside the plain ASCII world have experienced, character encoding makes a big difference when it comes to ensuring that text remains readable. For XML files, the encoding can be defined through the XML [...]]]></description>
				<content:encoded><![CDATA[<p>The other week I listened to Dennis Lundberg&#8217;s presentation &#8220;<a title="Dennis Lundberg's presentation &quot;Site creation with Maven&quot;" href="http://www.dennislundberg.se/maven/Site-creation-with-Maven.pdf" target="_blank">Site creation with Maven</a>&#8221; and learned something new. As most of us living outside the plain ASCII world have experienced, character encoding makes a big difference when it comes to ensuring that text remains readable. For XML files, the encoding can be defined through the XML header which makes it possible for an XML file reader to decide on the proper encoding. But for other types of files such as Java source files and properties files, the encoding has to be defined outside of the actual source file.</p>

<p>Even though encoding seems to be handled correctly in your environment, with your local language settings or some implicit default value, the best practice is to always explicitly define the character encoding. This will make sure that your build is portable and it will also protect you in the future in case some of your default values change. The bottom line is, just do it!</p>

<p>In the Maven world, you need to specify the character encoding for every plugin that processes source files or creates reports. It would have been great if this were made possible through a shared configuration element in the POM, but that would require an update to the POM model and that won&#8217;t happen until Maven 3.x. In the meantime, two special properties have been defined.</p>

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

<blockquote><code>project.build.sourceEncoding</code><br />

<code>project.reporting.outputEncoding</code></blockquote>

<p>If these properties are set, most plugins will use the character encoding defined through them. So now we don&#8217;t have to individually configure all plugins. If needed, the encoding defined through the properties can be overridden by defining some other encoding in the plugin&#8217;s configuration. As always, some plugin could work differently and you should always consult the plugin&#8217;s documentation.</p>

<p>More information about the thoughts behind these special properties and how to use them can be found in the proposals below. On these pages you can also find out which plugins have been updated to use these properties.</p>

<ul>
    <li><a title="Proposal for source file encoding property" href="http://docs.codehaus.org/display/MAVENUSER/POM+Element+for+Source+File+Encoding" target="_blank">POM Element for Source File Encoding</a></li>
    <li><a title="Proposal for reporting encoding property" href="http://docs.codehaus.org/display/MAVEN/Reporting+Encoding+Configuration" target="_blank">Reporting Encoding Configuration</a></li>
</ul>

<p>Dennis, thanks for the tip!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2009/11/special-character-encoding-properties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven 3.x: Paving the desire lines &#8212;  Part One</title>
		<link>http://blog.sonatype.com/people/2009/11/maven-3x-paving-the-desire-lines-part-one-2/</link>
		<comments>http://blog.sonatype.com/people/2009/11/maven-3x-paving-the-desire-lines-part-one-2/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 08:32:29 +0000</pubDate>
		<dc:creator>Jason van Zyl</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[m2eclipse]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Sonatype]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=3292</guid>
		<description><![CDATA[Maven 3.0 With Maven 3.x we have made our best attempt to listen to users, find out what they need and want, and make reasonable preparations and plans to fix the problems, implement useful features, and create the integration points for working properly with third-party systems like Nexus and Hudson. While there have been many [...]]]></description>
				<content:encoded><![CDATA[<!-- Generated by Markdown to HTML in MarsEdit -->

<h1>Maven 3.0</h1>

<p>With Maven 3.x we have made our best attempt to listen to users, find out what they need and want, and make reasonable preparations and plans to fix the problems, implement useful features, and create the integration points for working properly with third-party systems like Nexus and Hudson. While there have been many new feature requests &#8212; and we have many new features done or in the works &#8212; the number one concern is backward compatibility. Maven 3.x makes an ardent attempt to be 100% backward-compatible with Maven 2.x. All your Maven 2.x builds should work out of the box using 3.x without change to your projects. We simply can&#8217;t cause pain to the existing user base. We are very cognizant that even small changes can have a huge impact and so we have tried achieve complete Maven 2.x fidelity with Maven 3.x.</p>

<p>In Maven 3.x we have reduced the number of modules, we have simplified and extracted the artifact resolution system, we have put a performance framework in place, and we have created an enormous set of integration tests for Maven&#8217;s core and for many of the core plugins. We are constantly trying to validate core features and core plugins are working properly. We hope with the simplifications that we have made that more people will get involved in the project. We have done some heavy overhauling of many of the internals to make way for future features and I believe Maven 3.x is really the only path forward for Maven. What&#8217;s the technique we used to decide on how to plan and work toward the completion of Maven 3.x? A very practical approach to determining an optimal path called desire lines.</p>

<h2>Desire Lines</h2>

<p>A desire line usually represents the shortest or most easily navigated route between an origin and destination. The width and amount of erosion of the line represents the amount of demand. The term was coined by Gaston Bachelard in his book The Poetics of Space. Desire lines can usually be found as shortcuts where constructed pathways take a circuitous route. A concrete example: the pathways around the Berkeley campus in California. During the early years of Berkeley no pathways were paved. Instead they let inhabitants walk in optimal paths between the buildings and location over a period time to form clear pathways over the grass. Once these pathways had been established they could be paved to make the pathway more permanent. This is very similar to what happened with Maven 2.x. Consider Maven 2.x the pathways marked in the grass. Consider Maven 3.x taking all that learning from Maven 2.x and adopting the optimal form of use and codifying those forms of use i.e. paving the desire lines.</p>

<p>Over the course of hundreds of thousands of people using Maven we have a very good idea of what these optimal pathways look like now. Here are a few examples of some of the things we&#8217;ve seen and the things we have to do in order to make these lasting improvements.</p>

<h2>Responding to invitations for improvement</h2>

<p><img src="http://www.sonatype.com/people/wp-content/uploads/2009/11/desireline11.png" alt="DesireLine1.png" border="0" width="666" height="500" /></p>

<p>There are many things in Maven 2.x that work reasonably well but have some minor flaws which cause irritation:</p>

<ul><li>Dependency management. How to effectively manage what we will call a target platform (intentionally using the Eclipse nomenclature). It is easy to manage the versions of an applications runtime or its target platform. But what happens when you start pulling in multiple, separately developed target platforms.</li><li>Version specifications and version ranges. Maven&#8217;s notion of this is workable, but when it comes to the version specification and ranges it&#8217;s time to just defer to OSGi in this regard. What OSGi specifies and what Maven specifies are not wildly different but different enough to cause some problems. We&#8217;ll be working on aligning Maven to the version specification of OSGi.</li><li>The way plugins interact with embedded environments was just wrong. We allowed for no support for incremental changes. The result is that in M2Eclipse when you change an individual resource, that individual resource can be processed efficiently and not fire up all of Maven to run the whole build lifecycle. Sorry, but you won&#8217;t have time to get a coffee anymore.</li><li>There are slew more, but we&#8217;ll save those for other blog entries.</li></ul>

<h2>Responding to &#8230; being completely wrong</h2>

<p><img src="http://www.sonatype.com/people/wp-content/uploads/2009/11/desireline2.jpg" alt="DesireLine2.jpg" border="0" width="375" height="500" /></p>

<p>There are some things in Maven 2.x we just didn&#8217;t get right and we have to make reparations:</p>

<ul><li>Composition versus inheritance in the POM. There are some great debugged toolchains like we have in the Apache Organization POM for releasing, but this toolchain is not easily consumable by outside projects because it makes no sense to inherit from the Apache Organization POM for your projects. So how can we make these chunks of debugged combinations of plugins and their associated configuration? We will introduce mixins to help with this. Essentially it will be a POM consisting of plugins and configurations that can be externally parameterized. These mixins will be deployed to a repository and be referenced with a standard coordinate. Basically it will be an intelligent import with validation which will allow composition in your POMs.</li><li>Checking out the whole source tree versus an individual module and parent element versioning. We have always intentionally made projects specify versions in the parent elements. When you check out individual modules this is necessary. But for projects where the whole source tree is checked out, the version of the parent can be inferred and the requirement for specifying the version element in the parent can be removed.</li><li>Clean separation of operations that need to happen at the beginning and end of the lifecycle versus in the lifecycle itself. To make the OSGi integration we created work we needed to get at the projects before the build lifecycle was executed so we added a clear hook before lifecycle execution. What we have done to make OSGi integration work in Maven 3.x is simply not possible in Maven 2.x. We also had a terrible problem with reporting and aggregation because there was no clear point at which the lifecycle was over. Now once the build lifecycle is complete there is a clear hook to get the projects in the reactor so they can be processed easily. Accurate aggregation is now possible.</p></li><li>Again, there are slew more, but we&#8217;ll also save those for other blog entries.</li></ul>

<h2>Responding to under-utilization of what exists</h2>

<p>Unfortunately there are still a lot of powerful features and plugins in Maven that a lot of people don&#8217;t know about. We have tried to remedy this situation with the four books that we constantly update stream, and a stream of blog posts, and the soon to be enterprise Maven users list which will focus on the holistic and systematic use of Maven, M2Eclipse, Nexus and Hudson. We need to do a better job explaining end-to-end best practices for developing, testing, and provisioning software. We also need to do a better job describing some of the incredibly useful plugins we have like the enforcer plugin and the dependency plugin.</p>

<p>But again, our best attempt to show people what is available through the four books that we have:</p>

<ul><li><a href="http://www.sonatype.com/documentation/books/maven-defguide">Maven: The Definitive Guide</a></li><li><a href="http://books.sonatype.com/nexus-book/">Repository Management with Nexus</a></li><li><a href="http://books.sonatype.com/m2eclipse-book/reference">Developing with Eclipse and Maven</a></li><li><a href="http://books.sonatype.com/mhandbook/reference">The Maven Handbook</a></li></ul>

<p>Here is a picture I always use to illustrate the point that even though something may be sitting directly in front of you, it&#8217;s not always immediately obvious unless someone points it out to you. Th
is is very much the case where we see users asking us for help with particular use cases and in frequently it&#8217;s very easy to answer the question by pointing to a URL. My example is the Fedex logo which was designed to have an arrow being formed between the last two letters of the logo. Quite ingenious but most people I point this out to haven&#8217;t notice it. </p>

<p><img src="http://www.sonatype.com/people/wp-content/uploads/2009/11/fedex11.png" alt="Fedex1.png" border="0" width="588" height="175" /></p>

<p><img src="http://www.sonatype.com/people/wp-content/uploads/2009/11/fedex21.png" alt="Fedex2.png" border="0" width="588" height="175" /></p>

<p>We are going to try a lot harder to make sure the value that exists is easier to find. I don&#8217;t enjoy reading blog posts from unhappy users at all, but I especially don&#8217;t like it when I know there is a solution which has been documented somewhere. Those painful situations can be reduced if not eliminated completely.</p>

<h2>Backward Compatibility</h2>

<p>I can&#8217;t stress enough how important backward compatibility is to us. We have done a non-trivial amount of work to pave the way for new capabilities in Maven 3.x while preserving 100% backward compatibility for:</p>

<ul><li>Maven itself and the behaviour that users expect from the CLI</li><li>Artifact Resolution API</li><li>Plugin API</li><li>Plugin configuration</li><li>Site generation (even though we&#8217;ve extracted site/reporting entirely into the maven-site-plugin)</li></ul>

<p>We must ensure that plugins and reports written against the Maven 2.0.x APIs remain viable in 3.0. We don&#8217;t want people rewriting their plugins or having to change their projects at all or it will simply be chaos. We simply have too many users and requiring changes will have an enormous human cost so we&#8217;ve been slow in announcing Maven 3.x. The version of Maven 3.x you can pull from the Sonatype grid is probably the best version of Maven that has existed but we are still being careful about releasing it. If you want to try it you can find it <a href="https://grid.sonatype.org/ci/view/Maven%203.0.x/job/maven-3.0.x-bootstrap/">here</a>.</p>

<p>We must also ensure that POMs of version 4.0.0 are supported in 3.x along with the behavior currently experienced. We will need to make changes to the POM in order to introduce many of the new features so we&#8217;ve made the requisite preparation. We are relying heavily on our integrations tests right now but as we move forward the work that Benjamin is doing on the project/model-builder will help us to accommodate different versions of a POM, and different formats we decide to support.  The model-builder code has no limitation with respect to formats. We can support XML, or any source that anyone can dream up. These implementations may find use outside of Maven. For example someone might build something with the Maven, JRuby, and Mercury to create a JRuby-based system. The same could be done for Groovy. We already have some examples of this with the Polyglot Maven project we&#8217;ve started which will be the topic of a subsequent post.</p>

<p>We have managed to keep almost everything backward compatible and we will go so far as to provide an isolated execution environment that can contain older versions of the plugin API so that everything from the past can continue to work in Maven 3.x. We will not truly be able to do this until we change the internal Maven runtime over to OSGi but we know what needs to be done. </p>

<h2>Integration Testing</h2>

<p>An enormous amount of time and energy has gone into improving the the integration tests for Maven. The integration tests are the gatekeeper and let us determine that we have a Maven 3.x that is compatible for Maven 2.x. We now have 506 integration tests that will help protect us as we move forward. We will likely approach 600 integration tests by the time we reach the Maven 3.0 GA.</p>

<p>All core Maven plugins now have ITs and we have started branching out into the Mojo project to create plugin ITs there as well. We have a good pattern so we are encouraging anyone writing a Maven plugin to create ITs so that we can help ensure we don’t break people in the future. We have really taken fixing the problems we see seriously. I couldn&#8217;t help but make a little spoof of the SNL skit and adapting it for the Maven perspective.</p>

<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/kaT-jFpwj_M&amp;hl=en&amp;fs=1&amp;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/kaT-jFpwj_M&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>

<p>In the next post I will start talking about some of the technical changes we have made to Maven 3.x in order to achieve our goals. Those will include:</p>

<ul><li>Refactored model/project builder (the support Polyglot Maven uses)</li><li>Queryable lifecycle</li><li>Lifecycle Extension points</li><li>Error and integrity reporting</li><li>Mercury: Jetty Client &amp; SAT4J</li><li>Embedding</li><li>Incremental build support (used heavily in M2Eclipse for performance improvements, these are changes to the plugin API)</li></ul>

<p>I plan to try and write something about Maven 3.x frequently in preparation for the Maven 3.x talks in <a href="http://www.javaforum.se/jf/index.jsp?meeting=53">Stockholm</a>, <a href="http://rheinjug.de/knowledge/vortr-mainmenu-28/108-maven-3-mit-jason-van-zyl">Dusseldorf</a>, <a href="http://87.230.78.21:8080/display/jugc/2009.11.16+Maven+3">Cologne</a>, and <a href="http://oredev.org/maven">Devoxx</a>.</p>

<p>Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2009/11/maven-3x-paving-the-desire-lines-part-one-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nexus Tips: Disable Redeployment in Nexus</title>
		<link>http://blog.sonatype.com/people/2009/11/nexus-tips-disable-redeployment-in-nexus/</link>
		<comments>http://blog.sonatype.com/people/2009/11/nexus-tips-disable-redeployment-in-nexus/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 16:10:26 +0000</pubDate>
		<dc:creator>Brian Demers</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Nexus]]></category>
		<category><![CDATA[best practice]]></category>
		<category><![CDATA[nexus pro]]></category>
		<category><![CDATA[repository]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=3111</guid>
		<description><![CDATA[It&#8217;s a fundamental tenet of Maven that release artifacts never change once they are released. This is enforced in Maven by the fact that once a release artifact or POM is located in the local repository, Maven will never check for an updated artifact in a remote repository. Once an artifact is released, it is [...]]]></description>
				<content:encoded><![CDATA[<p>It&#8217;s a fundamental tenet of Maven that <b>release artifacts never change once they are released</b>. This is enforced in Maven by the fact that once a release artifact or POM is located in the local repository, Maven will never check for an updated artifact in a remote repository.   Once an artifact is released, it is considered a static, unchanging artifact.  If you release an artifact and then subsequently change it (intentionally or otherwise), you&#8217;re in for some fun as people will have different versions based on when they first retrieved it&#8230; that&#8217;s a situation not exactly conducive to a repeatable, standard build.   This blog post discusses a feature in Nexus 1.4 which can enforce this rule and help you avoid problems caused by the redeployment of release artifacts.</p>

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

<p>To illustrate this problem, consider a 1.0 build of your product that depends on foo-1.2.jar.  It works great. Then you build 2.0 of your product which still depends on foo-1.2.jar.  Since then, foo-1.2.jar was patched and now breaks your application.  However the application still works for half of your developers because the original foo-1.2.jar is in their local repository and possibly proxied in another Nexus instance.</p>

<p>The solution is to release a new version foo-1.2.1.jar. (ie foo-1.2.2.jar or foo-1.2.1.1-jar), but that alone isn&#8217;t enough.   You want to make sure that you are using a repository manager that prevents someone from updating a release artifact once it has been published.</p>

<p>It has always been possible to stop people from doing this in Nexus but the solution was difficult to <a href="http://nexus.sonatype.org/about/faq.html#QHowdoIdisableartifactredeployment">explain</a>.    In the Nexus 1.4 release, we have reworked and simplified the interface to encourage this best-practive.</p>

<p>To disable redeployment, edit your repository and set the &#8216;Deployment Policy&#8217; field to &#8216;Disable Redeploy&#8217; then click save.</p>

<p><img class="alignnone size-full wp-image-3115" title="disable-redploy" src="http://www.sonatype.com/people/wp-content/uploads/2009/10/disable-redploy.png" alt="disable-redploy" width="422" height="140" /></p>

<p>Upgrading from a previous version of Nexus 1.4.0 will set this field to &#8216;Allow Redeploy&#8217;, so no existing repositories will be changed and the behavior matches previous releases. However the default value when creating a new repository is now &#8216;Disable Redeploy&#8217;.</p>

<p>When you use Nexus, you are not just using a capable repository manager, you are adopting the best-practice.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2009/11/nexus-tips-disable-redeployment-in-nexus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven Tips and Tricks: Optimizing with the Maven Dependency Plugin</title>
		<link>http://blog.sonatype.com/people/2009/10/maven-tips-and-tricks-optimizing-with-the-maven-dependency-plugin/</link>
		<comments>http://blog.sonatype.com/people/2009/10/maven-tips-and-tricks-optimizing-with-the-maven-dependency-plugin/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 20:05:30 +0000</pubDate>
		<dc:creator>Brian Fox</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=3224</guid>
		<description><![CDATA[On larger projects, additional dependencies often tend to creep into a POM as the number of dependencies grow. As dependencies change, you are often left with dependencies that are not being used, and just as often, you may forget to declare explicit dependencies for libraries you require. Because Maven 2.x includes transitive dependencies in the [...]]]></description>
				<content:encoded><![CDATA[<p>On larger projects, additional dependencies often tend to creep into a POM as the number of dependencies grow. As dependencies change, you are often left with dependencies that are not being used, and just as often, you may forget to declare explicit dependencies for libraries you require. Because Maven 2.x includes transitive dependencies in the compile scope, your project may compile properly but fail to run in production. Consider a case where a project uses classes from a widely used project such as Jakarta Commons BeanUtils. Instead of declaring an explicit dependency on BeanUtils, your project simply relies on a project like Hibernate that references BeanUtils as a transitive dependency. Your project may compile successfully and run just fine, but if you upgrade to a new version of Hibernate that doesn’t depend on BeanUtils, you’ll start to get compile and runtime errors, and it won’t be immediately obvious why your project stopped compiling. Also, because you haven’t explicitly listed a dependency version, Maven cannot resolve any version conflicts that may arise.
<span id="more-3224"></span></p>

<p>A good rule of thumb in Maven is to always declare explicit dependencies for classes referenced in your code. If you are going to be importing Commons BeanUtils classes, you should also be declaring a direct dependency on Commons BeanUtils. Fortunately, via bytecode analysis, the Maven Dependency plugin is able to assist you in uncovering direct references to dependencies. Using the updated POMs we previously optimized, let’s look to see if any errors pop up:</p>

<pre>$ mvn dependency:analyze
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO]   Chapter 8 Simple Parent Project
[INFO]   Chapter 8 Simple Object Model
[INFO]   Chapter 8 Simple Weather API
[INFO]   Chapter 8 Simple Persistence API
[INFO]   Chapter 8 Simple Command Line Tool
[INFO]   Chapter 8 Simple Web Application
[INFO]   Chapter 8 Parent Project
[INFO] Searching repository for plugin with prefix: 'dependency'.

...

[INFO] ------------------------------------------------------------------------
[INFO] Building Chapter 8 Simple Object Model
[INFO]    task-segment: [dependency:analyze]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing dependency:analyze
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [dependency:analyze]
[WARNING] Used undeclared dependencies found:
[WARNING]    javax.persistence:persistence-api:jar:1.0:compile
[WARNING] Unused declared dependencies found:
[WARNING]    org.hibernate:hibernate-annotations:jar:3.3.0.ga:compile
[WARNING]    org.hibernate:hibernate:jar:3.2.5.ga:compile
[WARNING]    junit:junit:jar:3.8.1:test

...

[INFO] ------------------------------------------------------------------------
[INFO] Building Chapter 8 Simple Web Application
[INFO]    task-segment: [dependency:analyze]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing dependency:analyze
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] No sources to compile
[INFO] [dependency:analyze]
[WARNING] Used undeclared dependencies found:
[WARNING]    org.sonatype.mavenbook.optimize:simple-model:jar:1.0:compile
[WARNING] Unused declared dependencies found:
[WARNING]    org.apache.velocity:velocity:jar:1.5:compile
[WARNING]    javax.servlet:jstl:jar:1.1.2:compile
[WARNING]    taglibs:standard:jar:1.1.2:compile
[WARNING]    junit:junit:jar:3.8.1:test</pre>

<p>In the truncated output just shown, you can see the output of the dependency:analyze  goal. This goal analyzes the project to see whether there are any indirect dependencies, or dependencies that are being referenced but are not directly declared. In the simple-model project, the Dependency plugin indicates a “used undeclared dependency” on javax.persistence:persistence-api. To investigate further, go to the simple-model directory and run the dependency:tree goal, which will list all of the project’s direct and transitive dependencies:</p>

<pre>$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Chapter 8 Simple Object Model
[INFO]    task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
[INFO] [dependency:tree]
[INFO] org.sonatype.mavenbook.optimize:simple-model:jar:1.0
[INFO] +- org.hibernate:hibernate-annotations:jar:3.3.0.ga:compile
[INFO] |  \- javax.persistence:persistence-api:jar:1.0:compile
[INFO] +- org.hibernate:hibernate:jar:3.2.5.ga:compile
[INFO] |  +- net.sf.ehcache:ehcache:jar:1.2.3:compile
[INFO] |  +- commons-logging:commons-logging:jar:1.0.4:compile
[INFO] |  +- asm:asm-attrs:jar:1.5.3:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  +- antlr:antlr:jar:2.7.6:compile
[INFO] |  +- cglib:cglib:jar:2.1_3:compile
[INFO] |  +- asm:asm:jar:1.5.3:compile
[INFO] |  \- commons-collections:commons-collections:jar:2.1.1:compile
[INFO] \- junit:junit:jar:3.8.1:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
</pre>

<p>From this output, we can see that the persistence-api dependency is coming from hibernate. A cursory scan of the source in this module will reveal many javax.persistence  import statements confirming that we are, indeed, directly referencing this dependency. The simple fix is to add a direct reference to the dependency. In this example, we put the dependency version in simple-parent’s dependencyManagement  section because the dependency is linked to Hibernate, and the Hibernate version is declared here. Eventually you are going to want to upgrade your project’s version of Hibernate. Listing the persistence-api dependency version near the Hibernate dependency version will make it more obvious later when your team modifies the parent POM to upgrade the Hibernate version.</p>

<p>If you look at the dependency:analyze output from the simple-web module, you will see that we also need to add a direct reference to the simple-model dependency. The code in simple-webapp directly references the model objects in simple-model, and the simple-model is exposed to simple-webapp as a transitive dependency via simple-persist. Since this is a sibling dependency that shares both the version and groupId, the dependency can be defined in simple-webapp’s pom.xml using the ${project.groupId} and ${project.version}.</p>

<p>How did the Maven Dependency plugin uncover these issues? How does dependency:analyze know which classes and dependencies are directly referenced by your project’s bytecode? The Dependency plugin uses the ObjectWeb ASM (http://asm.objectweb.org/) toolkit to analyze the raw bytecode. The Dependency plugin uses ASM to walk through all the classes in the current project, and it builds a list of every other class referenced. It then walks through all the dependencies, direct and transitive, and marks off the classes discovered in the direct dependencies. Any classes not located in the direct dependencies are discovered in the transitive dependencies, and the list of “used, undeclared dependencies” is produced.</p>

<p>In contrast, the list of unused, declared dependencies is a little trickier to validate, and less useful than the “used, undeclared dependencies.” For one, some dependencies are used only at runtime or for tests, and they won’t be found in the bytecode. These are pretty obvious when you see them in the output; for example, JUnit appears in this list, but this is expected because it is used only for unit tests. You’ll also notice that the Velocity and Servlet API dependencies are listed in this list for the simple-web module. This is also expected because, although the project doesn’t have any direct references to the classes of these artifacts, they are still essential during runtime.</p>

<p>Be careful when removing any unused, declared dependencies unless you have very good test coverage, or you might introduce a runtime error. A more sinister issue pops up with bytecode optimization. For example, it is legal for a compiler to substitute the value of a constant and optimize away the reference. Removing this dependency will cause the compile to fail, yet the tool shows it as unused. Future versions of the Maven Dependency plugin will provide better techniques for detecting and/or ignoring these types of issues.</p>

<p>You should use the dependency:analyze tool periodically to detect these common errors in your projects. It can be configured to fail the build if certain conditions are found, and it is also available as a report.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2009/10/maven-tips-and-tricks-optimizing-with-the-maven-dependency-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven Tips and Tricks: Grouping Dependencies</title>
		<link>http://blog.sonatype.com/people/2009/10/maven-tips-and-tricks-grouping-dependencies/</link>
		<comments>http://blog.sonatype.com/people/2009/10/maven-tips-and-tricks-grouping-dependencies/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 17:20:06 +0000</pubDate>
		<dc:creator>Tim O'Brien</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=3192</guid>
		<description><![CDATA[Maven can be used to manage everything from simple, single-project systems to builds that involve hundreds of inter-related submodules. Part of the learning process with Maven isn&#8217;t just figuring out the syntax for configuring Maven, it is learning the &#8220;Maven Way&#8221;—the current set of best practices for organizing and building projects using Maven. This is [...]]]></description>
				<content:encoded><![CDATA[<p>Maven can be used to manage everything from simple, single-project systems to builds that involve hundreds of inter-related submodules. Part of the learning process with Maven isn&#8217;t just figuring out the syntax for configuring Maven, it is learning the &#8220;Maven Way&#8221;—the current set of best practices for organizing and building projects using Maven. This is the first in a series of posts that will attempt to distill some of this knowledge to help you adopt best practices from the start without having to wade through years of discussions on the Maven mailing lists.</p>

<h3>Grouping Dependencies</h3>

<p>If you have a set of dependencies which are logically grouped together. You can create a project with pom packaging that groups dependencies together. For example, let&#8217;s assume that your application uses Hibernate, a popular Object-Relational mapping framework. Every project which uses Hibernate might also have a dependency on the Spring Framework and a MySQL JDBC driver. Instead of having to include these dependencies in every project that uses Hibernate, Spring, and MySQL you could create a special POM that does nothing more than declare a set of common dependencies. You could create a project called persistence-deps (short for Persistence Dependencies), and have every project that needs to do persistence depend on this convenience project: </p>

<p><span id="more-3192"></span></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 style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.sonatype.mavenbook<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>persistence-deps<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>pom<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.hibernate<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>hibernate<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${hibernateVersion}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.hibernate<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>hibernate-annotations<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${hibernateAnnotationsVersion}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.springframework<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>spring-hibernate3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${springVersion}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>mysql<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>mysql-connector-java<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mysqlVersion}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mysqlVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>(5.1,)<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mysqlVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;springVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>(2.0.6,)<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/springVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hibernateVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>3.2.5.ga<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hibernateVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hibernateAnnotationsVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>3.3.0.ga<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hibernateAnnotationsVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></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>If you create this project in a directory named persistence-deps, all you need to do is create this pom.xml and run mvn install. Since the packaging type is pom, this POM is installed in your local repository. You can now add this project as a dependency and all of its dependencies will be added to your project. When you declare a dependency on this persistence-deps project, don&#8217;t forget to specify the dependency type as pom. </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 style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>This is a project requiring JDBC<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  ...
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    ...
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.sonatype.mavenbook<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>persistence-deps<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>pom<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></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>If you later decide to switch to a different JDBC driver (for example, JTDS), just replace the dependencies in the persistence-deps  project to use net.sourceforge.jtds:jtds instead of mysql:mysql-java-connector and update the version number. All projects depending on persistence-deps  will use JTDS if they decide to update to the newer version. Consolidating related dependencies is a good way to cut down on the length of pom.xml files that start having to depend on a large number of dependencies. If you need to share a large number of dependencies between projects, you could also just establish parent-child relationships between projects and refactor all common dependencies to the parent project, but the disadvantage of the parent-child approach is that a project can have only one parent. Sometimes it makes more sense to group similar dependencies together and reference a pom dependency. This way, your project can reference as many of these consolidated dependency POMs as it needs. </p>

<blockquote>Maven uses the depth of a dependency in the tree when resolving conflicts using a nearest-wins approach. Using the dependency grouping technique above pushes those dependencies one level down in the tree. Keep this in mind when choosing between grouping in a pom or using dependencyManagement in a parent POM</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2009/10/maven-tips-and-tricks-grouping-dependencies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven Tips and Tricks: Encrypting Passwords</title>
		<link>http://blog.sonatype.com/people/2009/10/maven-tips-and-tricks-encrypting-passwords/</link>
		<comments>http://blog.sonatype.com/people/2009/10/maven-tips-and-tricks-encrypting-passwords/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 18:15:59 +0000</pubDate>
		<dc:creator>Tim O'Brien</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=3118</guid>
		<description><![CDATA[The first time I configured Maven to authenticate against a protected repository manager, I was somewhat disturbed by presence of unencrypted passwords in my home directory. While many of us have grown accustomed to leaving a few unencrypted passwords here or there in a production system, it just didn&#8217;t seem appropriate to leave a password [...]]]></description>
				<content:encoded><![CDATA[<p>The first time I configured Maven to authenticate against a protected repository manager, I was somewhat disturbed by presence of unencrypted passwords in my home directory.   While many of us have grown accustomed to leaving a few unencrypted passwords here or there in a production system, it just didn&#8217;t seem appropriate to leave a password for something like a repository manager sitting in a known file location (~/.m2/settings.xml).    Luckily, Maven provides a very easy method for encrypting passwords.  In this post, I&#8217;ll walk you through the process.</p>

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

<h3>Introduction</h3>

<p>Once you start to use Maven to deploy software to remote repositories and to interact with source control systems directly, you will start to collect a number of passwords in your Maven Settings and without a mechanism for encrypting these passwords, a developer&#8217;s ~/.m2/settings.xml will quickly become a security risk as it will contain plain-text passwords to source control and repository managers. Maven 2.1 introduced a facility to encrypt passwords in a user&#8217;s Maven Settings (~/.m2/settings.xml). To do this, you must first create a master password and store this master password in a security-settings.xml file in ~/.m2/settings-security.xml. You can then use this master password to encrypt passwords stored in Maven Settings (~/.m2/settings.xml).</p>

<p>To illustrate this feature, consider the process Maven uses to retrieve an unencrypted server password for a user&#8217;s Maven Settings as shown in the following figure. A user will reference a named server using an identifier in a project&#8217;s POM, Maven looks for a matching server in Maven Settings. When it finds a matching server element in Maven Settings, Maven will then use the password associated with that server element and send this password along to the server. The password is stored as plain-text in ~/.m2/settings.xml and it is readily available to anyone who has read access to this file.</p>

<p><img src="http://www.sonatype.com/people/wp-content/uploads/2009/10/settings_password-no-encryption.png" alt="settings_password-no-encryption" title="settings_password-no-encryption" width="473" height="196" class="aligncenter size-full wp-image-3119" /></p>

<p>Next, consider the process Maven uses to support encrypted passwords as shown in the following figure.</p>

<p><img src="http://www.sonatype.com/people/wp-content/uploads/2009/10/settings_password-encryption.png" alt="settings_password-encryption" title="settings_password-encryption" width="472" height="325" class="aligncenter size-full wp-image-3120" /></p>

<p>To configure encrypted passwords, create a master password by running mvn -emp or mvn &#8211;encrypt-master-password followed by your master password.</p>

<pre>$ mvn -emp mypassword
{rsB56BJcqoEHZqEZ0R1VR4TIspmODx1Ln8/PVvsgaGw=}</pre>

<p>Maven prints out an encrypted copy of the password to standard out. Copy this encrypted password and paste it into a ~/.m2/settings-security.xml file.</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;settingsSecurity<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;master<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>{rsB56BJcqoEHZqEZ0R1VR4TIspmODx1Ln8/PVvsgaGw=}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/master<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/settingsSecurity<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>


<p>After you have created a master password, you can then encrypt passwords for use in your Maven Settings. To encrypt a password with the master password, run mvn -ep or mvn &#8211;encrypt-password. Assume that you have a repository manager and you need to send a username of &#8220;deployment&#8221; and a password of &#8220;qualityFIRST&#8221;. To encrypt this particular password, you would run the following command:</p>

<pre>$ mvn -ep qualityFIRST
{uMrbEOEf/VQHnc0W2X49Qab75j9LSTwiM3mg2LCrOzI=}</pre>

<p>At this point, copy the encrypted password printed from the output of mvn -ep and paste it into your Maven Settings.</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;settings<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;server<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>nexus<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;username<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deployment<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/username<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>{uMrbEOEf/VQHnc0W2X49Qab75j9LSTwiM3mg2LCrOzI=}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/server<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  ...
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/settings<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>


<p>When you run a Maven build that needs to interact with the repository manager, Maven will retrieve the Master password from the ~/.m2/settings-security.xml file and use this master password to decrypt the password stored in your ~/.m2/settings.xml file. Maven will then send the decrypted password to the server.</p>

<p>What does this buy you? It allows you to avoid storing your passwords in ~/.m2/settings.xml as plain-text passwords providing you with the peace of mind that your critical passwords are not being stored, unprotected in a Maven Settings file. Note that this feature does not provide for encryption of the password while it is being sent to the remote server. An enterprising attacker could still capture the password using a network analysis tool.</p>

<p>For an extra level of security, you can encourage your developers to store the encrypted master password on a removable storage device like a USB hard drive. Using this method, a developer would plug a removable drive into a workstation when she wanted to perform a deployment or interact with a remote server. To support this, your ~/.m2/settings-security.xml file would contain a reference to the location of the settings-security.xml file using the relocation element.</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;settingsSecurity<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;relocation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/Volumes/usb-key/settings-security.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/relocation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/settingsSecurity<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>


<p>The developer would then store the settings-security.xml file at /Volumes/usb-key/settings-security.xml which would only be available if the developer were sitting at the workstation.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonatype.com/people/2009/10/maven-tips-and-tricks-encrypting-passwords/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
