I recently had a short three-month stint on our server team. The server team works in Java and my prior Java experience included an applet that simulates broken glass and a JNI frond-end to some COM object. In other words zilch. I wasn't too worried about Java the language, since I read a lot about it and I have a good C# track record. However, the environment and the culture were very different than what I am used to (low-level C/C++). There is a lot of open source third-party code, lots of configuration files, and due to the distributed nature of the system it is not easy to perform isolated integration tests. You don't debug much in Java. You read log files and develop theories about your bugs. Consequently, I immediately volunteered to redo the build system in addition to my development tasks. Being the build guy is a great way to study a complicated software system.
The build system was a mix of ant scripts and makefiles. The system was comprised of multiple projects such a non-standard presentation tier (web tier) based on XMPP, EJB-based middle tier, and a database. In addition a panoply of satellite projects (various batch processes) were also part of the build. The middle tier was deployed on the not so prevalent JOnAS application server and the presentation tier was deployed on Apache Tomcat.
The build was far from perfect. There was no repeated one-click build, no automated testing, and deployment required manual copying of files and manual changes to various configuration files. Dependency management was pretty weak also. I studied the Java build scene and ascertained Ant is indeed the 800-pound gorilla. However I also read a lot of criticism about Ant and looked for alternatives. I finally homed in on Maven. Maven is more than a build systemit is "a software project management and comprehension tool" according to the Maven developers.
In this article, I concentrate on the build aspects of Maven. 2.0.2 (the current stable version). I introduce Maven through a web application that serves Sudoku puzzles. (The complete source code for the puzzle is available online.) The goal of a Sudoku puzzle is to populate a 9x9 grid made of nine 3x3 regions with the digits 1 through 9. Each row, column, and region should contain all 9 digits (so no repeats are allowed). You start with some populated cells and complete the rest (see Figure 1).