The basic concept of Maven is a project. A project can create only one artifact. E.g. a web project can create a war file as an artifact. To work around this restriction of one artifact per project, a project can have sub-projects. Each of the sub-projects can have a artificat by themselves. The project's responsibility now is to take the sub-project's artifacts and make one artifact.
A project is defined as any directory with a project.xml in it. If sub-directories of a project directory have project.xml then they are project directories too.
All project artifacts (artifacts resulting from projects) are stored in repositories. There are remote and local repositories. Local repository is created in ./maven/repository. In windows its "c:/Documents and Settings/
The structure of repository on a windows box:
c:/Documents and Settings/babu.subburathinam/maven/repository/commons-loggging/jars/commons-logging-1.0.7.jar
Instead of each project having a copy of its dependencies, all libraries are lodged in a repository and all projects share the libraries available in the repository. Each project will inturn publish its artifact on to the repository. This process of a project publishing its artifact is called "install"ing in maven lingo. This process of each project publishing its (snapshot and release) artifacts to a central repository helps in continuous integration. This is how: Daemon processes running in build servers can build each project with its updated dependencies several times a day, deploy and test the built artifacts. Thus, integration issues if any will surface much before the release date of a specific project.
Inputs to maven:
One of the input files to maven is Project Object Model (POM) file. This file describes the project to maven. This file has the following structure:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
Line 2 - Root element of XML
Line 3 - This tag is unused but needed.
Line 4 - A directory with this name is created in Maven repository to hold the artifacts of projects sharing the group id.
Line 5,6 - The id and version is used to create the artifact name as
Line 7 - Name of the project
The project Management section has project information such as the organization, its web site, location of SCM (Software configuration management), deployment and issue tracking sites, developer lists, mailing lists, etc...Most of this section is optional. The contents of project.xml can be extended. Most of the content is defined at the enterprise level and each project can override what is appropriate to it.
An example of the project management section:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 ...
30 ...
31
32
33
34
35
36
37
38
39 ...
40 ...
41
* Lines 01-05 - Organization details
* Line 08 - Top level package for the project
* Line 09 - Project Logo
* Line 12 - Project web site
* Line 14 - The site where the project is hosted
* Line 15 - Physical location of project deployment
* Line 16 - Physical location where the project distributions are available
* Lines 18-21 - SCM to access the project source
* Lines 23-31 - Mailing list for the project
* Lines 33-41 - Developers in the project
General structure of a maven project:
Maven Project Root
- maven.xml // Project definition file
- src // source directory
-- conf // Configuration within source
---xyz.properties // config gile
--java // java source
---com
----access
-----dev
------Hello.java
- test // test directory
-- conf // test configuration
---abc.properties // test config file
--java // java test files
---com
----access
-----dev
------TestHello.java
Project dependency section
In this section the project indicates all the dependecies that it has on artifacts of other projects. An example:
01
02
03
04
05
06
Line 1 - Starts the dependencies
Line 3 - The artifact that this project depends on is at the directory named "BeanUtils" in the repository
Line 4,5 - The artifact name is "commons-beanutils-1.5.jar" (using
Project build section
This section indicates the location of source, test and resource files. This is defined at the org. level or main project level for sub-projects to follow. If this section is not specified, no build ever gets done. Once build is over, all unit tests specified in the unit test section are executed. The contents of this section should match the actual layout of the code in the filesystem.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
* Line 02 - Email address to send notification about the build status
* Line 03 - Folder containing the source files for the project. The source can be java, jsp and so on.
* Line 04 - Directory containing the unit test files for the project.
* Lines 05-09 - The test file name pattern to run after the build is completed
* Lines 11-19 - Resources to be copied in case a jar is created.
Project reports sections
Once build is done, reports and documentation about the build are generated.
e.g.
No comments:
Post a Comment