0
# Core Model Classes
1
2
The main Model class and fundamental structure classes that represent the root POM elements and shared build configuration. These are the primary entry points for working with Maven project definitions.
3
4
## Capabilities
5
6
### Model
7
8
The root class representing a complete Maven project definition, corresponding to the `<project>` element in a POM file.
9
10
```java { .api }
11
public class Model extends ModelBase {
12
// Core project coordinates
13
public String getModelVersion();
14
public void setModelVersion(String modelVersion);
15
public String getGroupId();
16
public void setGroupId(String groupId);
17
public String getArtifactId();
18
public void setArtifactId(String artifactId);
19
public String getVersion();
20
public void setVersion(String version);
21
public String getPackaging();
22
public void setPackaging(String packaging);
23
24
// Project information
25
public String getName();
26
public void setName(String name);
27
public String getDescription();
28
public void setDescription(String description);
29
public String getUrl();
30
public void setUrl(String url);
31
public String getInceptionYear();
32
public void setInceptionYear(String inceptionYear);
33
34
// URL inheritance control for child projects
35
public String getChildProjectUrlInheritAppendPath();
36
public void setChildProjectUrlInheritAppendPath(String value);
37
public boolean isChildProjectUrlInheritAppendPath();
38
public void setChildProjectUrlInheritAppendPath(boolean value);
39
40
// Parent relationship
41
public Parent getParent();
42
public void setParent(Parent parent);
43
44
// Project structure
45
public List<String> getModules();
46
public void setModules(List<String> modules);
47
public void addModule(String module);
48
public void removeModule(String module);
49
50
// Organization and people
51
public Organization getOrganization();
52
public void setOrganization(Organization organization);
53
public List<License> getLicenses();
54
public void setLicenses(List<License> licenses);
55
public void addLicense(License license);
56
public void removeLicense(License license);
57
public List<Developer> getDevelopers();
58
public void setDevelopers(List<Developer> developers);
59
public void addDeveloper(Developer developer);
60
public void removeDeveloper(Developer developer);
61
public List<Contributor> getContributors();
62
public void setContributors(List<Contributor> contributors);
63
public void addContributor(Contributor contributor);
64
public void removeContributor(Contributor contributor);
65
public List<MailingList> getMailingLists();
66
public void setMailingLists(List<MailingList> mailingLists);
67
public void addMailingList(MailingList mailingList);
68
public void removeMailingList(MailingList mailingList);
69
70
// Management systems
71
public IssueManagement getIssueManagement();
72
public void setIssueManagement(IssueManagement issueManagement);
73
public CiManagement getCiManagement();
74
public void setCiManagement(CiManagement ciManagement);
75
public Scm getScm();
76
public void setScm(Scm scm);
77
public Prerequisites getPrerequisites();
78
public void setPrerequisites(Prerequisites prerequisites);
79
80
// Profiles
81
public List<Profile> getProfiles();
82
public void setProfiles(List<Profile> profiles);
83
public void addProfile(Profile profile);
84
public void removeProfile(Profile profile);
85
86
// Properties
87
public Properties getProperties();
88
public void setProperties(Properties properties);
89
public void addProperty(String key, String value);
90
91
// Utility methods
92
public String getId();
93
public String toString();
94
public File getPomFile();
95
public void setPomFile(File pomFile);
96
public File getProjectDirectory();
97
public void setProjectDirectory(File projectDirectory);
98
public Model clone();
99
public InputLocation getLocation(Object key);
100
public void setLocation(Object key, InputLocation location);
101
}
102
```
103
104
**Usage Example:**
105
106
```java
107
Model model = new Model();
108
model.setModelVersion("4.0.0");
109
model.setGroupId("com.example");
110
model.setArtifactId("my-project");
111
model.setVersion("1.0.0");
112
model.setPackaging("jar");
113
model.setName("My Example Project");
114
model.setDescription("An example Maven project");
115
116
// Add properties
117
model.addProperty("maven.compiler.source", "11");
118
model.addProperty("maven.compiler.target", "11");
119
120
// Add modules for multi-module project
121
model.addModule("submodule-1");
122
model.addModule("submodule-2");
123
```
124
125
### ModelBase
126
127
Base class containing common elements shared between Model and Profile classes. Contains dependencies, repositories, build configuration, and other shared POM elements.
128
129
```java { .api }
130
public class ModelBase {
131
// Dependencies
132
public List<Dependency> getDependencies();
133
public void setDependencies(List<Dependency> dependencies);
134
public void addDependency(Dependency dependency);
135
public void removeDependency(Dependency dependency);
136
public DependencyManagement getDependencyManagement();
137
public void setDependencyManagement(DependencyManagement dependencyManagement);
138
139
// Repositories
140
public List<Repository> getRepositories();
141
public void setRepositories(List<Repository> repositories);
142
public void addRepository(Repository repository);
143
public void removeRepository(Repository repository);
144
public List<Repository> getPluginRepositories();
145
public void setPluginRepositories(List<Repository> pluginRepositories);
146
public void addPluginRepository(Repository pluginRepository);
147
public void removePluginRepository(Repository pluginRepository);
148
149
// Build configuration
150
public Build getBuild();
151
public void setBuild(Build build);
152
153
// Reporting
154
public Reporting getReporting();
155
public void setReporting(Reporting reporting);
156
157
// Distribution
158
public DistributionManagement getDistributionManagement();
159
public void setDistributionManagement(DistributionManagement distributionManagement);
160
161
// Properties
162
public Properties getProperties();
163
public void setProperties(Properties properties);
164
165
// Utility methods
166
public ModelBase clone();
167
public InputLocation getLocation(Object key);
168
public void setLocation(Object key, InputLocation location);
169
}
170
```
171
172
### Parent
173
174
Represents the parent POM reference, enabling POM inheritance for shared configuration.
175
176
```java { .api }
177
public class Parent {
178
public String getGroupId();
179
public void setGroupId(String groupId);
180
public String getArtifactId();
181
public void setArtifactId(String artifactId);
182
public String getVersion();
183
public void setVersion(String version);
184
public String getRelativePath();
185
public void setRelativePath(String relativePath);
186
187
// Utility methods
188
public String getId();
189
public String toString();
190
public Parent clone();
191
public InputLocation getLocation(Object key);
192
public void setLocation(Object key, InputLocation location);
193
}
194
```
195
196
**Usage Example:**
197
198
```java
199
Parent parent = new Parent();
200
parent.setGroupId("com.example");
201
parent.setArtifactId("parent-pom");
202
parent.setVersion("1.0.0");
203
parent.setRelativePath("../parent/pom.xml");
204
205
Model childModel = new Model();
206
childModel.setParent(parent);
207
childModel.setArtifactId("child-module");
208
// Version and groupId inherited from parent
209
```
210
211
### Prerequisites
212
213
Defines the minimum Maven version required to build the project.
214
215
```java { .api }
216
public class Prerequisites {
217
public String getMaven();
218
public void setMaven(String maven);
219
220
// Utility methods
221
public Prerequisites clone();
222
public InputLocation getLocation(Object key);
223
public void setLocation(Object key, InputLocation location);
224
}
225
```
226
227
### ConfigurationContainer
228
229
Base class for elements that can contain configuration data.
230
231
```java { .api }
232
public class ConfigurationContainer {
233
public Object getConfiguration();
234
public void setConfiguration(Object configuration);
235
public boolean isInherited();
236
public void setInherited(boolean inherited);
237
238
// Utility methods
239
public ConfigurationContainer clone();
240
public InputLocation getLocation(Object key);
241
public void setLocation(Object key, InputLocation location);
242
}
243
```