Maven (11) - Standard Directory Structure
Maven (11) - Standard Directory Structure

Maven (11) - Standard Directory Structure

in

Having a standard directory structure provides Maven project users with a sense of familiarity when transitioning from one project to another. This practice is akin to adopting a consistent look and feel across websites.

The following section outlines the expected directory layout by Maven and the layout Maven creates. It’s advisable to adhere to this structure as closely as possible. If not feasible, these settings can be overridden through project descriptors.

Directory Description
src/main/java Application/Library source code
src/main/resources Application/Library resources
src/main/filters Resource filter files
src/main/webapp Web application source code
src/test/java Test source code
src/test/resources Test resources
src/test/filters Test resource filter files
src/it Integration tests (primarily for plugins)
src/assembly Assembly descriptors
src/site Website
LICENSE.txt Project license
NOTICE.txt Notice and attributions for dependencies
README.txt Project readme

At the top level are files describing the project: the pom.xml file. Additionally, there are text files like README.txt, LICENSE.txt, etc., for users to read upon receiving the source code.

This structure consists of only two subdirectories: src and target. The only other directories needed here are metadata such as CVS, .git, or .svn, and any subprojects in multi-project builds (each subproject follows the layout above).

The target directory is used to store all outputs from the build process.

The src directory contains all source materials for building the project, website, etc. Each type has a subdirectory: main for primary build artifacts, test for unit test code and resources, site, etc.

Within the build artifacts directories (main and test), there’s a directory for java language (with a regular package hierarchy underneath) and one for resources (structured to be copied to the target classpath per default resource definitions).

If there are other contributions to the build process, they reside in additional subdirectories. For example, src/main/antlr contains Antlr grammar definition files.