Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrading catalogue and user service to micronaut version 4.3.4 #73

Merged
merged 14 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 15 additions & 31 deletions .github/workflows/java-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches:
- main
env:
JAVA: '11'
JAVA: '21'
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -34,10 +34,10 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK
uses: actions/setup-java@v2
- name: Setup GraalVM
uses: graalvm/setup-[email protected]
with:
distribution: 'adopt'
distribution: 'graalvm'
java-version: ${{ env.JAVA }}
- name: Build and test
working-directory: src/${{ matrix.project-path }}
Expand Down Expand Up @@ -74,10 +74,10 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK
uses: actions/setup-java@v2
- name: Setup GraalVM
uses: graalvm/setup-[email protected]
with:
distribution: 'adopt'
distribution: 'graalvm'
java-version: ${{ env.JAVA }}
- name: Login to OCIR
uses: docker/login-action@v1
Expand All @@ -93,7 +93,7 @@ jobs:
if [ -f "mvnw" ]; then
# Install only the `lib` module to the local repository so it can be used for building the `app` image
./mvnw install -Drevision=$GITHUB_SHA -pl -app,-aws,-oci
./mvnw deploy -Dpackaging=docker -Djib.from.image=ghcr.io/graalvm/graalvm-ce:java11-21.1.0 -Ddocker.image.suffix=graalvm -Drevision=$GITHUB_SHA --no-transfer-progress -pl app
./mvnw deploy -Dpackaging=docker -Djib.from.image=ghcr.io/graalvm/native-image-community:21 -Ddocker.image.suffix=graalvm -Drevision=$GITHUB_SHA --no-transfer-progress -pl app
elif [ -f "gradlew" ]; then
./gradlew :app:dockerPush -Pversion=$GITHUB_SHA --no-daemon
fi
Expand All @@ -102,7 +102,6 @@ jobs:
needs: build-docker-compose-test-images
runs-on: self-hosted
steps:
- uses: AutoModality/action-clean@v1
- uses: actions/checkout@v2
- name: Login to OCIR
uses: docker/login-action@v1
Expand Down Expand Up @@ -164,18 +163,17 @@ jobs:
'assets'
]
steps:
- uses: AutoModality/action-clean@v1
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK
uses: actions/setup-java@v2
- name: Setup GraalVM
uses: graalvm/setup-[email protected]
with:
distribution: 'adopt'
distribution: 'graalvm'
java-version: ${{ env.JAVA }}
- name: Login to OCIR
uses: docker/login-action@v1
Expand All @@ -185,34 +183,20 @@ jobs:
password: ${{ secrets.OCI_TOKEN }}
logout: false

- name: Push docker image - GraalVM
- name: Push docker image - GraalVM Native Image
working-directory: src/${{ matrix.project-path }}
run: |
if [ -f "mvnw" ]; then
# Install only the `lib` module to the local repository so it can be used for building `app`, `aws` and `oci` GraalVM images
./mvnw install -pl -app,-aws,-oci
# Build and deploy `app`, `aws` and `oci` GraalVM images
./mvnw deploy -Dpackaging=docker -Djib.from.image=phx.ocir.io/oraclelabs/micronaut-showcase/mushop/base/graalvm-ce:java11-21.1.0 -Ddocker.image.suffix=graalvm --no-transfer-progress -pl app
./mvnw deploy -Dpackaging=docker -Djib.from.image=phx.ocir.io/oraclelabs/micronaut-showcase/mushop/base/graalvm-ce:java11-21.1.0 -Ddocker.image.suffix=graalvm --no-transfer-progress -pl aws
./mvnw deploy -Dpackaging=docker -Djib.from.image=phx.ocir.io/oraclelabs/micronaut-showcase/mushop/base/graalvm-ce:java11-21.1.0 -Ddocker.image.suffix=graalvm --no-transfer-progress -pl oci
./mvnw deploy -Dpackaging=docker -Djib.from.image=phx.ocir.io/oraclelabs/micronaut-showcase/mushop/base/native-image-community:21 -Ddocker.image.suffix=graalvm --no-transfer-progress -pl app
./mvnw deploy -Dpackaging=docker -Djib.from.image=phx.ocir.io/oraclelabs/micronaut-showcase/mushop/base/native-image-community:21 -Ddocker.image.suffix=graalvm --no-transfer-progress -pl aws
./mvnw deploy -Dpackaging=docker -Djib.from.image=phx.ocir.io/oraclelabs/micronaut-showcase/mushop/base/native-image-community:21 -Ddocker.image.suffix=graalvm --no-transfer-progress -pl oci
elif [ -f "gradlew" ]; then
./gradlew dockerPush --no-daemon
fi

