0
# Plugin Management
1
2
Comprehensive Maven plugin management with pre-configured settings for compilation, testing, packaging, and deployment of Spring Boot applications.
3
4
## Capabilities
5
6
### Java Compilation
7
8
Maven compiler plugin configuration with Spring Boot optimizations.
9
10
```xml { .api }
11
/**
12
* Maven compiler plugin with parameter names preservation
13
* Enables parameter names in compiled bytecode for Spring's reflection
14
*/
15
<plugin>
16
<groupId>org.apache.maven.plugins</groupId>
17
<artifactId>maven-compiler-plugin</artifactId>
18
<configuration>
19
<parameters>true</parameters>
20
</configuration>
21
</plugin>
22
```
23
24
**Usage Examples:**
25
26
```java
27
// Parameter names preserved in bytecode
28
@RestController
29
public class UserController {
30
@PostMapping("/users")
31
public User createUser(@RequestBody String name, @RequestParam int age) {
32
// Spring can use actual parameter names instead of arg0, arg1
33
return userService.create(name, age);
34
}
35
}
36
```
37
38
### Kotlin Compilation
39
40
Kotlin Maven plugin configuration for mixed Java/Kotlin projects.
41
42
```xml { .api }
43
/**
44
* Kotlin Maven plugin for Kotlin compilation support
45
* Configured for JVM target and Java parameter preservation
46
*/
47
<plugin>
48
<groupId>org.jetbrains.kotlin</groupId>
49
<artifactId>kotlin-maven-plugin</artifactId>
50
<version>${kotlin.version}</version>
51
<configuration>
52
<jvmTarget>${java.version}</jvmTarget>
53
<javaParameters>true</javaParameters>
54
</configuration>
55
<executions>
56
<execution>
57
<id>compile</id>
58
<phase>compile</phase>
59
<goals>
60
<goal>compile</goal>
61
</goals>
62
</execution>
63
<execution>
64
<id>test-compile</id>
65
<phase>test-compile</phase>
66
<goals>
67
<goal>test-compile</goal>
68
</goals>
69
</execution>
70
</executions>
71
</plugin>
72
```
73
74
### Integration Testing
75
76
Maven Failsafe plugin for integration test execution.
77
78
```xml { .api }
79
/**
80
* Maven Failsafe plugin for integration tests
81
* Executes *IT.java test classes separately from unit tests
82
*/
83
<plugin>
84
<groupId>org.apache.maven.plugins</groupId>
85
<artifactId>maven-failsafe-plugin</artifactId>
86
<executions>
87
<execution>
88
<goals>
89
<goal>integration-test</goal>
90
<goal>verify</goal>
91
</goals>
92
</execution>
93
</executions>
94
<configuration>
95
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
96
</configuration>
97
</plugin>
98
```
99
100
**Usage Examples:**
101
102
```java
103
// Integration test example
104
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
105
class UserControllerIT {
106
107
@Autowired
108
private TestRestTemplate restTemplate;
109
110
@Test
111
void shouldCreateUser() {
112
// Integration test that starts full Spring context
113
}
114
}
115
```
116
117
### JAR Packaging
118
119
Maven JAR plugin configuration with manifest entries for executable JARs.
120
121
```xml { .api }
122
/**
123
* Maven JAR plugin with Spring Boot manifest configuration
124
* Creates JAR with main class and implementation entries
125
*/
126
<plugin>
127
<groupId>org.apache.maven.plugins</groupId>
128
<artifactId>maven-jar-plugin</artifactId>
129
<configuration>
130
<archive>
131
<manifest>
132
<mainClass>${start-class}</mainClass>
133
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
134
</manifest>
135
</archive>
136
</configuration>
137
</plugin>
138
```
139
140
### WAR Packaging
141
142
Maven WAR plugin configuration for web application deployment.
143
144
```xml { .api }
145
/**
146
* Maven WAR plugin with Spring Boot manifest configuration
147
* Creates WAR with main class for embedded server deployment
148
*/
149
<plugin>
150
<groupId>org.apache.maven.plugins</groupId>
151
<artifactId>maven-war-plugin</artifactId>
152
<configuration>
153
<archive>
154
<manifest>
155
<mainClass>${start-class}</mainClass>
156
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
157
</manifest>
158
</archive>
159
</configuration>
160
</plugin>
161
```
162
163
### Spring Boot Maven Plugin
164
165
Core Spring Boot Maven plugin for executable JAR/WAR creation and application running.
166
167
```xml { .api }
168
/**
169
* Spring Boot Maven plugin for executable artifact creation
170
* Repackages JAR/WAR with embedded dependencies and launcher
171
*/
172
<plugin>
173
<groupId>org.springframework.boot</groupId>
174
<artifactId>spring-boot-maven-plugin</artifactId>
175
<executions>
176
<execution>
177
<id>repackage</id>
178
<goals>
179
<goal>repackage</goal>
180
</goals>
181
</execution>
182
</executions>
183
<configuration>
184
<mainClass>${spring-boot.run.main-class}</mainClass>
185
</configuration>
186
</plugin>
187
```
188
189
**Usage Examples:**
190
191
```bash
192
# Run application during development
193
mvn spring-boot:run
194
195
# Create executable JAR
196
mvn package
197
java -jar target/my-app-1.0.0.jar
198
199
# Run with profile
200
mvn spring-boot:run -Dspring-boot.run.profiles=dev
201
```
202
203
### Git Information Plugin
204
205
Git commit ID plugin for embedding build information.
206
207
```xml { .api }
208
/**
209
* Git commit ID plugin for build information
210
* Generates git.properties with commit details
211
*/
212
<plugin>
213
<groupId>io.github.git-commit-id</groupId>
214
<artifactId>git-commit-id-maven-plugin</artifactId>
215
<executions>
216
<execution>
217
<goals>
218
<goal>revision</goal>
219
</goals>
220
</execution>
221
</executions>
222
<configuration>
223
<verbose>true</verbose>
224
<generateGitPropertiesFile>true</generateGitPropertiesFile>
225
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
226
</configuration>
227
</plugin>
228
```
229
230
### SBOM Generation
231
232
CycloneDX plugin for Software Bill of Materials generation.
233
234
```xml { .api }
235
/**
236
* CycloneDX plugin for SBOM generation
237
* Creates software bill of materials in JSON format
238
*/
239
<plugin>
240
<groupId>org.cyclonedx</groupId>
241
<artifactId>cyclonedx-maven-plugin</artifactId>
242
<executions>
243
<execution>
244
<phase>generate-resources</phase>
245
<goals>
246
<goal>makeAggregateBom</goal>
247
</goals>
248
<configuration>
249
<projectType>application</projectType>
250
<outputDirectory>${project.build.outputDirectory}/META-INF/sbom</outputDirectory>
251
<outputFormat>json</outputFormat>
252
<outputName>application.cdx</outputName>
253
</configuration>
254
</execution>
255
</executions>
256
</plugin>
257
```
258
259
### Uber JAR Creation
260
261
Maven Shade plugin for creating fat JARs with all dependencies.
262
263
```xml { .api }
264
/**
265
* Maven Shade plugin for uber JAR creation
266
* Alternative to Spring Boot plugin for specific deployment scenarios
267
*/
268
<plugin>
269
<groupId>org.apache.maven.plugins</groupId>
270
<artifactId>maven-shade-plugin</artifactId>
271
<configuration>
272
<keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
273
<createDependencyReducedPom>true</createDependencyReducedPom>
274
<filters>
275
<filter>
276
<artifact>*:*</artifact>
277
<excludes>
278
<exclude>META-INF/*.SF</exclude>
279
<exclude>META-INF/*.DSA</exclude>
280
<exclude>META-INF/*.RSA</exclude>
281
</excludes>
282
</filter>
283
</filters>
284
</configuration>
285
<executions>
286
<execution>
287
<phase>package</phase>
288
<goals>
289
<goal>shade</goal>
290
</goals>
291
<configuration>
292
<transformers>
293
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
294
<resource>META-INF/spring.handlers</resource>
295
</transformer>
296
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
297
<resource>META-INF/spring.schemas</resource>
298
</transformer>
299
<transformer implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
300
<resource>META-INF/spring.factories</resource>
301
</transformer>
302
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
303
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
304
<mainClass>${start-class}</mainClass>
305
<manifestEntries>
306
<Multi-Release>true</Multi-Release>
307
</manifestEntries>
308
</transformer>
309
</transformers>
310
</configuration>
311
</execution>
312
</executions>
313
</plugin>
314
```
315
316
## Plugin Execution Lifecycle
317
318
### Standard Build Lifecycle
319
320
```bash
321
# Clean and compile
322
mvn clean compile
323
324
# Run tests (unit tests via Surefire, integration tests via Failsafe)
325
mvn test
326
mvn integration-test
327
328
# Package executable JAR/WAR
329
mvn package
330
331
# Install to local repository
332
mvn install
333
334
# Deploy to remote repository
335
mvn deploy
336
```
337
338
### Development Lifecycle
339
340
```bash
341
# Run application with hot reload
342
mvn spring-boot:run
343
344
# Run with specific profile
345
mvn spring-boot:run -Dspring-boot.run.profiles=dev
346
347
# Debug mode
348
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
349
```