Maven in our development process. Part 2 - Maven infrastructure.
Sherali Karimov, X-Team LeadFebruary 19, 2008
In this part I will focus on the infrastructure that Maven needs to have in place and how we set it up to suite our needs..
Repositories
With Maven you use repositories to store your libraries. In fact you store artifacts in the repositories. We have a few repositories for different types of artifacts:

- Public libraries are kept in our public repository.
- Contributed libraries are in the contrib repository.
- Binaries and javadoc of closed-source libraries are released to the public repository and sources to private repository.
- There is a special repository for the third-party libraries. Mainly this serves as a convenience. We do not deploy all the third-party libraries we depend on here but only things we can not find in other public Maven repositories. We also deploy the source code and the javadoc of some libraries so it can be easily attached in IDEs.
- Everyone who uses Maven seriously, is familiar with the pain of coping with SUN libraries. To make this easier on our own developers we have a restricted repository devoted to these libraries. Giving our DevNet teams and customers access to this repository would make their lives easier but would be against the license terms so we can not do that. Nevertheless this is yet another type of library we have a Maven repository for. Note: Java.net provide a maven2 repository but it does not have all of the needed Sun libraries (e.g. activation, mail etc.)
Latest update:- connected archiva to the Java.net maven1 and Java.net maven2 repositories
- configured a nice feature in Archiva that translates maven1 artifacts to maven2 artifacts transparently
- There also are public-snapshot, contrib-snapshot and private-snapshot repositories that host 'snapshots' for the corresponding types of libraries. (Snapshot is a special version that indicates a current development copy. Unlike regular versions, Maven will check for a new SNAPSHOT version in a remote repository regularly. Snapshots are also handled entirely by maven thus reducing the management overhead of maintaining and publishing development versions.)
All those repositories are accessible via WebDAV. Here is how access restrictions to those repositories are configured (the arrow pointing back at the repository means write access):
Proxies
We do not use our repositories directly though. Instead - we have two Archiva proxies.

External proxy is hosted outside the office. The internal proxy is in Sydney office. When connecting to m2proxy.atlassian.com internally, internal DNS server will resolve it to the local proxy. Outside the office, it will resolve to the external proxy. This is quite convenient since it allows people to seamlessly roam between offices or work from home without affecting their Maven settings.
Since we wanted only to maintain one proxy for developers, customers and contributors, we have partitioned the proxy into two parts.
- The Public section of the proxy is accessible to everyone and it lets you lookup Atlassian public and contrib libraries, their snapshots and whatever third-party libraries there might be on it. It is also connected to the ibiblio server in case it needs to resolve a new third-party artifact.
- The Private section of the proxy requires authentication (which Maven will handle) and resolves against the above the public one and also against the private and the restricted repositories I described earlier.
The internal proxy, in turn, will resolve against the private section of the external proxy.
The only time when repositories are accessed directly is when writing to them. Write requests are authenticated against our Crowd instance and a distinction is made between atlassian-staff and atlassian-devnet roles for authorization.
Maven proxies also cache things that they download. This means if a version of a product was built once against the proxy, it will always be possible to build that version again even if any one of the repositories is down. This is especially important when it comes to the external repositories. Our proxies are also connected to a few different external repositories in case there is an outage on some of them.
Setting up your local Maven
A Maven environment is configured via its settings.xml file. For our Maven users we have three types of settings.xml.
- Developer settings.xml is configured to use the internal part of the proxy as its central repository.
- DevNet settings.xml is configured for the public part.
- We also ship the DevNet settings above to our customers.
The first two files have to be configured with your username and password if you are going to deploy any artifacts to our repositories. Customers use the repositories for building our products only and normally do not have usernames in our Crowd database.
Summary
The infrastructure I describe above achieves the following:
- Our builds will always be able to find all the dependencies they ever need because our proxies will keep the artifacts forever.
- We do not directly depend on external repositories which makes our builds a lot more robust.
- For the Sydney team (where the majority of our developers are), access to a repository is significantly faster since we have a local proxy.
- There is one set of settings our developers have to maintain in their local environment regardless of whether they are in the office or outside.
- We are less affected by the quirks of the external libraries (legal issues, missing artifacts, etc.)
.. to be continued
Part 3 will describe you how our projects (all of those libraries I talked about) are configured to make their builds deterministic and repeatable.
Unfortunately, even after several years, our Maven infrastructure is not perfect. Part 4 will cover issues we hit every now and again and explain how we deal with them.


