Having a common directory layout allows users to be familiar with Maven project from one to another.
Maven defines a standard directory structure.
- src - main - java - resources - webapp - test - java - resources - target
src directory is the root directory of source code and test code.
main directory is the root directory for source code related
to the application itself, not test code.
test directory contains the test source code.
java directories under main and test contains the
Java code for the application itself which is under main and
the Java code for the tests which is under test.
resources directory contains
the resources needed by your project.
target directory is created by Maven.
It contains all the compiled classes, JAR files etc.
When executing the
mvn clean command,
Maven would clean the target directory.
webapp directory contains Java web application,
if the project is a web application.
webapp directory is the root directory of the web application.
The webapp directory contains the
If you follow the directory structure, you do not need to specify the directories of your source code, test code, resource files, etc. in your POM file.
Here are the most important directories:
|src/main/webapp||Web application sources|
|NOTICE.txt||Notices and attributions|
At the top of the project root there are pom.xml file and any properties, maven.xml.
In addition, there are text files for the user to read immediately on receiving the source: README.txt, LICENSE.txt, etc.
There are two subdirectories of this structure:
src directory contains all of the source
material for building the project, its site and so on.
It contains a subdirectory for each type:
main for the main build artifact,
test for the unit test code and
site and so on.
Within source directories,
there is one directory for the language java,
under which there are the normal package hierarchy,
and one for resources.
The resources under is copied to the target classpath.
If there are other contributing sources to the artifact build,
they would be under other subdirectories:
src/main/antlr would contain Antlr grammar definition files.