-
Notifications
You must be signed in to change notification settings - Fork 8
/
pom.xml
461 lines (416 loc) · 20.8 KB
/
pom.xml
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.octodemo-containers</groupId>
<artifactId>bookstore-advanced</artifactId>
<version>${revision}${changelist}${sha1}</version>
<packaging>war</packaging>
<name>${project.artifactId}</name>
<description>A Java example project to demonstrate a Java development stack with Maven, GitHub Actions, GitHub Package Registry and Cloud Resources.</description>
<url>https://github.com/octodemo-containers/bookstore-advanced</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
<!--
Dependency Versions
-->
<jetty.version.semver>10.0.0</jetty.version.semver>
<jetty.version>${jetty.version.semver}</jetty.version>
<log4j.version>2.12.1</log4j.version>
<slf4j.version>2.0.0-alpha1</slf4j.version>
<!--
Properties used to create a CD style version number for the Maven build
-->
<revision>1.0.0</revision>
<changelist></changelist>
<sha1>-SNAPSHOT</sha1>
<!-- Logging debug flag for jetty server when we run the maven jetty plugin -->
<logj-debug>FALSE</logj-debug>
<!--
Properties for naming, tagging and deploying the Docker image, when running under the correct
operating system that supports this.
-->
<github.repository>octodemo-containers/bookstore-advanced</github.repository>
<!-- The container registry to publish to -->
<container.image.registry>ghcr.io</container.image.registry>
<container.image.name>octodemo-containers/${project.artifactId}</container.image.name>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-bom</artifactId>
<version>${jetty.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>4.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>3.0.12.RELEASE</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20200518</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.32.3.2</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.16</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j18-impl</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.1</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.29</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<!-- To enable debug compilation use the maven.compiler.debug user property -->
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.34.1</version>
</plugin>
<plugin>
<groupId>com.github.ekryd.echo-maven-plugin</groupId>
<artifactId>echo-maven-plugin</artifactId>
<version>1.2.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<dumpOnStart>true</dumpOnStart>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>verify-style</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<logViolationsToConsole>true</logViolationsToConsole>
<checkstyleRules>
<module name="Checker">
<module name="TreeWalker">
<module name="MethodName">
<property name="format" value="^[a-z](_?[a-zA-Z0-9]+)*$"/>
</module>
</module>
</module>
</checkstyleRules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-jacoco</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<!--
Profile to build a Docker container for running our WAR.
This will only activate on MacOS and Linux hosts as the container used as a base does not have a
corresponding Windows variant.
-->
<profile>
<id>build-container</id>
<activation>
<os>
<family>!windows</family>
</os>
</activation>
<build>
<plugins>
<!--
Create the full image name (including registry) for the container being created. This is just lowercasing the name
as the docker container image must be lowercase to pass checks. (Its a bit convoluted to use regex replace but its the
simplest way to acheive this for now).
-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>clean container image name full</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>container.image.name.full</name>
<value>${container.image.registry}/${container.image.name}</value>
<regex>\?</regex>
<toLowerCase>true</toLowerCase>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
<execution>
<id>clean container image name</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>container.image.name</name>
<value>${container.image.name}</value>
<regex>\?</regex>
<toLowerCase>true</toLowerCase>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>build-container</id>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
<configuration>
<verbose>true</verbose>
<images>
<!--
Equivalent of a Dockerfile, it is defined here due to the build needing
to put the .war file we generate as the ROOT.war inside the container so
that Jetty can run it as the default Web App.
-->
<image>
<name>${container.image.name.full}</name>
<build>
<from>jetty:${jetty.version.semver}-jre11-slim</from>
<assembly>
<mode>dir</mode>
<targetDir>/var/lib/jetty/webapps</targetDir>
<descriptorRef>rootWar</descriptorRef>
</assembly>
<labels>
<!-- <org.opencontainer.image.created></org.opencontainer.image.created> -->
<org.opencontainers.image.authors>GitHub Solutions Engineering</org.opencontainers.image.authors>
<org.opencontainers.image.url>${project.url}</org.opencontainers.image.url>
<org.opencontainers.image.documentation>https://github.com/octodemo-containers/bookstore-advanced/README.md</org.opencontainers.image.documentation>
<org.opencontainers.image.source>${project.url}</org.opencontainers.image.source>
<org.opencontainers.image.version>${project.version}</org.opencontainers.image.version>
<org.opencontainers.image.revision>${changelist}</org.opencontainers.image.revision>
<org.opencontainers.image.vendor>GitHub</org.opencontainers.image.vendor>
<org.opencontainers.image.licenses>MIT</org.opencontainers.image.licenses>
<org.opencontainers.image.title>GitHub Solutions Engineering Bookstore</org.opencontainers.image.title>
<org.opencontainers.image.description>${project.description}</org.opencontainers.image.description>
</labels>
<tags>
<tag>${project.version}</tag>
</tags>
</build>
</image>
</images>
</configuration>
</execution>
</executions>
</plugin>
<!--
Using the Maven echo-maven-plugin here to communicate with the GitHub Actions runtime
to set some outputs that can be used in steps later in the workflow.
This will expose the tag used when building the container and the registry that was used
to deploy it to. Both of these values can be changed using properties in the build.
-->
<plugin>
<groupId>com.github.ekryd.echo-maven-plugin</groupId>
<artifactId>echo-maven-plugin</artifactId>
<executions>
<execution>
<id>github-actions-version</id>
<phase>package</phase>
<goals>
<goal>echo</goal>
</goals>
<configuration>
<message>Exporting Outputs for GitHub Actions
::set-output name=container_registry::${container.image.registry}
::set-output name=container_image::${container.image.name}
::set-output name=container_version::${project.version}
</message>
</configuration>
</execution>
</executions>
</plugin>
<!--
Using this as a fall back to the echo above as there have been times where the actions step logs are truncated
so we do not get these values echoed and then loaded as outputs to later steps.
This outputting the file is a fallback to counter this as we can load from this file if it keeps happening in practice.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>github-actions-version-file</id>
<goals>
<goal>copy-resources</goal>
</goals>
<phase>package</phase>
<configuration>
<resources>
<resource>
<directory>src/main/github_workflow</directory>
<filtering>true</filtering>
</resource>
</resources>
<outputDirectory>${project.build.directory}/github_actions</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!--
Profile for forking the jetty server and providing a debugger attachment to running process.
This is primarily used within the GitHub Codespace environment to be able to run and debug the application, deployed into a
Jetty Server that can update based on local file changes.
Due to this being a background process, it will register a stop port of 8081 whereby it will listen for the termination message and password
to shutdown the server once debugging is completed.
-->
<id>vscode-debug</id>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<deployMode>FORK</deployMode>
<jvmArgs>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -Dlog4j2.debug=${log4j-debug}</jvmArgs>
<stopPort>8081</stopPort>
<stopKey>jetty-vscode</stopKey>
<!-- These are provided in the VS Code tasks.json file now -->
<!-- <env>
<DATABASE_URL>jdbc:postgresql://localhost:5432/bookstore</DATABASE_URL>
<DATABASE_USER>admin</DATABASE_USER>
<DATABASE_PASSWORD>password</DATABASE_PASSWORD>
<DATABASE_RETRIES>1</DATABASE_RETRIES>
</env> -->
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>