Skip to content

Commit

Permalink
Merge pull request #76 from oracle-quickstart/assets-to-micronaut4
Browse files Browse the repository at this point in the history
Upgrading the assets service to Micronaut version 4
  • Loading branch information
ChaimaaeROUAI authored Apr 15, 2024
2 parents c021111 + a5bc873 commit 346b3f5
Show file tree
Hide file tree
Showing 12 changed files with 331 additions and 284 deletions.
183 changes: 101 additions & 82 deletions src/assets/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,82 +1,101 @@
plugins {
id("com.github.johnrengelman.shadow") version "7.1.2"
id("io.micronaut.application") version "3.6.2"
}

group = "micronaut.mushop"

repositories {
mavenCentral()
}

micronaut {
runtime("netty")
testRuntime("junit5")
processing {
incremental(true)
annotations("assets.*")
}
}

dependencies {
annotationProcessor("io.micronaut.openapi:micronaut-openapi")

implementation("io.micronaut:micronaut-http-client")
implementation("io.micronaut:micronaut-runtime")
implementation("io.micronaut:micronaut-validation")

// Metrics
implementation("io.micronaut:micronaut-management")
implementation("io.micronaut.micrometer:micronaut-micrometer-core")
implementation("io.micronaut.micrometer:micronaut-micrometer-registry-prometheus")

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

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

implementation("io.micronaut.objectstorage:micronaut-object-storage-core:1.1.0")

runtimeOnly("ch.qos.logback:logback-classic")

testImplementation(project(":tck"))
}

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

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

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

dockerBuild {
images = ["phx.ocir.io/oraclelabs/micronaut-showcase/mushop/$project.parent.name-$project.name-${javaBaseImage}:$project.version"]
}

dockerBuildNative {
images = ["phx.ocir.io/oraclelabs/micronaut-showcase/mushop/${project.parent.name}-${project.name}-native:$project.version"]
}

processResources {
def assetPaths = []
eachFile {details ->
if (details.path.contains("assets")) {
assetPaths << details.path.minus("assets/")
}
}
doLast {
File assetsFile = new File("$destinationDir/assets/manifest.txt")
assetsFile.withWriter{ out ->
assetPaths.each {out.println it}
}
}
}
plugins {
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"

repositories {
mavenCentral()
}

micronaut {
runtime("netty")
testRuntime("junit5")
processing {
incremental(true)
annotations("assets.*")
}
aot {
optimizeServiceLoading = false
convertYamlToJava = false
precomputeOperations = true
cacheEnvironment = true
optimizeClassLoading = true
deduceEnvironment = true
optimizeNetty = true
}
}

dependencies {
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.serde:micronaut-serde-jackson")
implementation("io.micronaut.validation:micronaut-validation")
implementation("jakarta.validation:jakarta.validation-api")

// Metrics
implementation("io.micronaut:micronaut-management")
implementation("io.micronaut.micrometer:micronaut-micrometer-core")
implementation("io.micronaut.micrometer:micronaut-micrometer-registry-prometheus")

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

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

implementation("io.micronaut.objectstorage:micronaut-object-storage-core")

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

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

testImplementation(project(":tck"))
}

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

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

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

dockerBuild {
images = ["phx.ocir.io/oraclelabs/micronaut-showcase/mushop/$project.parent.name-$project.name-${javaBaseImage}:$project.version"]
}

dockerBuildNative {
images = ["phx.ocir.io/oraclelabs/micronaut-showcase/mushop/${project.parent.name}-${project.name}-native:$project.version"]
}

processResources {
def assetPaths = []
eachFile {details ->
if (details.path.contains("assets")) {
assetPaths << details.path.minus("assets/")
}
}
doLast {
File assetsFile = new File("$destinationDir/assets/manifest.txt")
assetsFile.withWriter{ out ->
assetPaths.each {out.println it}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package assets.controllers;

import io.micronaut.core.annotation.Introspected;

@Introspected
public class AssetLocationDTO {

private final String productImagePath;

public AssetLocationDTO(String productImagePath) {
this.productImagePath = productImagePath;
}

public String getProductImagePath() {
return productImagePath;
}
}
package assets.controllers;

import io.micronaut.serde.annotation.Serdeable;

@Serdeable
public class AssetLocationDTO {

private final String productImagePath;

public AssetLocationDTO(String productImagePath) {
this.productImagePath = productImagePath;
}

public String getProductImagePath() {
return productImagePath;
}
}
29 changes: 14 additions & 15 deletions src/assets/app/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<withJansi>true</withJansi>
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern>
</encoder>
</appender>

<root level="info">
<appender-ref ref="STDOUT" />
</root>
</configuration>
<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern>
</encoder>
</appender>

<root level="info">
<appender-ref ref="STDOUT" />
</root>
</configuration>
134 changes: 72 additions & 62 deletions src/assets/aws/build.gradle
Original file line number Diff line number Diff line change
@@ -1,62 +1,72 @@
plugins {
id("com.github.johnrengelman.shadow") version "7.1.2"
id("io.micronaut.application") version "3.6.2"
}

group = "micronaut.mushop"

repositories {
mavenCentral()
}

micronaut {
runtime("netty")
testRuntime("junit5")
processing {
incremental(true)
annotations("assets.*")
}
}

dependencies {
implementation(project(":app"))

// Authentication
implementation("software.amazon.awssdk:sts")

// Configuration discovery
implementation("io.micronaut.aws:micronaut-aws-parameter-store")

// Metrics
implementation("io.micronaut.micrometer:micronaut-micrometer-registry-cloudwatch")

// Object Storage
implementation("io.micronaut.aws:micronaut-aws-sdk-v2")
implementation("io.micronaut.objectstorage:micronaut-object-storage-aws:1.1.0")

testImplementation(project(":tck"))
testImplementation("org.mockito:mockito-core")
}

application {
mainClass.set("assets.AwsApplication")
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

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

dockerBuild {
images = ["phx.ocir.io/oraclelabs/micronaut-showcase/mushop/$project.parent.name-$project.name-${javaBaseImage}:$project.version"]
}

dockerBuildNative {
images = ["phx.ocir.io/oraclelabs/micronaut-showcase/mushop/${project.parent.name}-${project.name}-native:$project.version"]
}
plugins {
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"

repositories {
mavenCentral()
}

micronaut {
runtime("netty")
testRuntime("junit5")
processing {
incremental(true)
annotations("assets.*")
}
aot {
optimizeServiceLoading = false
convertYamlToJava = false
precomputeOperations = true
cacheEnvironment = true
optimizeClassLoading = true
deduceEnvironment = true
optimizeNetty = true
}
}

dependencies {
implementation(project(":app"))

// Authentication
implementation("software.amazon.awssdk:sts")

// Configuration discovery
implementation("io.micronaut.aws:micronaut-aws-parameter-store")

// Metrics
implementation("io.micronaut.micrometer:micronaut-micrometer-registry-cloudwatch")

// Object Storage
implementation("io.micronaut.aws:micronaut-aws-sdk-v2")
implementation("io.micronaut.objectstorage:micronaut-object-storage-aws")

testImplementation(project(":tck"))
testImplementation("org.mockito:mockito-core")
}

application {
mainClass.set("assets.AwsApplication")
}

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

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

dockerBuild {
images = ["phx.ocir.io/oraclelabs/micronaut-showcase/mushop/$project.parent.name-$project.name-${javaBaseImage}:$project.version"]
}

dockerBuildNative {
images = ["phx.ocir.io/oraclelabs/micronaut-showcase/mushop/${project.parent.name}-${project.name}-native:$project.version"]
}
6 changes: 3 additions & 3 deletions src/assets/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
micronautVersion=3.7.3
version=2.0.0-SNAPSHOT
javaBaseImage=graalvm
micronautVersion=4.3.4
version=2.0.0-SNAPSHOT
javaBaseImage=graalvm
Binary file modified src/assets/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion src/assets/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 346b3f5

Please sign in to comment.