diff --git a/src/fulfillment/app/build.gradle b/src/fulfillment/app/build.gradle index d5037126..b820308d 100644 --- a/src/fulfillment/app/build.gradle +++ b/src/fulfillment/app/build.gradle @@ -1,76 +1,96 @@ -plugins { - id("groovy") - 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("spock2") - processing { - incremental(true) - annotations("mushop.*") - } -} - -dependencies { - annotationProcessor("io.micronaut.micrometer:micronaut-micrometer-annotation") - 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") - - // NATS - implementation("io.micronaut.nats:micronaut-nats") - - // Swagger - implementation("io.swagger.core.v3:swagger-annotations") - - runtimeOnly("ch.qos.logback:logback-classic") - - testImplementation(project(":tck")) - testImplementation("org.testcontainers:testcontainers") -} - -application { - mainClass.set("mushop.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"] -} - -dockerfileNative { - instruction "RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.11/main' >> /etc/apk/repositories && apk update && apk add 'zlib<1.2.12'" -} +plugins { + id("groovy") + 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" + id("io.micronaut.test-resources") version "4.3.4" +} + +group = "micronaut.mushop" + +repositories { + mavenCentral() +} + +micronaut { + runtime("netty") + testRuntime("spock2") + processing { + incremental(true) + annotations("mushop.*") + } + 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.openapi:micronaut-openapi") + annotationProcessor("io.micronaut.serde:micronaut-serde-processor") + annotationProcessor("io.micronaut.validation:micronaut-validation-processor") + + implementation("io.micronaut:micronaut-retry") + implementation("io.micronaut.serde:micronaut-serde-jackson") + implementation("io.micronaut:micronaut-http-client") + implementation("io.micronaut:micronaut-runtime") + implementation("io.micronaut.validation: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-brave") + implementation("io.micronaut.tracing:micronaut-tracing-brave-http") + + // NATS + implementation("io.micronaut.nats:micronaut-nats") + + // Swagger + implementation("io.swagger.core.v3:swagger-annotations") + + compileOnly("io.micronaut:micronaut-http-client") + compileOnly("io.micronaut:micronaut-http-validation") + compileOnly("io.micronaut.serde:micronaut-serde-processor") + + runtimeOnly("ch.qos.logback:logback-classic") + runtimeOnly("org.yaml:snakeyaml") + + testImplementation(project(":tck")) +} + +application { + mainClass.set("mushop.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"] +} + +dockerfileNative { + instruction "RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.11/main' >> /etc/apk/repositories && apk update && apk add 'zlib<1.2.12'" +} \ No newline at end of file diff --git a/src/fulfillment/app/src/main/java/mushop/OrderUpdate.java b/src/fulfillment/app/src/main/java/mushop/OrderUpdate.java index a7811d8d..72553d37 100644 --- a/src/fulfillment/app/src/main/java/mushop/OrderUpdate.java +++ b/src/fulfillment/app/src/main/java/mushop/OrderUpdate.java @@ -1,43 +1,43 @@ -/** - ** Copyright © 2020, Oracle and/or its affiliates. All rights reserved. - ** Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. - **/ -package mushop; - -import io.micronaut.core.annotation.Introspected; -import io.micronaut.core.annotation.Nullable; - -/** - * The messaging business object. - */ -@Introspected -public class OrderUpdate { - - private final Long orderId; - private Shipment shipment; - - public OrderUpdate(Long orderId, @Nullable Shipment shipment) { - this.orderId = orderId; - this.shipment = shipment; - } - - public Long getOrderId() { - return orderId; - } - - public Shipment getShipment() { - return shipment; - } - - public void setShipment(Shipment shipment) { - this.shipment = shipment; - } - - @Override - public String toString() { - return "OrderUpdate{" + - "orderId='" + orderId + '\'' + - ", shipment=" + shipment + - '}'; - } -} +/** + ** Copyright © 2020, Oracle and/or its affiliates. All rights reserved. + ** Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. + **/ +package mushop; + +import io.micronaut.serde.annotation.Serdeable; +import io.micronaut.core.annotation.Nullable; + +/** + * The messaging business object. + */ +@Serdeable +public class OrderUpdate { + + private final Long orderId; + private Shipment shipment; + + public OrderUpdate(Long orderId, @Nullable Shipment shipment) { + this.orderId = orderId; + this.shipment = shipment; + } + + public Long getOrderId() { + return orderId; + } + + public Shipment getShipment() { + return shipment; + } + + public void setShipment(Shipment shipment) { + this.shipment = shipment; + } + + @Override + public String toString() { + return "OrderUpdate{" + + "orderId='" + orderId + '\'' + + ", shipment=" + shipment + + '}'; + } +} diff --git a/src/fulfillment/app/src/main/java/mushop/Shipment.java b/src/fulfillment/app/src/main/java/mushop/Shipment.java index 1ca09a95..ca0d966d 100644 --- a/src/fulfillment/app/src/main/java/mushop/Shipment.java +++ b/src/fulfillment/app/src/main/java/mushop/Shipment.java @@ -1,38 +1,38 @@ -/** - ** Copyright © 2020, Oracle and/or its affiliates. All rights reserved. - ** Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. - **/ -package mushop; - -import io.micronaut.core.annotation.Introspected; - -/** - * The messaging business object. - */ -@Introspected -public class Shipment { - - private final String id; - private final String name; - - public Shipment(String id, String name) { - this.id = id; - this.name = name; - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - @Override - public String toString() { - return "Shipment{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - '}'; - } -} +/** + ** Copyright © 2020, Oracle and/or its affiliates. All rights reserved. + ** Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. + **/ +package mushop; + +import io.micronaut.serde.annotation.Serdeable; + +/** + * The messaging business object. + */ +@Serdeable +public class Shipment { + + private final String id; + private final String name; + + public Shipment(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + @Override + public String toString() { + return "Shipment{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + '}'; + } +} diff --git a/src/fulfillment/app/src/main/resources/application.yml b/src/fulfillment/app/src/main/resources/application.yml index 57145784..61a864fc 100644 --- a/src/fulfillment/app/src/main/resources/application.yml +++ b/src/fulfillment/app/src/main/resources/application.yml @@ -1,37 +1,45 @@ -micronaut: - application: - name: fulfillment - server: - port: 8082 - metrics: - enabled: true - export: - prometheus: - enabled: true - descriptions: true - step: PT1M - router: - static-resources: - swagger: - paths: classpath:META-INF/swagger - mapping: /swagger/** - -endpoints: - health: - enabled: true - sensitive: false - details-visible: ANONYMOUS - prometheus: - enabled: true - sensitive: false - details-visible: ANONYMOUS - -mushop: - messaging: - subjects: - orders: ${ORDERS_NEW:mushop-orders} - shipments: ${ORDERS_SHIPPED:mushop-shipments} - -nats: - addresses: - - nats://${NATS_HOST:localhost}:${NATS_PORT:4222} +micronaut: + application: + name: fulfillment + server: + port: 8082 + metrics: + enabled: true + export: + prometheus: + enabled: true + descriptions: true + step: PT1M + router: + static-resources: + swagger: + paths: classpath:META-INF/swagger + mapping: /swagger/** + +endpoints: + health: + enabled: true + sensitive: false + details-visible: ANONYMOUS + prometheus: + enabled: true + sensitive: false + details-visible: ANONYMOUS + +mushop: + messaging: + subjects: + orders: ${ORDERS_NEW:mushop-orders} + shipments: ${ORDERS_SHIPPED:mushop-shipments} +test-resources: + containers: + nats: + image-name: nats:latest + hostnames: + - nats.host + exposed-ports: + - nats.port: 4222 +nats: + default: + addresses: + - "nats://${nats.host}:${nats.port}" \ No newline at end of file diff --git a/src/fulfillment/app/src/main/resources/logback.xml b/src/fulfillment/app/src/main/resources/logback.xml index 6010eb52..2c2421a9 100644 --- a/src/fulfillment/app/src/main/resources/logback.xml +++ b/src/fulfillment/app/src/main/resources/logback.xml @@ -1,15 +1,14 @@ - - - - true - - - %cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n - - - - - - - + + + + + + %cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n + + + + + + + diff --git a/src/fulfillment/aws/build.gradle b/src/fulfillment/aws/build.gradle index b3a15923..3529eba1 100644 --- a/src/fulfillment/aws/build.gradle +++ b/src/fulfillment/aws/build.gradle @@ -1,57 +1,68 @@ -plugins { - id("groovy") - 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("spock2") - processing { - incremental(true) - annotations("mushop.*") - } -} - -dependencies { - implementation(project(":app")) - - // Metrics - implementation("io.micronaut.micrometer:micronaut-micrometer-registry-cloudwatch") - - testImplementation(project(":tck")) - testImplementation("org.testcontainers:testcontainers") -} - -application { - mainClass.set("mushop.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"] -} - -dockerfileNative { - instruction "RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.11/main' >> /etc/apk/repositories && apk update && apk add 'zlib<1.2.12'" -} +plugins { + id("groovy") + id("com.github.johnrengelman.shadow") version "8.1.1" + id("io.micronaut.application") version "4.3.4" + id("io.micronaut.aot") version "4.3.3" + id("io.micronaut.test-resources") version "4.3.4" +} + +group = "micronaut.mushop" + +repositories { + mavenCentral() +} + +micronaut { + runtime("netty") + testRuntime("spock2") + processing { + incremental(true) + annotations("mushop.*") + } + aot { + optimizeServiceLoading = false + convertYamlToJava = false + precomputeOperations = true + cacheEnvironment = true + optimizeClassLoading = true + deduceEnvironment = true + optimizeNetty = true + } +} + +dependencies { + implementation(project(":app")) + // Metrics + implementation("io.micronaut.micrometer:micronaut-micrometer-registry-cloudwatch") + + testImplementation(project(":tck")) + testImplementation("org.testcontainers:testcontainers") + testImplementation("io.micronaut:micronaut-http-client") +} + +application { + mainClass.set("mushop.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"] +} + +dockerfileNative { + instruction "RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.11/main' >> /etc/apk/repositories && apk update && apk add 'zlib<1.2.12'" +} diff --git a/src/fulfillment/buildSrc/build.gradle b/src/fulfillment/buildSrc/build.gradle new file mode 100644 index 00000000..984863e3 --- /dev/null +++ b/src/fulfillment/buildSrc/build.gradle @@ -0,0 +1,13 @@ + +plugins { + id 'groovy-gradle-plugin' +} + +repositories { + mavenCentral() + gradlePluginPortal() +} + +dependencies { + implementation("com.bmuschko:gradle-docker-plugin:9.4.0") +} \ No newline at end of file diff --git a/src/fulfillment/gradle.properties b/src/fulfillment/gradle.properties index b4655753..4fef5403 100644 --- a/src/fulfillment/gradle.properties +++ b/src/fulfillment/gradle.properties @@ -1,4 +1,4 @@ -micronautVersion=3.7.3 -version=2.0.0-SNAPSHOT -javaBaseImage=graalvm -swagger-ui.enabled=true +micronautVersion=4.3.4 +version=2.0.0-SNAPSHOT +javaBaseImage=graalvm +swagger-ui.enabled=true diff --git a/src/fulfillment/gradle/wrapper/gradle-wrapper.jar b/src/fulfillment/gradle/wrapper/gradle-wrapper.jar index 249e5832..d64cd491 100644 Binary files a/src/fulfillment/gradle/wrapper/gradle-wrapper.jar and b/src/fulfillment/gradle/wrapper/gradle-wrapper.jar differ diff --git a/src/fulfillment/gradle/wrapper/gradle-wrapper.properties b/src/fulfillment/gradle/wrapper/gradle-wrapper.properties index ae04661e..a80b22ce 100644 --- a/src/fulfillment/gradle/wrapper/gradle-wrapper.properties +++ b/src/fulfillment/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/src/fulfillment/gradlew b/src/fulfillment/gradlew index a69d9cb6..1aa94a42 100755 --- a/src/fulfillment/gradlew +++ b/src/fulfillment/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +131,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/src/fulfillment/gradlew.bat b/src/fulfillment/gradlew.bat index f127cfd4..7101f8e4 100755 --- a/src/fulfillment/gradlew.bat +++ b/src/fulfillment/gradlew.bat @@ -1,91 +1,92 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/fulfillment/oci/build.gradle b/src/fulfillment/oci/build.gradle index f13c2e91..20cafa69 100644 --- a/src/fulfillment/oci/build.gradle +++ b/src/fulfillment/oci/build.gradle @@ -1,57 +1,54 @@ -plugins { - id("groovy") - 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("spock2") - processing { - incremental(true) - annotations("mushop.*") - } -} - -dependencies { - implementation(project(":app")) - - // Metrics - implementation("io.micronaut.oraclecloud:micronaut-oraclecloud-micrometer") - - testImplementation(project(":tck")) - testImplementation("org.testcontainers:testcontainers") -} - -application { - mainClass.set("mushop.OciApplication") -} - -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"] -} - -dockerfileNative { - instruction "RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.11/main' >> /etc/apk/repositories && apk update && apk add 'zlib<1.2.12'" -} +plugins { + id("groovy") + id("com.github.johnrengelman.shadow") version "8.1.1" + id("io.micronaut.application") version "4.3.4" + id("io.micronaut.test-resources") version "4.3.4" +} + +group = "micronaut.mushop" + +repositories { + mavenCentral() +} + +micronaut { + runtime("netty") + testRuntime("spock2") + processing { + incremental(true) + annotations("mushop.*") + } +} + +dependencies { + implementation(project(":app")) + + // Metrics + implementation("io.micronaut.oraclecloud:micronaut-oraclecloud-micrometer") + + testImplementation(project(":tck")) + testImplementation("io.micronaut:micronaut-http-client") +} + +application { + mainClass.set("mushop.OciApplication") +} + +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"] +} diff --git a/src/fulfillment/settings.gradle b/src/fulfillment/settings.gradle index 0ef17145..7912ac2b 100644 --- a/src/fulfillment/settings.gradle +++ b/src/fulfillment/settings.gradle @@ -1,9 +1,6 @@ -rootProject.name="fulfillment" - -include "app" -include "aws" -include "oci" -include "tck" - -startParameter.excludedTaskNames << ':tck:dockerPush' -startParameter.excludedTaskNames << ':tck:dockerPushNative' +rootProject.name="fulfillment" + +include "app" +include "aws" +include "oci" +include "tck" \ No newline at end of file diff --git a/src/fulfillment/tck/build.gradle b/src/fulfillment/tck/build.gradle index 2d5a451d..ec7fdf3e 100644 --- a/src/fulfillment/tck/build.gradle +++ b/src/fulfillment/tck/build.gradle @@ -1,20 +1,19 @@ -plugins { - id("groovy") - id("io.micronaut.application") version "3.6.2" -} - -group = "micronaut.mushop" - -repositories { - mavenCentral() -} - -dependencies { - implementation(project(":app")) - implementation("io.micronaut:micronaut-http-client") - implementation("io.micronaut.nats:micronaut-nats") - implementation("io.micronaut:micronaut-inject-groovy") - implementation("io.micronaut.test:micronaut-test-spock") - implementation("org.testcontainers:spock") - implementation("org.testcontainers:testcontainers") -} +plugins { + id("groovy") + id("io.micronaut.application") version "4.3.4" +} + +group = "micronaut.mushop" + +repositories { + mavenCentral() +} + +dependencies { + implementation(project(":app")) + implementation("io.micronaut:micronaut-http-client") + implementation("io.micronaut.nats:micronaut-nats") + implementation("io.micronaut:micronaut-inject-groovy") + implementation("io.micronaut.test:micronaut-test-spock") + implementation("org.testcontainers:spock") +} \ No newline at end of file diff --git a/src/fulfillment/tck/src/main/groovy/mushop/AbstractFulfillmentControllerSpec.groovy b/src/fulfillment/tck/src/main/groovy/mushop/AbstractFulfillmentControllerSpec.groovy index 7d175fd0..2289ea63 100644 --- a/src/fulfillment/tck/src/main/groovy/mushop/AbstractFulfillmentControllerSpec.groovy +++ b/src/fulfillment/tck/src/main/groovy/mushop/AbstractFulfillmentControllerSpec.groovy @@ -1,21 +1,22 @@ -/** - * Copyright © 2020, Oracle and/or its affiliates. All rights reserved. - * Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. - **/ -package mushop - -import io.micronaut.http.client.HttpClient -import io.micronaut.http.client.annotation.Client -import jakarta.inject.Inject - -abstract class AbstractFulfillmentControllerSpec extends AbstractFulfillmentSpec { - - @Inject - @Client("/fulfillment") - HttpClient httpClient - - void 'test Fulfillment Controller'() { - expect: - httpClient.toBlocking().retrieve("/123") == "Order 123 is fulfilled" - } -} +/** + * Copyright © 2020, Oracle and/or its affiliates. All rights reserved. + * Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. + **/ +package mushop + +import io.micronaut.http.client.HttpClient +import io.micronaut.http.client.annotation.Client +import jakarta.inject.Inject +import spock.lang.Specification + +abstract class AbstractFulfillmentControllerSpec extends Specification { + + @Inject + @Client("/fulfillment") + HttpClient httpClient + + void 'test Fulfillment Controller'() { + expect: + httpClient.toBlocking().retrieve("/123") == "Order 123 is fulfilled" + } +} diff --git a/src/fulfillment/tck/src/main/groovy/mushop/AbstractFulfillmentListenerSpec.groovy b/src/fulfillment/tck/src/main/groovy/mushop/AbstractFulfillmentListenerSpec.groovy index 90172bff..18f91db3 100644 --- a/src/fulfillment/tck/src/main/groovy/mushop/AbstractFulfillmentListenerSpec.groovy +++ b/src/fulfillment/tck/src/main/groovy/mushop/AbstractFulfillmentListenerSpec.groovy @@ -1,50 +1,51 @@ -/** - * Copyright © 2020, Oracle and/or its affiliates. All rights reserved. - * Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. - **/ -package mushop - -import io.micronaut.http.client.HttpClient -import io.micronaut.http.client.annotation.Client -import io.micronaut.nats.annotation.NatsListener -import io.micronaut.nats.annotation.Subject -import jakarta.inject.Inject -import spock.util.concurrent.AsyncConditions - -abstract class AbstractFulfillmentListenerSpec extends AbstractFulfillmentSpec { - - @Inject - @Client("/fulfillment") - HttpClient httpClient - - @Inject - ShipmentListener shipmentListener - - @Inject - OrdersPublisher ordersPublisher - - void 'test it adds shipment details to order'() { - given: - def asyncCond = new AsyncConditions() - shipmentListener.setAsyncConditions(asyncCond) - - when: - ordersPublisher.publishOrder(new OrderUpdate(123, null)) - - then: - asyncCond.await() - } - - @NatsListener - static class ShipmentListener { - AsyncConditions asyncConditions - - @Subject("mushop-shipments") - void handleShipment(OrderUpdate orderUpdate) { - assert asyncConditions - asyncConditions.evaluate(() -> { - assert orderUpdate.shipment - }) - } - } -} +/** + * Copyright © 2020, Oracle and/or its affiliates. All rights reserved. + * Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. + **/ +package mushop + +import io.micronaut.http.client.HttpClient +import io.micronaut.http.client.annotation.Client +import io.micronaut.nats.annotation.NatsListener +import io.micronaut.nats.annotation.Subject +import jakarta.inject.Inject +import spock.lang.Specification +import spock.util.concurrent.AsyncConditions + +abstract class AbstractFulfillmentListenerSpec extends Specification { + + @Inject + @Client("/fulfillment") + HttpClient httpClient + + @Inject + ShipmentListener shipmentListener + + @Inject + OrdersPublisher ordersPublisher + + void 'test it adds shipment details to order'() { + given: + def asyncCond = new AsyncConditions() + shipmentListener.setAsyncConditions(asyncCond) + + when: + ordersPublisher.publishOrder(new OrderUpdate(123, null)) + + then: + asyncCond.await() + } + + @NatsListener + static class ShipmentListener { + AsyncConditions asyncConditions + + @Subject("mushop-shipments") + void handleShipment(OrderUpdate orderUpdate) { + assert asyncConditions + asyncConditions.evaluate(() -> { + assert orderUpdate.shipment + }) + } + } +} diff --git a/src/fulfillment/tck/src/main/groovy/mushop/AbstractFulfillmentSpec.groovy b/src/fulfillment/tck/src/main/groovy/mushop/AbstractFulfillmentSpec.groovy deleted file mode 100644 index 849eb9ce..00000000 --- a/src/fulfillment/tck/src/main/groovy/mushop/AbstractFulfillmentSpec.groovy +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2021 original authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package mushop - -import io.micronaut.core.annotation.NonNull -import io.micronaut.test.support.TestPropertyProvider -import org.testcontainers.containers.GenericContainer -import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy -import spock.lang.Specification - -abstract class AbstractFulfillmentSpec extends Specification implements TestPropertyProvider { - - static GenericContainer natsContainer = - new GenericContainer("nats:latest") - .withExposedPorts(4222) - .waitingFor(new LogMessageWaitStrategy().withRegEx("(?s).*Server is ready.*")) - - static { - natsContainer.start() - } - - @NonNull - Map getProperties() { - return ["nats.addresses": "nats://${natsContainer.getHost()}:${natsContainer.getMappedPort(4222)}"] - } -} diff --git a/src/fulfillment/tck/src/main/groovy/mushop/OrdersPublisher.groovy b/src/fulfillment/tck/src/main/groovy/mushop/OrdersPublisher.groovy index 9de69788..0869b334 100644 --- a/src/fulfillment/tck/src/main/groovy/mushop/OrdersPublisher.groovy +++ b/src/fulfillment/tck/src/main/groovy/mushop/OrdersPublisher.groovy @@ -1,11 +1,11 @@ -package mushop - -import io.micronaut.nats.annotation.NatsClient -import io.micronaut.nats.annotation.Subject - -@NatsClient -interface OrdersPublisher { - - @Subject("mushop-orders") - void publishOrder(OrderUpdate orderUpdate) -} +package mushop + +import io.micronaut.nats.annotation.NatsClient +import io.micronaut.nats.annotation.Subject + +@NatsClient +interface OrdersPublisher { + + @Subject("mushop-orders") + void publishOrder(OrderUpdate orderUpdate) +}