- name: Push - docker image GraalVM Native Image
working-directory: src/${{ matrix.project-path }}
run: |
if [ -f "mvnw" ]; then
# Install only the `lib` module to the local repository so it can be used for building `app`, `aws` and `oci` images
./mvnw install -pl -app,-aws,-oci
# Build and deploy images one by one since the micronaut-maven-plugin doesn't support building of native images by executing `deploy` command on the parent in the multi module project
./mvnw deploy -Dpackaging=docker-native -Djib.from.image=phx.ocir.io/oraclelabs/micronaut-showcase/mushop/base/native:ol7-java11-22.2.0 -Ddocker.image.suffix=native --no-transfer-progress -Pgraalvm -pl app
./mvnw deploy -Dpackaging=docker-native -Djib.from.image=phx.ocir.io/oraclelabs/micronaut-showcase/mushop/base/native:ol7-java11-22.2.0 -Ddocker.image.suffix=native --no-transfer-progress -Pgraalvm -pl aws
./mvnw deploy -Dpackaging=docker-native -Djib.from.image=phx.ocir.io/oraclelabs/micronaut-showcase/mushop/base/native:ol7-java11-22.2.0 -Ddocker.image.suffix=native --no-transfer-progress -Pgraalvm -pl oci
elif [ -f "gradlew" ]; then
./gradlew dockerPushNative --no-daemon
fi

- name: Cleanup images
if: ${{ always() }}
run: docker image prune -a -f
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ installs/
**/.idea/**
**/node_modules/**
deploy/basic/terraform/image*
.micronaut/

# Log file
*.log
Expand Down
46 changes: 33 additions & 13 deletions src/catalogue/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("com.github.johnrengelman.shadow") version "7.1.2"
id("io.micronaut.application") version "3.6.2"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("io.micronaut.application") version "4.3.4"
id("io.micronaut.aot") version "4.3.4"
}

group = "micronaut.mushop"
Expand All @@ -16,16 +17,31 @@ micronaut {
incremental(true)
annotations("catalogue.*")
}
aot {
optimizeServiceLoading = false
convertYamlToJava = false
precomputeOperations = true
cacheEnvironment = true
optimizeClassLoading = true
deduceEnvironment = true
optimizeNetty = true
}
}

dependencies {
annotationProcessor("io.micronaut.micrometer:micronaut-micrometer-annotation")
annotationProcessor("io.micronaut.data:micronaut-data-processor")
annotationProcessor("io.micronaut.openapi:micronaut-openapi")
annotationProcessor("io.micronaut:micronaut-http-validation")
annotationProcessor("io.micronaut.serde:micronaut-serde-processor")
annotationProcessor("io.micronaut.tracing:micronaut-tracing-opentelemetry-annotation")
annotationProcessor("io.micronaut.validation:micronaut-validation-processor")

implementation("io.micronaut:micronaut-http-client")
implementation("io.micronaut:micronaut-runtime")
implementation("io.micronaut:micronaut-validation")
implementation("io.micronaut:micronaut-retry")
implementation("io.micronaut.serde:micronaut-serde-jackson")
implementation("io.micronaut.validation:micronaut-validation")
implementation("jakarta.validation:jakarta.validation-api")

// Metrics
implementation("io.micronaut:micronaut-management")
Expand All @@ -39,31 +55,35 @@ dependencies {
runtimeOnly("com.h2database:h2")

// Tracing
implementation("io.micronaut.tracing:micronaut-tracing-core")
implementation("io.micronaut.tracing:micronaut-tracing-zipkin")

implementation("io.swagger.core.v3:swagger-annotations")

runtimeOnly("ch.qos.logback:logback-classic")
implementation("io.micronaut.tracing:micronaut-tracing-opentelemetry-http")
implementation("io.opentelemetry:opentelemetry-exporter-zipkin")



// Caching
implementation("io.micronaut.cache:micronaut-cache-caffeine")

compileOnly("io.micronaut.openapi:micronaut-openapi-annotations")

runtimeOnly("ch.qos.logback:logback-classic")
runtimeOnly("org.yaml:snakeyaml")

testImplementation(project(":tck"))

}

application {
mainClass.set("catalogue.Application")
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.toVersion("21")
targetCompatibility = JavaVersion.toVersion("21")
}

if (javaBaseImage == "graalvm") {
dockerfile {
baseImage = "ghcr.io/graalvm/graalvm-ce:ol8-java11-21.1.0"
baseImage = "ghcr.io/graalvm/native-image-community:21"
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package catalogue.controllers;

import io.micronaut.core.annotation.Introspected;
import io.micronaut.serde.annotation.Serdeable;

/**
* Represents a product in the catalog
*/
@Introspected
@Serdeable
public class CatalogueItemDTO {

private final String id;
Expand Down Expand Up @@ -46,77 +46,88 @@ public CatalogueItemDTO(
}

/**
* The id of the product
* The id of the product
* @return The id of the product
*/
public String getId() {
return id;
}

/**
* The brand of the product
* @return The brand of the product
*/
public String getBrand() {
return brand;
}

/**
* The title of the product
* @return The title of the product
*/
public String getTitle() {
return title;
}

/**
* The description of the product
* @return The description of the product
*/
public String getDescription() {
return description;
}

/**
* The weight of the product
* @return The weight of the product
*/
public String getWeight() {
return weight;
}

/**
* The size of the product
* @return The size of the product
*/
public String getProductSize() {
return productSize;
}

/**
* The available colors of the product
* @return The available colors of the product
*/
public String getColors() {
return colors;
}

/**
* The quantity of the product
* @return The quantity of the product
*/
public int getQty() {
return qty;
}

/**
* The price of the product
* @return The price of the product
*/
public double getPrice() {
return price;
}

/**
* An array of size 2 with the first image being the thumbnail and the second the full size image
* @return An array of size 2 with the first image being the thumbnail and the second the full size image
*/
public String[] getImageUrl() {
return imageUrl;
}

/**
* The categories of the image
* @return The categories of the image
*/
public String[] getCategory() {
return category;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package catalogue.controllers;

import io.micronaut.core.annotation.Introspected;

import io.micronaut.serde.annotation.Serdeable;

/**
* Returns the size of the catalogue
*/
@Introspected
@Serdeable
public class CatalogueSizeDTO {

private final int size;
Expand All @@ -16,6 +17,7 @@ public CatalogueSizeDTO(int size) {

/**
* The size of the catalogue
* @return The size of the catalogue
*/
public int getSize() {
return size;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package catalogue.controllers;

import io.micronaut.core.annotation.Introspected;
import io.micronaut.serde.annotation.Serdeable;

import java.util.List;

/**
* Lists the available categories
*/
@Introspected
@Serdeable
public class CategoriesDTO {

private final String[] categories;
Expand Down
4 changes: 2 additions & 2 deletions src/catalogue/app/src/main/java/catalogue/db/DbSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.slf4j.LoggerFactory;

import javax.sql.DataSource;
import javax.transaction.Transactional;
import jakarta.transaction.Transactional;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -44,7 +44,7 @@ public DbSetup(DataSource dataSource,

@EventListener
@Transactional
void init(StartupEvent startupEvent) {
void onStartupEvent(StartupEvent startupEvent) {
ChaimaaeROUAI marked this conversation as resolved.
Show resolved Hide resolved
if (repository.count() > 0) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import io.micronaut.data.annotation.Id;
import io.micronaut.data.annotation.MappedEntity;

import javax.validation.constraints.Size;
import jakarta.validation.constraints.Size;
import java.util.Objects;

@MappedEntity("CATEGORIES")
Expand Down
6 changes: 3 additions & 3 deletions src/catalogue/app/src/main/java/catalogue/model/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import io.micronaut.data.annotation.MappedEntity;
import io.micronaut.data.annotation.MappedProperty;
import io.micronaut.data.annotation.Relation;
import io.micronaut.data.jdbc.annotation.JoinColumn;
import io.micronaut.data.jdbc.annotation.JoinTable;
import io.micronaut.data.annotation.sql.JoinColumn;
import io.micronaut.data.annotation.sql.JoinTable;

import javax.validation.constraints.Size;
import jakarta.validation.constraints.Size;
import java.util.Collections;
import java.util.List;

Expand Down
Loading
Loading