Showing posts with label maven. Show all posts
Showing posts with label maven. Show all posts

Thursday, March 12, 2015

Book Review for "Mastering Apache Maven 3"


There's been a 'build tool' war in the Java community for many years.  On one side are fans of Ant, the original Java script-and-build toolkit.  On the other side are users of Maven, a newer kit with an emphasis on dependency management and a predefined lifecycle.  The battle has been waged fiercely for quite a while.

It looks to me as if the Maven side has taken the upper hand.  I try to be pragmatic about such things, but must admit that I have had some difficult times with Maven.  For simple projects (based on examples from the internet, called archetypes) it's a great tool.  But Maven is a two-edged sword:  For every simple archetype I've benefited from, I've had a more complicated project that caused me some problem that required hours of research to solve or at least the rebuilding of my local repository.  Maven can be somewhat mysterious at inopportune times.

Maven also has a giant appetite for artifacts it pulls from the internet.  Pull any Maven-based open source project onto your machine some time and kick off a build cycle.  If it's any kind of project at all, you'll be horrified by the number or things Maven fetches from the internet.  (Ant most likely would have referred to a /lib directory that had everything cached for you.  But there are pros and cons to this.) 

Given this situation, I was delighted to lay hands on a copy of "Mastering Apache Maven 3" so I could learn more about this build monster.  I was not disappointed.

The book covers a lot of ground.  You are given knowledge of how the build cycle works and definitions for all the involved terminology ("Mojo", "plugin", "phase", "lifecycle", "assembly", etc.)  Different chapters are devoted to some of the things I always thought would be cool to understand:  Writing plugins, associating them with a given part of the build cycle, writing my own archetype, setting up a Nexus repository, etc. It turns out Maven is really a framework for running arbitrary code plugins-- cool!  Pretty much every question I had about Maven is at least touched upon in this book.  The author gives us decent examples of not only how to configure Maven, but also how to extend it.  I thought this was excellent.

If the book has a shortcoming, it would be that it's a little low on illustrations.   Reading page after page about a build tool (with accompanying configuration XML!) can be tedious.  Just a few stick drawings or sequence diagrams would have gone a long way towards helping the reader get immediate context about what is being discussed. That's about the only harsh criticism I have for this book.  For the most part, it's a very good book and will no doubt be one I'll reach for on occasion as I battle Maven in my day-to-day duties.

To summarize:
  • Who would I recommend this book for?  
    • Any enterprise Java developer.  
  • Is it a great book?  
    • It's not a page turner, but it's likely to be a treasured resource.  
  • Will it stay relevant for long?  
    • Given the length of the Ant/Maven battle, I'd guess a very long time.  
I consider this book a welcome addition to my tech library.

The book can be found here

Happy Building!

Saturday, April 21, 2012

Book Review: Apache Maven 3 Cookbook




Are you a long-time Ant fan being drawn into the world of Maven?  I am.  I like Ant and it's straight-line, totally transparent nature.  But I'm also pragmatic, and I think I can see the tide has turned.  Maven is now being used (almost required!) by a good many projects that I use daily.  It's high time I got on board.  So I picked up a copy of "Apache Maven 3 Cookbook" and started reading.

Like all Packt Cookbooks, this book follows a predictable format.  These books are meant to guide the reader directly through commonly encountered tasks.  You find an article title (i.e. "Integrating Scala development with Maven"), and under this heading you'll find a little text then the sections "Getting Ready", "How to Do It", and "How It Works".  There isn't  a lot of text spent explaining theory or history, it's mostly just how to accomplish a particular task.

The book starts out with the basics of Maven, which was useful for me.  Some of what I found in the first chapter I knew from previous dealings with Maven, some I thought I knew but wasn't sure, and some I hadn't seen before.  There are totally simple examples of how to set up Maven on various platforms.

The next few chapters cover the core of Maven's use cases.  Software engineering (complete with automated unit tests, code coverage reports, etc.) are explained here, as are the uses of Maven's dependency management system.  For those who are totally new to Maven, dependency management-- the automatic downloading and inclusion of libraries your project needs-- is probably the single best feature of Maven.

Hudson integration and various reports that can be generated are next.  The reports include JavaDocs, code coverage, and code quality, among others.

Some common Java development scenarios are covered next.  These include web applications, JEE apps, Spring, Hibernate and Seam.  Mostly what you are shown is use of an optimal archetype for each of these, then the expected directory structure after the project is generated.  There's also a little useful text about how to go about developing further in the chosen application type after that.

Chapter 6 is devoted to Google development with Maven.  Topics include Android development, GWT, and Google App Engine.

Chapter 7 explains Maven usage with Scala, Groovy, and Flex.

Chapter 8 explains using Maven with an IDE.  Eclipse, Netbeans, and IntelliJ are explained.

Finally, you are told how to extend Maven by making and documenting your own Maven plugins.

So, what's the final verdict?  This book was useful for me, as it explained many things about Maven I didn't previously know.  The book is formatted in such a way that it's task oriented, so it's a more comfortable read if you're coding as you're reading.  If you develop in some of the many use cases described above, you'll find some value in this book.

The book can be found here.

Happy assisted Software Engineering!