MAVEN项目标准目录结构 ;
http://blog.csdn.net/lengyue_wy/article/details/6718637
版權(quán)聲明:本文為博主原創(chuàng)文章,未經(jīng)博主允許不得轉(zhuǎn)載。
1.標(biāo)準(zhǔn)目錄結(jié)構(gòu):src
? -main ????? –bin 腳本庫(kù) ????? –java java源代碼文件 ????? –resources 資源庫(kù),會(huì)自動(dòng)復(fù)制到classes目錄里 ????? –filters 資源過濾文件 ????? –assembly 組件的描述配置(如何打包) ????? –config 配置文件 ????? – webapp web應(yīng)用的目錄。WEB-INF、css、js等 ? -test ????? –java 單元測(cè)試java源代碼文件 ????? –resources 測(cè)試需要用的資源庫(kù) ????? –filters 測(cè)試資源過濾庫(kù) ? -site Site(一些文檔) target LICENSE.txt Project’s license README.txt Project’s readme工程根目錄下就只有src和target兩個(gè)目錄
target是有存放項(xiàng)目構(gòu)建后的文件和目錄,jar包、war包、編譯的class文件等。
target里的所有內(nèi)容都是maven構(gòu)建的時(shí)候生成的
參照:http://breath.iteye.com/blog/1005447
++++++++++++++++++++++++++++++++++++++++++++
Maven項(xiàng)目的標(biāo)準(zhǔn)目錄介紹
?
Maven提倡使用一個(gè)共同的標(biāo)準(zhǔn)目錄結(jié)構(gòu),使開發(fā)人員能在熟悉了一個(gè)Maven工程后,對(duì)其他的Maven工程也能清晰了解。這樣做也省去了很多設(shè)置的麻煩。
以下的文檔介紹是Maven希望的目錄結(jié)構(gòu),并且也是目錄創(chuàng)建工程是采用的目錄結(jié)構(gòu)。Maven推薦大家盡可能的遵守這樣的目錄結(jié)構(gòu)。
| 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 |
在頂級(jí)目錄上是工程的描述文件pom.xml(如果使用Ant則還包括其他屬性文件,maven.xml或build.xml),另外還包括提供給最終用戶的文件,如,README.txt,LICENSE.txt等等。
?
頂級(jí)目錄還包括兩個(gè)子目錄:src,target。頂級(jí)目錄下可能出現(xiàn)的其他目錄僅僅是CVS或.svn和其他多模塊工程的工程目錄,最好不要再有其他目錄。
?
Target目錄是所有工程編譯構(gòu)建的輸出目錄。
?
Src目錄包含所有工程的源碼文件,配置文件,資源文件等等。它下面的子目錄一般包含main(主要的工程源文件),test(測(cè)試文件),site(項(xiàng)目站點(diǎn)文件)。
?
項(xiàng)目構(gòu)建的生命周期的介紹
?
Maven 2是圍繞著構(gòu)建生命周期概念設(shè)計(jì)的。這意味著,構(gòu)建或者發(fā)布的過程已經(jīng)被清晰的定義了。
當(dāng)我們使用Maven構(gòu)建工程時(shí),我們只需要了解幾個(gè)Maven定義好的命令即可,其他的工作則交給POM來完成。
以下給出Maven提供的構(gòu)建生命周期列表:
| 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. |
因此,當(dāng)我們構(gòu)建一個(gè)項(xiàng)目時(shí),只需要了解自己希望做什么,然后執(zhí)行以上對(duì)應(yīng)的生命周期即可。
?
例如,我們希望編譯我們的工程。在命令行狀態(tài)下進(jìn)入到工程的pom.xml文件所在的目錄中,使用命令:mvn compile;希望構(gòu)建打包我們的工程,使用mvn package即可。
?
當(dāng)然了,maven的構(gòu)建生命周期也是可以擴(kuò)展和自定義的,這里就先不做介紹了。
?
參照:http://hi.baidu.com/mylovechangchu/blog/item/fbda36da3644a6dfb6fd48d6.html
+++++++++++++++++++++++++++++++
APACHE原址:http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
轉(zhuǎn)載于:https://www.cnblogs.com/linbo3168/p/6541250.html
總結(jié)
以上是生活随笔為你收集整理的MAVEN项目标准目录结构 ;的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [转]Linux系统下yum和apt-g
- 下一篇: 紫书搜索 例题7-10 UVA - 11