-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmaven_docs.txt
163 lines (113 loc) · 2.99 KB
/
maven_docs.txt
1
2
3
4
5
6
7
8
9
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
Build Life Cycle
POM
Transitive Dependencies
Exclusion of Dependencies
Build Life Cycle
- process of building and distributing a particular artifact(project)
- build lifecycles is madeup of phases
Phase
- it is represented as a stage in lifecycle
validate
compile
test
package
verify
install
deploy
3 built-in build life cycle
- default - handles project deployement
- clean - handles project cleaning
- site - handles the creation of your project's website
default
- validate
- initialize
- compile
- test-compile
- test
- package
- verify
- install
- deploy
clean
- pre-clean
- clean
- post-clean
site
- pre-site
- site
- post-site
- site deploy
Build phase is made up of plugins goals
mvn clean dependency:copy-dependencies package
clean and package are build phases
dependency:copy-dependencies is a goal of a plugin
Phase plugin:goal
-------------------------------------------
compile compiler:compile
test surefire:test
package jar:jar, ear:ear, war:war
install install:install
deploy deploy:deploy
Plugins
- plugins are artifacts that provide goals to Maven
- a plugin can have one or more goals,
example compiler plugin has 2 goals : compile and testcompile
POM - Project Object Model
- fundamental unit of work in Maven
- It's an XML file that contains information about the project and configuration details used by maven to build the project
- When we execute a task or a goal, Maven looks for POM in current directory
Super POM
- Super POM is the Maven's default POM
Minimal requirement for POM
- project - root
- modelVersion - generally set to 4.0.0
- groupId - id of the project's group
- artifactId - id of the project
- version - version of the artifact under specified group
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.org.app</groupId>
<artifactId>app-name</artifact>
<version>1</version>
</project>
fully qualified artifact name will be :
com.org.app:app-name:1
Project Inheritance
- elements in POM are merged
- dependencies
- developers and contributors
- plugins list
- plugins execution
- plugin configuration
- resources
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.org.app</groupId>
<artifactId>app-name</artifact>
<version>1</version>
</parent>
<artifactId>app-module-name</artifact>
</project>
All about POM.xml
POM.xml is divided into 4 parts
- Basics
- Build Settings
- More Project Information
- Environment Settings
Basics
- it is the declarative manifestation of "who", "what" and "where"
Maven Coodinates
- groupId
- artifactId
- version
Packaging - jar, war, rar, ejb, ear, maven-plugin, pom
<packaging>war</packaging>
Dependencies
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>