7 Comment(s)
More please! The practical use of Maven in a development shop that has their act together...this is gold.
By Thad at February 26, 2008 1:45 PM
Something weird happened on this blog. It seems like it's posted twice in the same page, at least to me.
Anyhow, as Thad says, this is excellent stuff, keep it up!
By Viktor Nordling at March 3, 2008 4:29 AM
Viktor,
indeed something weird. The blog content was duplicated on the page. I tend to blame the software but inside suspect a copy-paste error on my part (how did I miss it while checking it, no idea). The thing I find sad is that I was not notified of your comment and completely missed it.
I have fixed the post up now.
Thanks a bunch for the vote of confidence by the way.
cheers,
sherali
By Sherali Karimov, X-Team Lead at March 19, 2008 4:42 AM
Hello,
I've read with a great interest your series of articles on 'Maven in our development process'.
I would like to ask you some questions.
Which IDE and SCM do you use or recommend to use? Eclipse or NetBeans or ..., Subversion or CVS or ...?
Where do you store your source code? Whithin the SCM tool or directly into one of the Maven's Repositories?
Which SCM's Maven plugin do you use?
Do you perform checkout and checkin operations directly from your IDE to the SCM repository or to the Maven repository? If this is to the Maven Repository how do you synchronize your Maven repository and the SCM one?
Which IDE's plugin do you use for Maven?
Thank you in advance.
Cheers,
Philippe
By Philippe Waltregny-Dengis at March 24, 2008 5:02 PM
Philippe,
you are asking one of those questions that start religious IDE/text editor/etc. wars
My personal opinion is there isn't such a thing as 'perfect tool'.
- Some of us use Eclipse and some use IDEA. Everyone is happy with their choice.
- We use SVN for source control but I can't say that I would strongly recommend it over other SCMs.
- We store our code in SVN. This is what it is for. We do deploy our sources to Maven but only for the sake of easy access when you are debugging or bvrowsing code in your IDE and you want to go deeper into your dependencies. Maven repository isn't an SCM.
- Different people have different habits. Some checkout and build from within the IDE and some from the command line. Again it is a matter of preferences and again everyone is fairly happy with their choice.
An important message here, pertaining to the article, is that Maven isn't a tool that should be used to replace all tools in your development environment. Maven is a process that binds your tools together.
While picking your tools, you need to consider your requirements and your preferences.
While setting up Maven, you need to make sure you understand the process.
hope this helps,
sherali
By Sherali Karimov, X-Team Lead at March 24, 2008 7:01 PM
Sherali,
Thanks for the great series. We're facing a lot of the same issues within JBoss, and seeing how you have things set up has given us some good ideas.
How do you handle changes within the repository? Do you restrict repository access so that developers cannot delete artifacts? Also, do you use any tool to fix missing or bad metadata in your repositories?
Thanks!
By Paul Gier at June 2, 2008 10:39 AM
Paul,
I am glad you found it useful.
As for access rights for the developers and bad metadata, we never really had a need for either case. We had to delete a few artifacts in the past, but that was legitimate and our build and release engineer, James, did that.
I would imagine you could configure your repository only to support WebDAV access and disable deleting support in your dav configuration. Coupled with restricted SSH access to the box that should do the trick.
I am not aware of tools that would allow you to correct metadata automatically. James has written some tools in Python in the past to sort through the metadata in house.
cheers,
sherali
By Sherali Karimov, X-Team Lead at June 2, 2008 4:51 PM