MAVEN項目標準目錄結構

1.標準目錄結構:css

src -main –bin 腳本庫 –java java源代碼文件 –resources 資源庫,會自動複製到classes目錄裏 –filters 資源過濾文件 –assembly 組件的描述配置(如何打包) –config 配置文件 –webapp web應用的目錄。WEB-INF、css、js等 -test –java 單元測試java源代碼文件 –resources 測試須要用的資源庫 –filters 測試資源過濾庫 -site Site(一些文檔) target LICENSE.txt Project’s license README.txt Project’s readmejava

工程根目錄下就只有src和target兩個目錄web

target是有存放項目構建後的文件和目錄,jar包、war包、編譯的class文件等。app

target裏的全部內容都是maven構建的時候生成的 參照:http://breath.iteye.com/blog/1005447 ++++++++++++++++++++++++++++++++++++++++++++ Maven項目的標準目錄介紹webapp

Maven提倡使用一個共同的標準目錄結構,使開發人員能在熟悉了一個Maven工程後,對其餘的Maven工程也能清晰瞭解。這樣作也省去了不少設置的麻煩。 如下的文檔介紹是Maven但願的目錄結構,而且也是目錄建立工程是採用的目錄結構。Maven推薦你們儘量的遵照這樣的目錄結構。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(項目站點文件)。svn

項目構建的生命週期的介紹post

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. 所以,當咱們構建一個項目時,只須要了解本身但願作什麼,而後執行以上對應的生命週期便可。 例如,咱們但願編譯咱們的工程。在命令行狀態下進入到工程的pom.xml文件所在的目錄中,使用命令:mvn compile;但願構建打包咱們的工程,使用mvn package便可。 固然了,maven的構建生命週期也是能夠擴展和自定義的,這裏就先不作介紹了。單元測試

相關文章
相關標籤/搜索