maven-2directory-structurefilestructure

How does the maven file structure work?


We are planning on restructuring a complex project with many modules/pieces, what ever you wanna call it. In order to move toward a standard directory structure, we would like to adopt the maven file structure.

So the big question is: Can anybody provide a description of the maven file structure, where we don't have to dig through all the maven speak?


Solution

  • Please see http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html

    src/main/java      Application/Library sources
    src/main/resources   Application/Library resources
    src/main/filters    Resource filter files
    src/main/assembly    Assembly descriptors
    src/main/config      Configuration files
    src/main/webapp      Web application sources
    src/test/java      Test sources
    src/test/resources   Test resources
    src/test/filters     Test resource filter files
    src/site            Site
    LICENSE.txt          Project's license
    README.txt        Project's readme
    

    BTW, we did that migration on existing projects. It was a really long and hard task to make everything work as intended, but we are finally done and happy with it.


    UPDATED

    When you have many projects, you have the same structure for each project.

    Now the real problem starts when you want to group them. We had a hard time reading Maven documentation and best-practices, and deciding what was the appropriate structure for us.

    The basic idea would be to group related projects in a common directory (that we call a module), allowing to process the module as a whole without listing them. But if you open the module in an IDE (Eclipse in our case), the projects themselves belong to it, but are not opened as subprojects (that notion doesn't exist in Eclipse).

    We ended up with a strict hierarchy, that freed us from many maven problems: