MAVEN Project Standard directory structure

Source: Internet
Author: User

Scenario: The work of the project is using MAVEN's directory structure, although the development work can be completed as scheduled, but not familiar with the configuration of a Maven project, here is mainly about the MAVEN project and directory structure.

1 Standard directory structure
src   -main      –bin script library      –java Java source code file      –resources Repository, automatically copied to classes directory      –filters resource filter file      –assembly The description of the component configuration (how to package)      the –config profile      –webapp The directory of the Web App. WEB-INF, CSS, JS,  etc. -test      –java Unit tests Java source code files      –resources test the required resource pool      –filters Test Resource Filter Library   -site site (some documents) TargetLICENSE.txt project's LicenseREADME.txt project's readme

Only SRC and target two directories are in the project root directory

Target is the file and directory where the project was built, the jar package, the war package, the compiled class file, and so on.

All of the content in target is generated when MAVEN builds.

Reference: http://breath.iteye.com/blog/1005447

++++++++++++++++++++++++++++++++++++++++++++

1.1 Maven Introduction to the standard catalogue of projects

MAVEN advocates the use of a common standard directory structure that enables developers to understand the other MAVEN projects once they are familiar with a MAVEN project. This also saves a lot of setup trouble.

The following document describes the directory structure that Maven expects, and is the directory structure in which the catalog creation project is based. MAVEN recommends that you adhere to this directory structure as much as possible.

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

In the top-level directory is the project description filePom.xml(If you useAntOther properties files are also included.Maven.xmlorBuild.xml),It also includes files that are provided to end users, such as README.txt,LICENSE.txt Wait a minute.

The top-level directory also includes two subdirectories: Src,target. Other directories that may appear in the top-level directory are simply CVS or. SVN and other multi-module engineering catalogs, preferably with no additional directories.

The target directory is the output directory for all project compilation builds.

The SRC directory contains all project source files, configuration files, resource files, and so on. The following subdirectory generally contains main (the main project source file), test (testing file), site (project site file).

1.2 Introduction to the life cycle of project construction

Maven 2 is designed around the concept of building a life cycle. This means that the process of building or publishing has been clearly defined.

When we use MAVEN to build a project, we just need to know a few MAVEN-defined commands, and other work is done by the POM.

The following is a list of the build lifecycles provided by Maven:

Validate

Validate the project is correct and all necessary information are 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 does 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 is packaged or deployed.

Package

Take the compiled code and the package it in its distributable format, such as a JAR.

Pre-integration-test

Perform actions required before integration tests is executed. This could involve things such as setting up the required environment.

Integration-test

Process and deploy the package if necessary to an environment where integration tests can be run.

Post-integration-test

Perform actions required after integration tests has been executed. This could including cleaning up the environment.

Verify

Run any checks to verify the package is valid and meets quality criteria.

Install

Install the package to the local repository, for use as a dependency in other projects locally.

Deploy

Done in a integration or release environment, copies the final package to the remote repository for sharing with other de Velopers and projects.

So when we build a project, we just need to know what we want to do, and then execute the corresponding life cycle.

For example, we want to compile our project. In the command line state to enter into the directory where the project's Pom.xml file is located, use the command: MVN compile; we want to build our project with the MVN package.

Of course, MAVEN's build lifecycle can be extended and customized, but not introduced here.

Reference: http://hi.baidu.com/mylovechangchu/blog/item/fbda36da3644a6dfb6fd48d6.html

Apache site: http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html

1.3 Maven Project Add new Folder

The newly created MAVEN project does not have a resources folder and needs to be created by itself.

The step is divided into two steps:

1. Create the Resources folder under the SRC Main and test directories

2, as shown in the add can

(GO) MAVEN Project Standard directory structure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.