-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
index.apt
219 lines (170 loc) · 11.8 KB
/
index.apt
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
~~ Licensed to the Apache Software Foundation (ASF) under one
~~ or more contributor license agreements. See the NOTICE file
~~ distributed with this work for additional information
~~ regarding copyright ownership. The ASF licenses this file
~~ to you under the Apache License, Version 2.0 (the
~~ "License"); you may not use this file except in compliance
~~ with the License. You may obtain a copy of the License at
~~
~~ http://www.apache.org/licenses/LICENSE-2.0
~~
~~ Unless required by applicable law or agreed to in writing,
~~ software distributed under the License is distributed on an
~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~~ KIND, either express or implied. See the License for the
~~ specific language governing permissions and limitations
~~ under the License.
-----
Introduction
-----
Hervé Boutemy
-----
2013-03-19
-----
Maven Model Builder
The effective model builder, with profile activation, inheritance, interpolation, ...
The main component is <<<ModelBuilder>>>
({{{./apidocs/org/apache/maven/model/building/ModelBuilder.html}javadoc}},
{{{./xref/org/apache/maven/model/building/ModelBuilder.html}source}}),
with its <<<DefaultModelBuilder>>> implementation
({{{./apidocs/org/apache/maven/model/building/DefaultModelBuilder.html}javadoc}},
{{{./xref/org/apache/maven/model/building/DefaultModelBuilder.html}source}})
that manages the steps sequence.
The sequence is divided into 2 phases:
* phase 1
** profile activation: see {{{./apidocs/org/apache/maven/model/profile/activation/package-summary.html}available activators}}.
Notice that model interpolation hasn't happened yet, then interpolation for file-based activation is limited to
<<<$\{basedir}>>> (since Maven 3), system properties and user properties
** raw model validation: <<<ModelValidator>>> ({{{./apidocs/org/apache/maven/model/validation/ModelValidator.html}javadoc}}),
with its <<<DefaultModelValidator>>> implementation
({{{./xref/org/apache/maven/model/validation/DefaultModelValidator.html}source}})
** model normalization - merge duplicates: <<<ModelNormalizer>>> ({{{./apidocs/org/apache/maven/model/normalization/ModelNormalizer.html}javadoc}}),
with its <<<DefaultModelNormalizer>>> implementation
({{{./xref/org/apache/maven/model/normalization/DefaultModelNormalizer.html}source}})
** profile injection: <<<ProfileInjector>>> ({{{./apidocs/org/apache/maven/model/profile/ProfileInjector.html}javadoc}}),
with its <<<DefaultProfileInjector>>> implementation
({{{./xref/org/apache/maven/model/profile/DefaultProfileInjector.html}source}})
** parent resolution until {{{./super-pom.html}super-pom}}
** inheritance assembly (see {{{./index.html#Inheritance_Assembly}below}})
** model interpolation (see {{{./index.html#Model_Interpolation}below}})
** url normalization: <<<UrlNormalizer>>> ({{{./apidocs/org/apache/maven/model/path/UrlNormalizer.html}javadoc}}),
with its <<<DefaultUrlNormalizer>>> implementation
({{{./xref/org/apache/maven/model/path/DefaultUrlNormalizer.html}source}})
[]
* phase 2, with optional plugin processing
** model path translation: <<<ModelPathTranslator>>> ({{{./apidocs/org/apache/maven/model/path/ModelPathTranslator.html}javadoc}}),
with its <<<DefaultModelPathTranslator>>> implementation
({{{./xref/org/apache/maven/model/path/DefaultModelPathTranslator.html}source}})
** plugin management injection: <<<PluginManagementInjector>>> ({{{./apidocs/org/apache/maven/model/management/PluginManagementInjector.html}javadoc}}),
with its <<<DefaultPluginManagementInjector>>> implementation
({{{./xref/org/apache/maven/model/management/DefaultPluginManagementInjector.html}source}})
** <(optional)> lifecycle bindings injection: <<<LifecycleBindingsInjector>>> ({{{./apidocs/org/apache/maven/model/plugin/LifecycleBindingsInjector.html}javadoc}}),
with its <<<DefaultLifecycleBindingsInjector>>> implementation in maven-core
({{{./maven-core/xref/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.html}source}})
** dependency management import (for dependencies of type <<<pom>>> and scope <<<import>>> in the <<<\<dependencyManagement\>>>> section)
** dependency management injection: <<<DependencyManagementInjector>>> ({{{./apidocs/org/apache/maven/model/management/DependencyManagementInjector.html}javadoc}}),
with its <<<DefaultDependencyManagementInjector>>> implementation
({{{./xref/org/apache/maven/model/management/DefaultDependencyManagementInjector.html}source}})
** model normalization - inject default values: <<<ModelNormalizer>>> ({{{./apidocs/org/apache/maven/model/normalization/ModelNormalizer.html}javadoc}}),
with its <<<DefaultModelNormalizer>>> implementation
({{{./xref/org/apache/maven/model/normalization/DefaultModelNormalizer.html}source}})
** <(optional)> reports configuration: <<<ReportConfigurationExpander>>> ({{{./apidocs/org/apache/maven/model/plugin/ReportConfigurationExpander.html}javadoc}}),
with its <<<DefaultReportConfigurationExpander>>> implementation
({{{./xref/org/apache/maven/model/plugin/DefaultReportConfigurationExpander.html}source}})
** <(optional)> reports conversion to decoupled site plugin: <<<ReportingConverter>>> ({{{./apidocs/org/apache/maven/model/plugin/ReportingConverter.html}javadoc}}),
with its <<<DefaultReportingConverter>>> implementation
({{{./xref/org/apache/maven/model/plugin/DefaultReportingConverter.html}source}})
** <(optional)> plugins configuration: <<<PluginConfigurationExpander>>> ({{{./apidocs/org/apache/maven/model/plugin/PluginConfigurationExpander.html}javadoc}}),
with its <<<DefaultPluginConfigurationExpander>>> implementation
({{{./xref/org/apache/maven/model/plugin/DefaultPluginConfigurationExpander.html}source}})
** effective model validation: <<<ModelValidator>>> ({{{./apidocs/org/apache/maven/model/validation/ModelValidator.html}javadoc}}),
with its <<<DefaultModelValidator>>> implementation
({{{./xref/org/apache/maven/model/validation/DefaultModelValidator.html}source}})
[]
[]
* Inheritance Assembly
Inheritance Assembly consists in filling current model empty fields with values taken from parent model.
It is done in <<<InheritanceAssembler>>> ({{{./apidocs/org/apache/maven/model/inheritance/InheritanceAssembler.html}javadoc}}),
with its <<<DefaultInheritanceAssembler>>> implementation
({{{./xref/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.html}source}}).
By default, every model field is inherited as-is from parent, with a few exceptions that are intentionally not inherited:
<<<modelVersion>>>, <<<artifactId>>>, <<<profiles>>> (injected in phase 1) and <<<prerequisites>>>.
Notice that the 5 URLs from the model (<<<project.url>>>, <<<project.scm.connection>>>, <<<project.scm.developerConnection>>>,
<<<project.scm.url>>> and <<<project.distributionManagement.site.url>>>) have a special inheritance handling:
** if not configured in current model, the inherited value is the parent's one with current artifact id appended,
** since Maven 3.5.0, if <<<project.directory>>> POM property value is defined, it is used instead of artifact id:
this permits default inheritance calculations when module directory name is not equal to artifact id. Notice that this
property is not inherited from a POM to its child: childs POM will use child artifact id if property is not
set.
** since Maven 3.6.1, inheritance can avoid appending any path to parent value by setting model attribute value to
<<<false>>> for each url:
<<<project/@child.project.url.inherit.append.path>>>,
<<<project/distributionManagement/site/@child.site.url.inherit.append.path>>>,
<<<project/scm/@child.scm.connection.inherit.append.path>>>,
<<<project/scm/@child.scm.developerConnection.inherit.append.path>>> and
<<<project/scm/@child.scm.url.inherit.append.path>>>.
[]
* Model Interpolation
Model Interpolation consists in replacing <<<$\{...\}>>> with calculated value. It is done in <<<StringSearchModelInterpolator>>>
({{{./apidocs/org/apache/maven/model/interpolation/StringSearchModelInterpolator.html}javadoc}},
{{{./xref/org/apache/maven/model/interpolation/StringSearchModelInterpolator.html}source}}).
Notice that model interpolation happens <after> profile activation, then profile activation doesn't benefit from every values:
interpolation for file-based activation is limited to <<<$\{basedir}>>> (which was introduced in Maven 3 and is not deprecated
in this context), system properties and user properties.
Values are evaluated in sequence from different syntaxes:
*----+------+------+
|| value || evaluation result || common examples ||
*----+------+------+
| <<<project.*>>>\
<<<pom.*>>> (<deprecated>)\
<<<*>>> (<deprecated>) | POM content (see {{{../maven-model/maven.html}POM reference}}) | <<<$\{project.version\}>>>\
| | <<<$\{project.build.finalName\}>>>\
| | <<<$\{project.artifactId\}>>>\
| | <<<$\{project.build.directory\}>>> |
*----+------+------+
| <<<project.basedir>>>\
<<<pom.basedir>>> (<deprecated>)\
<<<basedir>>> (<deprecated>) | the directory containing the <<<pom.xml>>> file | <<<$\{project.basedir\}>>> |
*----+------+------+
| <<<project.baseUri>>>\
<<<pom.baseUri>>> (<deprecated>) | the directory containing the <<<pom.xml>>> file as URI | <<<$\{project.baseUri\}>>> |
*----+------+------+
| <<<build.timestamp>>>\
<<<maven.build.timestamp>>> | the UTC timestamp of build start, in <<<yyyy-MM-dd'T'HH:mm:ss'Z'>>> default format, which can be overridden with <<<maven.build.timestamp.format>>> POM property | <<<$\{maven.build.timestamp\}>>> |
*----+------+------+
| <<<*>>> | user properties, set from CLI with <<<-Dproperty=value>>> | <<<$\{skipTests\}>>> |
*----+------+------+
| <<<*>>> | model properties, such as project properties set in the pom | <<<$\{any.key\}>>> |
*----+------+------+
| <<<maven.home>>> | The path to the current Maven home. | <<<$\{maven.home\}>>> |
*----+------+------+
| <<<maven.version>>> | The version number of the current Maven execution <(since 3.0.4)>. For example, "<<<3.0.5>>>". | <<<$\{maven.version\}>>> |
*----+------+------+
| <<<maven.build.version>>> | The full build version of the current Maven execution <(since 3.0.4)>. For example, "<<<Apache Maven 3.2.2 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19T14:51:28+01:00)>>>". | <<<$\{maven.build.version\}>>> |
*----+------+------+
| <<<maven.repo.local>>> | The repository on the local machine Maven shall use to store installed and downloaded artifacts (POMs, JARs, etc). | <<<$\{user.home\}/.m2/repository>>> |
*----+------+------+
| <<<*>>> | Java system properties (see {{{https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#getProperties()}JDK reference}}) | <<<$\{user.home\}>>>\
| | <<<$\{java.home\}>>> |
*----+------+------+
| <<<*>>> | User properties | <<<$\{foo\}>>> |
*----+------+------+
| <<<env.*>>>\
<<<*>>> | environment variables | <<<$\{env.PATH\}>>> |
*----+------+------+
| <<<settings.*>>> | Local user settings (see {{{../maven-settings/settings.html}settings reference}}) | <<<$\{settings.localRepository\}>>> |
*----+------+------+
** Notice
* after model interpolation, <<<$\{...\}>>> content can remain in the model that will be evaluated later
when setting plugin parameters. This happens in particular with <<<settings.*>>> values for
{{{../maven-settings/settings.html}Settings Model}},
* encoding configuration have been defined as POM properties looking like POM content but not added to POM model to maintain
compatibility with previous Maven versions:
* <<<$\{project.build.sourceEncoding\}>>> for
{{{https://cwiki.apache.org/confluence/display/MAVEN/POM+Element+for+Source+File+Encoding}source files encoding}}
(defaults to platform encoding)
* <<<$\{project.reporting.outputEncoding\}>>> for
{{{https://cwiki.apache.org/confluence/display/MAVENOLD/Reporting+Encoding+Configuration}reporting output files encoding}}
(defaults to <<<UTF-8>>>)
[]
[]