-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpom.xml
More file actions
354 lines (304 loc) · 11.1 KB
/
pom.xml
File metadata and controls
354 lines (304 loc) · 11.1 KB
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<?xml version="1.0" encoding="UTF-8"?>
<!--
POM = Project Object Model
This file describes the project and tells Maven:
- what the project is
- how to build it
- which dependencies it needs
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!-- Maven model version (almost always 4.0.0) -->
<modelVersion>4.0.0</modelVersion>
<!-- Project coordinates (unique identifier) -->
<!-- groupId : usually organization or package base -->
<!-- artifactId : project name -->
<!-- version : project version -->
<groupId>fr.univtln.bruno.demos.docker</groupId>
<artifactId>hello-world</artifactId>
<version>0.1.0-SNAPSHOT</version>
<!-- Human-readable project information -->
<name>Hello World</name>
<description>
Application Java "Hello World" utilisée pour démontrer Maven et Docker
</description>
<url>https://github.com/ebpro/notebook-containers-intro-sample-java-helloworld</url>
<!--
Properties:
- Central place to define versions and configuration values
- Avoids repeating version numbers everywhere
-->
<properties>
<!-- Encoding used for source files and reports -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Java version used to compile the project -->
<java.version>21</java.version>
<!-- Fully qualified name of the main class -->
<main.class>fr.univtln.bruno.demos.docker.App</main.class>
<!-- Dependency versions -->
<junit.version>6.0.2</junit.version>
<slf4j.version>2.0.17</slf4j.version>
<logback.version>1.5.25</logback.version>
<!-- Maven plugin versions -->
<maven.compiler.version>3.14.1</maven.compiler.version>
<maven.surefire.version>3.5.4</maven.surefire.version>
<maven.jar.version>3.5.0</maven.jar.version>
<maven.dependency.version>3.9.0</maven.dependency.version>
<versions.maven.version>2.21.0</versions.maven.version>
<native.image.plugin.version>0.11.4</native.image.plugin.version>
<maven.jlink.version>3.2.0</maven.jlink.version>
<!-- Maven Enforcer plugin version -->
<maven.enforcer.version>3.6.2</maven.enforcer.version>
<maven.clean.version>3.5.0</maven.clean.version>
<maven.install.version>3.1.4</maven.install.version>
<maven.site.version>3.21.0</maven.site.version>
<maven.resources.version>3.4.0</maven.resources.version>
<maven.deploy.version>3.1.4</maven.deploy.version>
<!-- Ensures reproducible builds (same timestamps) -->
<project.build.outputTimestamp>2024-06-01T00:00:00Z</project.build.outputTimestamp>
</properties>
<!--
Dependencies:
External libraries required by the project
-->
<dependencies>
<!-- JUnit 5: unit testing framework (only used for tests) -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- SLF4J: logging API (used in the code) -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- Logback: logging implementation (used at runtime) -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<!--
Build configuration:
Defines how the project is compiled, tested, and packaged
-->
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>${maven.clean.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>${maven.install.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${maven.site.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven.resources.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven.deploy.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- Java compilation plugin -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<!-- Compile using Java 21 -->
<release>${java.version}</release>
<!-- Keep method parameter names (useful for reflection) -->
<parameters>true</parameters>
</configuration>
</plugin>
<!-- Runs unit tests -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
</plugin>
<!-- Plugin to check and update dependency versions -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>${versions.maven.version}</version>
<configuration>
<!-- Custom rules for allowed versions -->
<rulesUri>https://bruno.univ-tln.fr/rules.xml</rulesUri>
</configuration>
</plugin>
<!-- Maven Enforcer: enforce best-practice rules early in the build -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven.enforcer.version}</version>
<executions>
<execution>
<id>enforce</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<!-- Require a minimum Maven version -->
<requireMavenVersion>
<version>[3.6.3,)</version>
</requireMavenVersion>
<!-- Ensure the build uses the expected Java version -->
<requireJavaVersion>
<version>[21,)</version>
</requireJavaVersion>
<!-- Catch dependency convergence issues -->
<dependencyConvergence />
<!-- Enforce upper-bound dependency versions to avoid conflicts -->
<requireUpperBoundDeps />
<!-- Ensure plugins declare versions -->
<requirePluginVersions />
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!--
Profiles:
Optional build configurations activated with -P
-->
<profiles>
<!-- Production profile: creates a runnable JAR with dependencies -->
<profile>
<id>prod</id>
<build>
<plugins>
<!-- Copies runtime dependencies into target/libs -->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven.dependency.version}</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/libs</outputDirectory>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<!-- Builds a JAR with a Main-Class and classpath -->
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven.jar.version}</version>
<configuration>
<archive>
<manifest>
<!-- Entry point of the application -->
<mainClass>${main.class}</mainClass>
<!-- Adds classpath to the manifest -->
<addClasspath>true</addClasspath>
<classpathPrefix>libs/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- Profil jlink -->
<profile>
<id>jlink</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jlink-plugin</artifactId>
<version>${maven.jlink.version}</version>
<executions>
<execution>
<id>jlink</id>
<goals>
<goal>jlink</goal>
</goals>
</execution>
</executions>
<configuration>
<classifier>runtime-image</classifier>
<addModules>ALL-MODULE-PATH,java.naming</addModules>
<launcher>hello=fr.univtln.bruno.demos.docker/fr.univtln.bruno.demos.docker.App</launcher>
<!-- Optional but recommended -->
<compress>2</compress>
<stripDebug>true</stripDebug>
<noHeaderFiles>true</noHeaderFiles>
<noManPages>true</noManPages>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- Native profile: builds a GraalVM native executable -->
<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${native.image.plugin.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<id>build-native</id>
<phase>package</phase>
<goals>
<goal>compile-no-fork</goal>
</goals>
</execution>
</executions>
<!-- Native image configuration -->
<configuration>
<imageName>app</imageName>
<mainClass>${main.class}</mainClass>
<buildArgs>
<!-- No JVM fallback -->
<buildArg>--no-fallback</buildArg>
<!-- Static binary -->
<buildArg>--static</buildArg>
<!-- Use musl libc (Docker-friendly) -->
<buildArg>--libc=musl</buildArg>
<!-- Initialize logging libraries at build time -->
<buildArg>
--initialize-at-build-time=org.slf4j,ch.qos.logback
</buildArg>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>