-
Maven项目的标准目录介绍
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/webapps |
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 |
在顶级目录上是工程的描述文件pom.xml(如果使用Ant则还包括其他属性文件,maven.xml或build.xml),另外还包括提供给最终用户的文件,如,README.txt, LICENSE.txt等等。
顶级目录还包括两个子目录:src,target。顶级目录下可能出现的其他目录仅仅是CVS或.svn和其他多模块工程的工程目录,最好不要再有其他目录。
Target目录是所有工程编译构建的输出目录。
Src目录包含所有工程的源码文件,配置文件,资源文件等等。它下面的子目录一般包含main(主要的工程源文件),test(测试文件),site(项目站点文件)。
-
项目构建的生命周期的介绍
Maven 2是围绕着构建生命周期概念设计的。这意味着,构建或者发布的过程已经被清晰的定义了。
当我们使用Maven构建工程时,我们只需要了解几个Maven定义好的命令即可,其他的工作则交给POM来完成。
以下给出Maven提供的构建生命周期列表:
validate |
validate the project is correct and all necessary information is available. |
generate-sources |
generate any source code for inclusion in compilation. |
process-sources |
process the source code, for example to filter any values. |
generate-resources |
generate resources for inclusion in the package. |
process-resources |
copy and process the resources into the destination directory, ready for packaging. |
compile |
compile the source code of the project. |
process-classes |
post-process the generated files from compilation, for example to do bytecode enhancement on Java classes. |
generate-test-sources |
generate any test source code for inclusion in compilation. |
process-test-sources |
process the test source code, for example to filter any values. |
generate-test-resources |
create resources for testing. |
process-test-resources |
copy and process the resources into the test destination directory. |
test-compile |
compile the test source code into the test destination directory |
test |
run tests using a suitable unit testing framework. These tests should not require the code be packaged or deployed. |
package |
take the compiled code and package it in its distributable format, such as a JAR. |
pre-integration-test |
perform actions required before integration tests are executed. This may involve things such as setting up the required environment. |
integration-test |
process and deploy the package if necessary into an environment where integration tests can be run. |
post-integration-test |
perform actions required after integration tests have been executed. This may including cleaning up the environment. |
verify |
run any checks to verify the package is valid and meets quality criteria. |
install |
install the package into the local repository, for use as a dependency in other projects locally. |
deploy |
done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects. |