Apache Maven 2 Effective Implementation - book review
This is a review of "Apache Maven 2 Effective Implementation" book by Brett Porter and Maria Odea Ching (Packt Publishing, 2009)
I have been using Maven 2 for more than 3 years on daily basis, and I already know a great deal about it. This book gave me a great chance to revise my Maven 2 knowledge, and get familiar with the recent changes. Although a big part of it was for me just a repetition and strengthening of well known information, at least three sections - best practices, useful plugins and release process - have significantly helped me to be use Maven 2 more effectively.
The book is divided into 12 chapters and is based on one long example, running through all of them (you can download the source code for each chapter from Packt website). It also includes 3 really interesting appendices - concise, and packed to the brim with useful information. The content of the book can be roughly divided into two parts - one devoted to Maven 2 itself, and the other that presents other tools (i.e. Archiva, Continuum) and their cooperation.
Maven 2 part
The book starts with introduction to Maven 2. I guess it is very hard to introduce such a complex tool. I was not all happy with the way they did it. I had a feeling that the authors could not decide, what is the target audience of the book. Sometimes basic stuff is explained, and sometimes they assumed that the reader is already familiar with some terms and ideas from Maven world. Anyway, all main concepts of Maven are presented, and reader is ready to dive into more complex topics.
What I really missed in the introductory chapters are good diagrams to present some concepts. For example, a diagram presenting how the artifacts are uploaded and downloaded from artifact repository, or a diagram/table that would explain interaction between lifecycles, phases and goals, would be more than welcomed.
Later on things got much more interesting. The focus shifts to real-life, multi-module projects. It starts with the creation of parent POM and submodules, followed by the estabilishing of dependencies between modules. Next, creation of non-code (documentation) modules is described, along with the description of creation of custom site skin. Lastly, distribution of application is discussed, illustrated with the examples of usage of App Assembler and Assembly plugins.
The picture of Maven 2 would not be complete, without the archetypes, which are also described, including the development of custom ones.
tests & quality
As a team lead, I deal with the tasks of "code quality checking" (in broad sense) on a daily basis, so I was really interested in the chapters devoted to running tests, measuring code coverage, generating reports and checking code quality.
The authors concentrated on integration tests - i.e. web application testing with Selenium. This is a huge topic, so naturally only a part of real-life testing scenarios is covered in the book. I think this is a very good introduction (and even more than this) to running integration tests with Maven. And even though you won't find answers to all your questions here, at least you will find valuable pointers to the projects that will help you (e.g. Cargo).
The part on code coverage is also good and interesting. The book presents Emma, but if you use other tool, don't worry - the information included in this section will be valid and useful for you also.
I have mixed feelings about the general remarks on testing and code coverage, that I found in the book. In general I agree with what is written, but at the same time, I think I read few articles that discussed these matters slightly better. So if you are new to integration testing and code coverage, I would encourage you to find some other introductory materials. But if you already know the backgrounds, grab the book and learn "how to do it using Maven 2".
A lot of useful plugins are presented. Reporting and Checks chapter presents configuration and deployment of Maven site, and various reporting plugins (Javadocs, Checkstyle, PMD, Findbugs, Clirr and Emma). It shows how to generate reports and enforce quality by using checks. Very valuable information, especially if you are not familiar with the reporting and quality checking capabilities of Maven.
Next, 6 other plugins are presented - I bet you haven't heard about the half of them ! For each plugin an example is provided, that helps to understand its potential usage. Good stuff !
What surprised me, was the lack of "how to write custom plugins" section. This topic is barely mentioned, and you won't be able to learn it from the book. Also, no word on Bundle plugin, which is a hot topic nowadays.
Maven 2 is a complex tool, and you need to understand the "philosophy" behind it, to be able to use it effectively. Maven Best Practices chapter describes a lot of techniques that are in accordance with Maven's philosophy. It starts with a great explanation on how to make good use of various
settings.xml files. Then it presents the topic of repository access, "convention over configuration", inheritance of POMs, decomposition of project into modules, exclusion of dependencies, role of custom archetypes, profiles and many more. Really, if you are serious about improving you knowledge of Maven, you should read this chapter carefully !
When I thought I have finished with reading, I bumped into the appendices. Two of them are just great. Troubleshooting Maven - explains nicely the common pitfalls and presents ways of getting out of troubles. Recent Maven Features - was like a birthday gift for me ! I ended my Maven education on version 2.0.9, and this appendix introduced me to the changes that happened right after this version.
What I also expected to find in the book, are some hints on effective Maven usage with popular IDEs. Unfortunately, there is nothing about it. No word on which tool to use for working with POM's, nothing about m2eclipse plugin, and no advices on how to import a multi-module project into your IDE. :(
Archiva, Continuum and integration part
I use Maven with Nexus and Hudson, so the chapters presenting Archiva and Continuum (and also other tools) were not so interesting to me. Even though, I read them carefully, and my feeling is, that with this book in hand, you will be able to:
- install the tools,
- configure them,
- set roles/privileges (including connection with LDAP using Redback project),
- make them work together (including cooperation with SCM),
and proceed with everyday operations with ease. You will also learn about some more advanced options offered by these tools - e.g. parallel and distributed build with Continuum, or accessing Archiva and Continuum via web services API.
About 20% of the book is strictly related to Archiva and Continuum, but even there many valuable general comments can be found, so these parts are also worth reading, even if you are not interested in these particular tools. For example, introduction to Archiva, contains a very good explanation of:
- reasons for having a repository manager,
- role of proxy repositories,
- necessity of separation proxy/deployment repositories (and release/snapshot as well).
You can also learn a lot about the various files used by Maven - maven-metadata.xml file, settings.xml (
The real gem hidden in one of Archiva-related chapters is a section devoted to Maven release process, with detailed description on what happens before and during the release. You just can't miss it. This knowledge is absolutely crucial if you want to build and/or use effectively a complete CI solution.
In short, the book is very good. Based on real-life examples, aimed at the enterprise usage of Maven, full of code snippets, written by people involved in the development of Maven, Archiva and Continuum. By reading this book you will get not only a technical knowledge, but also deeper understanding of Maven philosophy.
I would recommended it especially for people who have some experience with Maven. I really think it is a must-have, if you plan to introduce Continuous Integration to your development environment, and you have no experiences with this topic. If CI and artifact repository are already your best friends, then you will find a good overall picture of the issues related to this, and probably many interesting tips. Some sections - especially two of them: best practices and release process - are simply invaluable, no matter how experienced you are and how mature your development environment is.
And if you haven't used Maven 2 yet... Well, I have mixed feelings. On the one hand, I am afraid that the learning curve of this book might be too steep, and probably some other books/tutorials would be better suited to introduce you to Maven 2. On the other hand, the lecture of this book gives you great insight into the real-life issues, and reading it now, might help you to choose the right paths from the very beginning. But since at some point in time (when you start to introduce CI), you will greatly benefit from this book, you can as well buy it now. :)