拥有一个通用的目录布局可以让开发人员在不同的Maven项目中都产生一种熟悉的感觉.接下来的内容记载了Maven期望的目录布局,而Maven本身创建的结构也是这样的.请尽可能的符合这个结构.然而,不过你不能这么做,这些设置也是可以被不同的项目描述重写的.
src/main/java | Application/Library sources |
src/main/resources | Application/Library resources |
src/main/resources-filtered | Application/Library resources which are filtered. (Starting with Maven 3.4.0, not yet released.) |
src/main/filters | Resource filter files |
src/main/webapp | Web application sources |
src/test/java | Test sources |
src/test/resources | Test resources |
src/test/resources-filtered | Test resources which are filtered by default. (Starting with Maven 3.4.0, not yet released.) |
src/test/filters | Test resource filter files |
src/it | Integration Tests (primarily for plugins) |
src/assembly | Assembly descriptors |
src/site | Site |
LICENSE.txt | Project's license |
NOTICE.txt | Notices and attributions required by libraries that the project depends on |
README.txt | Project's readme |
在项目文件描述的最顶层:除了有pom.xml之外,还有一些可以被用户直接阅读的文本文档,如: README.txt , LICENSE.txt 等.
在这个结构中只有两个子目录:src和target.除此之外只希望存在的其他目录是元数据(像:CVS,.git或.svn)和一个子项目目录(每个子项目本身的结构又和上面所描述的一样).
target目录用来存放所有的构建输出.
src目录则包含所有用于构建项目及它的站点等等的原材料.它为每种类型提供了一个子目录:main对应主要构建工件,test对应单元测试代码和资源,还有site等等.
在工件产生源目录(如main和test)下,这里有个jave语言目录(存在常见的包层级结构)和resources目录(这里面的内容会被拷贝到默认资源定义指定的目标类路径classpath下)
如果这里还有其他为构建项目作出贡献的来源,它们将被放置在其他子目录:如src/main/antlr应该包含Antlr语法定义文件.