Skip to content

Commit 973aeaf

Browse files
committed
fix(clean): clean names, CI and pom
1 parent a703e82 commit 973aeaf

10 files changed

Lines changed: 96 additions & 33 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This workflow is triggered on pushes and pull requests to the 'develop' and 'main' branches.
2+
13
name: Java CI with Maven
24

35
on:
@@ -8,10 +10,15 @@ on:
810

911
jobs:
1012
build:
11-
runs-on: ubuntu-latest
13+
# To run of Github-hosted runners, uncomment the line below and comment out the self-hosted runner line.
14+
# runs-on: ubuntu-latest
15+
# Use a self-hosted runner to ensure the necessary environment like sonarqube.
16+
runs-on: self-hosted
1217

1318
steps:
1419
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
1522

1623
- name: Set up JDK 21
1724
uses: actions/setup-java@v4

pom.xml

Lines changed: 76 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,36 @@
77
<version>1.0.0-SNAPSHOT</version>
88

99
<properties>
10-
<compiler-plugin.version>3.15.0</compiler-plugin.version>
10+
<!-- Java release level for the compiler (source/target) -->
1111
<maven.compiler.release>21</maven.compiler.release>
12+
13+
<!-- Maven Compiler Plugin: plugin version used to compile the project -->
14+
<compiler-plugin.version>3.15.0</compiler-plugin.version>
15+
<!-- Versions plugin: used for dependency/version updates -->
16+
<versions-plugin.version>2.21.0</versions-plugin.version>
17+
18+
<!-- Encoding properties: ensure consistent encoding across all plugins and reports -->
1219
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1320
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
21+
22+
<!-- Quarkus platform BOM coordinates -->
1423
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
1524
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
1625
<quarkus.platform.version>3.31.2</quarkus.platform.version>
26+
27+
<!-- Testing dependencies versions -->
1728
<surefire-plugin.version>3.5.4</surefire-plugin.version>
1829
<testcontainers.version>1.21.4</testcontainers.version>
19-
<versions-plugin.version>2.21.0</versions-plugin.version>
20-
<quarkus-cucumber.version>1.3.0</quarkus-cucumber.version>
2130
<cucumber.version>7.34.2</cucumber.version>
31+
<quarkus-cucumber.version>1.3.0</quarkus-cucumber.version>
2232

33+
<!-- For reproducible builds -->
2334
<project.build.outputTimestamp>2026-02-07T15:00:00Z</project.build.outputTimestamp>
2435
</properties>
2536

37+
<!-- Import Quarkus platform BOM for dependency version management -->
38+
<!-- This ensures that all Quarkus dependencies use compatible versions as defined by the platform BOM -->
39+
<!-- Not loaded as a regular dependency, but used to manage versions of Quarkus dependencies in the project -->
2640
<dependencyManagement>
2741
<dependencies>
2842
<dependency>
@@ -36,22 +50,29 @@
3650
</dependencyManagement>
3751

