Friday, December 16, 2011

Java Project Layout - Best Practices

Simple Project
  • project-name
    • trunk
      • src...
      • pom.xml
    • branches
      • branch-abc
        • src...
        • pom.xml
    • tags...

 Multi-Module Project
  • project-name 
    • project-name-parent
      • pom.xml - defines all modules that are part of the project
    • module 1 
      • trunk
        • src...
        • pom.xml - points to the parent pom.xml
      • branches
      • tags
    • module 2
      • trunk
        • src...
        • pom.xml - points to the parent pom.xml
      • branches
      • tags
    • module ...
 The key point is that the parent folder doesn't define the parent project, but is just a container for the parent and the children-modules.

Advantages:
  • Nicely groups the modules under one folder.
  • Allows to build the whole project by calling "mvn clean install" from parent's folder.
  • Keeps the SVN (and/or Git) operations simple, unlike the layout where the project-name-parent is the parent folder.

    No comments: