Tuesday, May 5, 2009

The Ultimate Enterprise Java Build Solution

Early in my career I took on the role of setting up and operating the build infrastructure of many of the projects I have consulted on. I started in this role before Apache Ant released its 1.0 version. I have struggled with using Cruise Control as my continuous integration server including lava lamps for broken builds. Finally, I have also used and configured just about every code quality tool for Java and built a dashboard to try to combind all the results.

Now after all these years, I think I found the right solutions for Enterprise Java Builds. The solution involves 5 open source projects: Maven, Subversion, Hudson, Nexus, Sonar.

At the core of the solutions is Apache Maven, a build, project, dependency management framework. Maven makes it easy to declaratively describe a project or collection of projects that generate artifacts like binary jars, source jars, doc jars, dependency lists and other artifacts. All these artifacts can be versioned to ensure all developers are using the right artifacts. These artifacts can also be published to a Maven repository making distribution of the artifacts seamless.

In order for developers to collectively own code and integrate often, a source code repository is necessary. Subversion has been a proven enterprise scale repository which integrates well with may tools like Eclipse, Hudson and Maven. But there are many other quality source code repositories that could fit in Subversion's place such as Git. The exact source code repository for this solutions is not as important as having one and having one that integrates well with the choosen tools.

One of the biggest challenges in developing software with a team of people is integrating the software so the practice of continiously integrating has become a staple in many enterprises. After every developer check-in, a continious integration server will check the code out, compile and run all the unit tests. Hudson is possibly the easiest and most powerful continious integration server available for Java. It has a very simple web console that makes creating and configuring build jobs a cinch especially Maven jobs. Just incase that is not enough, it has a very nice plug-in system and community making it very flexible and robust.

After Hudson builds artifacts (jars) that developers need it must publish them to a Maven repository hosted within the enterprise. Nexus is that Maven repository. It enables you to publish both release and snapshot artifacts, provides different views into the respository and includes searching for artifacts even their contents. In addition, it can act as a proxy to external public Maven repository providing traceablity into where artifacts came from as well as improve download performance. Both developers and Hudson can use Nexus to keep their local artifacts up to date providing continious integration for everybody all the time.

Finally, it is valuable to keep metrics about code quality. This can help show if code is improving or declining. This can help easily identify problems, risky areas and bad pratices. Sonar is a server that provides a dashboard into your code quality. It integrates with many common code quality tools like PMD, Checkstyle and FindBugs. It include metrics for code coverage, unit testing and lines of code. The trending capabilities make it easy to identify patterns.


SoftGUI said...

Ultimate would be to add a server running TeamCity for the 'remote run' and 'pre-tested commit' features (as Developer assistant, and continuous compilation server it is a great add-on for a CI system)

Jamie Whitehouse said...

I've pretty much settled on this as well with the exception of using a DVCS instead of Subversion.

Chose a DVCS since it can handle branchy development much more adequately and makes offline commits for developers possible.

Jetlag said...

We are close to that at my company, though we have recently ditched svn for git (I believe prematurely).

Christopher M Judd said...

Thanks for pointing out my grammar mistake.

José Díaz Díaz said...

What bug tracker should I use in it continuous system integration? What do you recommend?

Christopher M Judd said...

Trac (http://trac.edgewall.org/) is a very nice open source defect tracker.

Vinod Singh said...

Including Redmine will make a perfect project management tool.

emmimiusic said...

Hi Christopher, your post is very interesting.
If i want to develop in an environment like the discribed above
Wich are the hardware requirements?
I mean:
·Where does Hudson, Nexus, Subversion and Sonar reside in 4 diferents machines or Hundon, Nexus and Sonar in 1 machine and Subversion in other?
· Is there some security restriction?
· What do you recommend?

Appreciate your help

Christopher M Judd said...


As every good consultant should say that depends. If you have a decent server class box and only a couple projects and jobs you can run all this on one box. However, the more projects, jobs, frequency and project/build complexity the more boxes you will need. I would recommend putting SVN on its own server as developers will be interacting with it and you don't want some build to prevent a developer from updating or commiting code at a crucial time in the project.

If you want to experiment without a large investment, I have had several people mention to me they have experimented with this configuration on EC2.

samuel said...

Hi I am new here. Do one need subversion while it already using maven?

Arcángel said...

I use this configuration:

* Maven
* Artifactory
* Redmine
* Mercurial
* Sonar
* OpenLdap
* Eclipse

The Ultimate Enterprise Java Build Solution Revisited

In May of 2009, I wrote the blog post The Ultimate Enterprise Java Build Solution . Over the past 7 years since I wrote the post I have help...