0
# Build Configuration
1
2
Build-related classes including Build, BuildBase, plugins, executions, and resource management. These classes define how Maven builds and processes project artifacts.
3
4
## Capabilities
5
6
### Build
7
8
Main build configuration class that extends BuildBase with additional directory configurations.
9
10
```java { .api }
11
public class Build extends BuildBase {
12
// Source directories
13
public String getSourceDirectory();
14
public void setSourceDirectory(String sourceDirectory);
15
public String getScriptSourceDirectory();
16
public void setScriptSourceDirectory(String scriptSourceDirectory);
17
public String getTestSourceDirectory();
18
public void setTestSourceDirectory(String testSourceDirectory);
19
20
// Output directories
21
public String getOutputDirectory();
22
public void setOutputDirectory(String outputDirectory);
23
public String getTestOutputDirectory();
24
public void setTestOutputDirectory(String testOutputDirectory);
25
26
// Build configuration
27
public String getDirectory();
28
public void setDirectory(String directory);
29
public String getFinalName();
30
public void setFinalName(String finalName);
31
32
// Filter configuration
33
public List<String> getFilters();
34
public void setFilters(List<String> filters);
35
public void addFilter(String filter);
36
public void removeFilter(String filter);
37
38
// Extensions
39
public List<Extension> getExtensions();
40
public void setExtensions(List<Extension> extensions);
41
public void addExtension(Extension extension);
42
public void removeExtension(Extension extension);
43
44
// Utility methods
45
public Build clone();
46
public InputLocation getLocation(Object key);
47
public void setLocation(Object key, InputLocation location);
48
}
49
```
50
51
### BuildBase
52
53
Base class for build configuration shared between main Build and profile builds.
54
55
```java { .api }
56
public class BuildBase {
57
// Default goal
58
public String getDefaultGoal();
59
public void setDefaultGoal(String defaultGoal);
60
61
// Resources
62
public List<Resource> getResources();
63
public void setResources(List<Resource> resources);
64
public void addResource(Resource resource);
65
public void removeResource(Resource resource);
66
public List<Resource> getTestResources();
67
public void setTestResources(List<Resource> testResources);
68
public void addTestResource(Resource resource);
69
public void removeTestResource(Resource resource);
70
71
// Plugin management
72
public PluginManagement getPluginManagement();
73
public void setPluginManagement(PluginManagement pluginManagement);
74
public List<Plugin> getPlugins();
75
public void setPlugins(List<Plugin> plugins);
76
public void addPlugin(Plugin plugin);
77
public void removePlugin(Plugin plugin);
78
79
// Utility methods
80
public BuildBase clone();
81
public InputLocation getLocation(Object key);
82
public void setLocation(Object key, InputLocation location);
83
}
84
```
85
86
### Plugin
87
88
Represents a Maven plugin with its configuration and executions.
89
90
```java { .api }
91
public class Plugin {
92
// Plugin coordinates
93
public String getGroupId();
94
public void setGroupId(String groupId);
95
public String getArtifactId();
96
public void setArtifactId(String artifactId);
97
public String getVersion();
98
public void setVersion(String version);
99
100
// Plugin configuration
101
public String getExtensions();
102
public void setExtensions(String extensions);
103
public boolean isExtensions();
104
public Object getConfiguration();
105
public void setConfiguration(Object configuration);
106
public boolean isInherited();
107
public void setInherited(boolean inherited);
108
109
// Executions
110
public List<PluginExecution> getExecutions();
111
public void setExecutions(List<PluginExecution> executions);
112
public void addExecution(PluginExecution pluginExecution);
113
public void removeExecution(PluginExecution pluginExecution);
114
115
// Dependencies
116
public List<Dependency> getDependencies();
117
public void setDependencies(List<Dependency> dependencies);
118
public void addDependency(Dependency dependency);
119
public void removeDependency(Dependency dependency);
120
121
// Utility methods
122
public String getKey();
123
public String toString();
124
public Plugin clone();
125
public InputLocation getLocation(Object key);
126
public void setLocation(Object key, InputLocation location);
127
}
128
```
129
130
**Usage Example:**
131
132
```java
133
Plugin plugin = new Plugin();
134
plugin.setGroupId("org.apache.maven.plugins");
135
plugin.setArtifactId("maven-compiler-plugin");
136
plugin.setVersion("3.8.1");
137
138
// Add configuration
139
plugin.setConfiguration(configuration); // Typically DOM configuration
140
141
// Add execution
142
PluginExecution execution = new PluginExecution();
143
execution.setId("default-compile");
144
execution.setPhase("compile");
145
execution.addGoal("compile");
146
plugin.addExecution(execution);
147
148
build.addPlugin(plugin);
149
```
150
151
### PluginExecution
152
153
Defines a specific execution of a plugin with goals, phase, and configuration.
154
155
```java { .api }
156
public class PluginExecution extends ConfigurationContainer {
157
public String getId();
158
public void setId(String id);
159
public String getPhase();
160
public void setPhase(String phase);
161
public int getPriority();
162
public void setPriority(int priority);
163
164
// Goals
165
public List<String> getGoals();
166
public void setGoals(List<String> goals);
167
public void addGoal(String goal);
168
public void removeGoal(String goal);
169
170
// Utility methods
171
public String toString();
172
public PluginExecution clone();
173
public InputLocation getLocation(Object key);
174
public void setLocation(Object key, InputLocation location);
175
}
176
```
177
178
### PluginManagement
179
180
Container for managing default plugin versions and configurations.
181
182
```java { .api }
183
public class PluginManagement {
184
public List<Plugin> getPlugins();
185
public void setPlugins(List<Plugin> plugins);
186
public void addPlugin(Plugin plugin);
187
public void removePlugin(Plugin plugin);
188
189
// Utility methods
190
public PluginManagement clone();
191
public InputLocation getLocation(Object key);
192
public void setLocation(Object key, InputLocation location);
193
}
194
```
195
196
### Resource
197
198
Defines build resources with filtering and inclusion/exclusion patterns.
199
200
```java { .api }
201
public class Resource extends FileSet {
202
public String getTargetPath();
203
public void setTargetPath(String targetPath);
204
public String getFiltering();
205
public void setFiltering(String filtering);
206
public boolean isFiltering();
207
208
// Merge excludes from FileSet
209
public List<String> getMergeId();
210
public void setMergeId(List<String> mergeId);
211
212
// Utility methods
213
public Resource clone();
214
public InputLocation getLocation(Object key);
215
public void setLocation(Object key, InputLocation location);
216
}
217
```
218
219
### Extension
220
221
Represents a build extension that extends Maven's core functionality.
222
223
```java { .api }
224
public class Extension {
225
public String getGroupId();
226
public void setGroupId(String groupId);
227
public String getArtifactId();
228
public void setArtifactId(String artifactId);
229
public String getVersion();
230
public void setVersion(String version);
231
232
// Utility methods
233
public Extension clone();
234
public InputLocation getLocation(Object key);
235
public void setLocation(Object key, InputLocation location);
236
}
237
```