views:

489

answers:

3

Hello everyone, Maven is very impressive tool, I've used it for few weeks now and almost every day I learn something new about maven. What do you think are the best practices? I found this relevant on the google http://www.sonatype.com/people/2009/01/maven-continuous-integration-best-practices/ , others are not relevant at all, and maven apache documentation is not good organized so its hard to pick up on things if you don't know what you are looking for. Any suggestions ?

+8  A: 

I recommend reading book Apache Maven 2 Effective implementation by Brett Porter and Maria Odea Ching which contain chapter "Best practices". Here is table of contents of this chapter that gives an overview of practises proposed by authors.

Chapter 7: Maven Best Practices
    Preparing the development environment
          Maven installation and user settings
              Encrypting server passwords
          Project settings
          Configuring repositories
    Keeping it simple
          Using conventions
          Using inheritance
          Decomposing the build into modules
              Aligning the source structure
              Selecting group and artifact identifiers
              Building modules together
              Each module should be independently useful
              Watching the dependencies
              Separating API from implementation
          Trimming dependencies
          Dependency version management
          Profiles and pipelining
          Scripting and writing plugins
          Creating and using archetypes
   Build portability
          Setting expectations
          Hard coding
          Portable profiles
          Portable artifacts
          Resource filtering
          Shared resources
          Build reproducibility
cetnar
+1 Looks like a nice chapter (didn't read this book).
Pascal Thivent
thanks for the plug :) Some of this content is also available in the corresponding presentations: http://brettporter.wordpress.com/2007/11/16/apachecon-talk-slides-online/ and http://brettporter.wordpress.com/2008/11/06/maven-best-practices-slides-from-apachecon-us/
Brett Porter
@Brett No problem. BTW great book.
cetnar
@Brett Nice slides!
Pascal Thivent
+4  A: 

Of course, @cetnar's answer is more exhaustive but if I had to give one best practice it would be:

Don't fight against Maven, you'll loose. So, follow and use its conventions, adopt its philosophy, use it the way it works. If Maven doesn't work the way YOU want, don't use it.

Pascal Thivent
A: 

One of the good finds I did recently was on the sonatype - books site. There are some very good free online books about Maven, Nexus and Maven2-plug-in for Eclipse. Available online or downloadable as PDF.

Verhagen
c0mrade