3852
<dependencies>
53+
<!-- Quarkus dependencies: these are the libraries that provide the functionality for the application, such as REST endpoints, database access, JSON handling, etc. -->
54+
55+
<!-- Database and ORM -->
3956
<dependency>
4057
<groupId>io.quarkus</groupId>
41-
<artifactId>quarkus-rest-jackson</artifactId>
58+
<artifactId>quarkus-jdbc-postgresql</artifactId>
4259
</dependency>
4360
<dependency>
4461
<groupId>io.quarkus</groupId>
45-
<artifactId>quarkus-rest-client-jackson</artifactId>
62+
<artifactId>quarkus-hibernate-orm-rest-data-panache</artifactId>
4663
</dependency>
64+
65+
<!-- Rest and JSON handling -->
4766
<dependency>
4867
<groupId>io.quarkus</groupId>
49-
<artifactId>quarkus-jdbc-postgresql</artifactId>
68+
<artifactId>quarkus-rest-jackson</artifactId>
5069
</dependency>
5170
<dependency>
5271
<groupId>io.quarkus</groupId>
53-
<artifactId>quarkus-hibernate-orm-rest-data-panache</artifactId>
72+
<artifactId>quarkus-rest-client-jackson</artifactId>
5473
</dependency>
74+
75+
<!-- OpenAPI and Health -->
5576
<dependency>
5677
<groupId>io.quarkus</groupId>
5778
<artifactId>quarkus-smallrye-openapi</artifactId>
@@ -60,29 +81,47 @@
6081
<groupId>io.quarkus</groupId>
6182
<artifactId>quarkus-smallrye-health</artifactId>
6283
</dependency>
84+
85+
<!-- Dependency injection -->
6386
<dependency>
6487
<groupId>io.quarkus</groupId>
6588
<artifactId>quarkus-arc</artifactId>
6689
</dependency>
90+
91+
<!-- Container image building -->
6792
<dependency>
6893
<groupId>io.quarkus</groupId>
6994
<artifactId>quarkus-container-image-jib</artifactId>
7095
</dependency>
96+
97+
<!-- Testing dependencies: these are used for writing and running tests,
98+
including unit tests, integration tests, and end-to-end tests.
99+
They include libraries for testing frameworks, mocking, test containers, a
100+
nd Cucumber for BDD testing. -->
101+
<!-- Quarkus testing support -->
71102
<dependency>
72103
<groupId>io.quarkus</groupId>
73104
<artifactId>quarkus-junit</artifactId>
74105
<scope>test</scope>
75106
</dependency>
107+
<!-- REST-assured for testing REST endpoints -->
76108
<dependency>
77109
<groupId>io.rest-assured</groupId>
78110
<artifactId>rest-assured</artifactId>
79111
<scope>test</scope>
80112
</dependency>
113+
<!-- Mockito for mocking dependencies in tests -->
114+
<dependency>
115+
<groupId>org.mockito</groupId>
116+
<artifactId>mockito-core</artifactId>
117+
<scope>test</scope>
118+
</dependency>
81119
<dependency>
82120
<groupId>io.quarkus</groupId>
83121
<artifactId>quarkus-junit-mockito</artifactId>
84122
<scope>test</scope>
85123
</dependency>
124+
<!-- Testcontainers for integration testing with containers -->
86125
<dependency>
87126
<groupId>org.testcontainers</groupId>
88127
<artifactId>testcontainers</artifactId>
@@ -95,11 +134,10 @@
95134
<version>${testcontainers.version}</version>
96135
<scope>test</scope>
97136
</dependency>
98-
<dependency>
99-
<groupId>org.mockito</groupId>
100-
<artifactId>mockito-core</artifactId>
101-
<scope>test</scope>
102-
</dependency>
137+
<!-- Cucumber for Behavior Driven Development (BDD) testing -->
138+
<!-- quarkus-cucumber provides integration between Cucumber and Quarkus,
139+
allowing you to write BDD tests that can leverage Quarkus features
140+
and run in the same environment as your application -->
103141
<dependency>
104142
<groupId>io.quarkiverse.cucumber</groupId>
105143
<artifactId>quarkus-cucumber</artifactId>
@@ -122,8 +160,16 @@
122160
</dependencies>
123161

124162
<build>
163+
<!-- Plugin management: defines versions and configuration for plugins
164+
used in the build, such as the Quarkus Maven plugin for building the
165+
application, the Surefire plugin for running tests, and plugins for
166+
code quality and coverage analysis. -->
125167
<plugins>
126168
<plugin>
169+
<!-- Quarkus Maven plugin: used to build the Quarkus application,
170+
generate code, and create native images. It is configured to
171+
execute goals for building the application, generating code,
172+
and running the native image agent. -->
127173
<groupId>${quarkus.platform.group-id}</groupId>
128174
<artifactId>quarkus-maven-plugin</artifactId>
129175
<version>${quarkus.platform.version}</version>
@@ -139,6 +185,9 @@
139185
</execution>
140186
</executions>
141187
</plugin>
188+
<!-- Compiler plugin: used to compile the Java source code.
189+
It is configured to include parameter names in the compiled bytecode,
190+
which can be useful for reflection and testing. -->
142191
<plugin>
143192
<artifactId>maven-compiler-plugin</artifactId>
144193
<version>${compiler-plugin.version}</version>
@@ -165,7 +214,6 @@
165214
</configuration>
166215
</plugin>
167216

168-
169217
<!-- Failsafe / Integration Tests -->
170218
<plugin>
171219
<artifactId>maven-failsafe-plugin</artifactId>
@@ -193,7 +241,10 @@
193241
</configuration>
194242
</plugin>
195243

196-
<!-- Versions plugin: use organization rules.xml for dependency update rules -->
244+
<!-- Plugin to manage versions of dependencies and plugins, using organization-specific rules for updates
245+
can be used to check for outdated dependencies and suggest updates based on the rules defined in the provided rules.xml file
246+
247+
./mvn versions:display-property-updates -->
197248
<plugin>
198249
<groupId>org.codehaus.mojo</groupId>
199250
<artifactId>versions-maven-plugin</artifactId>
@@ -207,8 +258,12 @@
207258
</build>
208259

209260

261+
<!-- Profiles: these are different build configurations that can be activated based on certain conditions,
262+
such as the presence of specific properties. -->
210263
<profiles>
211-
<!-- Profil JVM -->
264+
<!-- Profile JVM: this profile is activated when the "jvm" property is set. It configures the build to create
265+
a JVM-based application package, build a container image using Jib, and load it into the local Docker registry. -->
266+
212267
<profile>
213268
<id>jvm</id>
214269
<properties>
@@ -219,10 +274,14 @@
219274
<quarkus.container-image.name>product-catalog</quarkus.container-image.name>
220275
<quarkus.container-image.tag>1.0.0-jvm</quarkus.container-image.tag>
221276
<quarkus.docker.dockerfile-jvm-path>src/main/docker/Dockerfile.jvm</quarkus.docker.dockerfile-jvm-path>
277+
<quarkus.jib.base-jvm-image>registry.access.redhat.com/ubi9/openjdk-21-runtime@sha256:20252d0fd32221be2c6ffa91c19f0344c80c8ce3f054a26a2d7492a172516e53</quarkus.jib.base-jvm-image>
278+
222279
</properties>
223280
</profile>
224281

225-
<!-- Profil Natif -->
282+
<!-- Profile Native: this profile is activated when the "native" property is set. It configures the build
283+
to create a native executable using GraalVM, build a container image using Jib, and load it into the local
284+
Docker registry. It also specifies the builder image to use for building the native executable. -->
226285
<profile>
227286
<id>native</id>
228287
<properties>
@@ -234,8 +293,7 @@
234293
<quarkus.container-image.group>brunoe</quarkus.container-image.group>
235294
<quarkus.container-image.name>product-catalog</quarkus.container-image.name>
236295
<quarkus.container-image.tag>1.0.0-native</quarkus.container-image.tag>
237-
238-
<quarkus.native.builder-image>quay.io/quarkus/ubi9-quarkus-mandrel-builder-image:jdk-21</quarkus.native.builder-image>
296+
<quarkus.jib.base-native-image>quay.io/quarkus/ubi9-quarkus-mandrel-builder-image:jdk-21</quarkus.jib.base-native-image>
239297
</properties>
240298
</profile>
241299

src/main/java/org/acme/api/v1/ProductResource.java renamed to src/main/java/org/acme/api/v1/ProductResourceV1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
@Produces(MediaType.APPLICATION_JSON)
2626
@Consumes(MediaType.APPLICATION_JSON)
2727
@Tag(name = "Product V1", description = "Basic memory-based API for M1 introduction")
28-
public class ProductResource {
28+
public class ProductResourceV1 {
2929

3030
/**
3131
* In-memory storage shared across all requests.

src/main/java/org/acme/api/v2/ProductResource.java renamed to src/main/java/org/acme/api/v2/ProductResourceV2.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
@Produces(MediaType.APPLICATION_JSON)
2828
@Consumes(MediaType.APPLICATION_JSON)
2929
@Tag(name = "Product V2", description = "Memory-based API with Path Params and Exceptions")
30-
public class ProductResource {
30+
public class ProductResourceV2 {
3131

3232
/**
3333
* Shared in-memory storage.
@@ -89,7 +89,7 @@ public Response deleteProduct(@PathParam("sku") String sku) {
8989
/**
9090
* Creates a new product.
9191
* * @param product Product to create.
92-
*
92+
*
9393
* @return 201 Created.
9494
* @throws WebApplicationException with 409 Conflict if SKU exists.
9595
*/

src/main/java/org/acme/api/v3/ProductResource.java renamed to src/main/java/org/acme/api/v3/ProductResourceV3.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
@Consumes(MediaType.APPLICATION_JSON)
3232
@Tag(name = "Product V3", description = "Service-based API with Dependency Injection")
3333
@RequestScoped
34-
public class ProductResource {
34+
public class ProductResourceV3 {
3535

3636
private final ProductServiceV3 service;
3737

@@ -42,7 +42,7 @@ public class ProductResource {
4242
* @param service Business service orchestrating the repository.
4343
*/
4444
@Inject
45-
public ProductResource(ProductServiceV3 service) {
45+
public ProductResourceV3(ProductServiceV3 service) {
4646
this.service = service;
4747
}
4848

src/main/java/org/acme/api/v4/ProductResource.java renamed to src/main/java/org/acme/api/v4/ProductResourceV4.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
@Consumes(MediaType.APPLICATION_JSON)
3232
@Tag(name = "Product V4", description = "API using DTOs to encapsulate the Domain model")
3333
@RequestScoped
34-
public class ProductResource {
34+
public class ProductResourceV4 {
3535

3636
private final ProductServiceV4 service;
3737

@@ -41,7 +41,7 @@ public class ProductResource {
4141
* @param service Business service handling V4 logic.
4242
*/
4343
@Inject
44-
public ProductResource(ProductServiceV4 service) {
44+
public ProductResourceV4(ProductServiceV4 service) {
4545
this.service = service;
4646
}
4747

src/main/java/org/acme/api/v5/ProductResource.java renamed to src/main/java/org/acme/api/v5/ProductResourceV5.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
@Consumes(MediaType.APPLICATION_JSON)
4141
@Tag(name = "Product V5", description = "Validated and documented production-ready API")
4242
@RequestScoped
43-
public class ProductResource {
43+
public class ProductResourceV5 {
4444

4545
private final ProductServiceV5 service;
4646

4747
@Inject
48-
public ProductResource(ProductServiceV5 service) {
48+
public ProductResourceV5(ProductServiceV5 service) {
4949
this.service = service;
5050
}
5151

src/main/resources/application.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ quarkus.swagger-ui.always-include=true
3535
# ==========================
3636
# Validates that the database is actually reachable
3737
quarkus.datasource.health.enabled=true
38-
# Add specific liveness check for the JVM
39-
quarkus.smallrye-health.liveness.checks.enabled=true
4038

4139
# ==========================
4240
# Logging

src/test/java/org/acme/api/cucumber/steps/ProductSteps.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ private void setResponse(Response response) {
6060
@Given("the product catalog is empty")
6161
public void theProductCatalogIsEmpty() {
6262
if (versionContext.getVersion().equals("v1"))
63-
org.acme.api.v1.ProductResource.clearProducts();
63+
org.acme.api.v1.ProductResourceV1.clearProducts();
6464
else if (versionContext.getVersion().equals("v2"))
65-
org.acme.api.v2.ProductResource.clearProducts();
65+
org.acme.api.v2.ProductResourceV2.clearProducts();
6666
else {
6767
// 1. Supprime tout
6868
repository.deleteAll();

src/test/java/org/acme/api/v1/ProductResourceV1IT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import static org.hamcrest.Matchers.*;
1414

1515
@QuarkusTest
16-
@TestHTTPEndpoint(ProductResource.class)
16+
@TestHTTPEndpoint(ProductResourceV1.class)
1717
@DisplayName("ProductResource v1 - In-Memory Tests")
1818
class ProductResourceV1IT {
1919

0 commit comments

Comments
 (0)