mirror of
https://gitlab.com/restcountries/restcountries.git
synced 2026-03-31 15:07:46 +01:00
Main
This commit is contained in:
@@ -4,6 +4,7 @@ Thumbs.db
|
||||
build/
|
||||
target/
|
||||
out/
|
||||
.micronaut/
|
||||
.idea
|
||||
*.iml
|
||||
*.ipr
|
||||
@@ -11,3 +12,4 @@ out/
|
||||
.project
|
||||
.settings
|
||||
.classpath
|
||||
.factorypath
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+18
-1
@@ -1 +1,18 @@
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you 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.
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
|
||||
|
||||
+2
-2
@@ -4,6 +4,6 @@ COPY . .
|
||||
RUN mvn --batch-mode package
|
||||
|
||||
FROM openjdk:17-alpine
|
||||
COPY --from=build target/dev.amatos.restcountries-*.jar dev.amatos.restcountries.jar
|
||||
COPY --from=build target/com.restcountries-*.jar com.restcountries.jar
|
||||
EXPOSE 8080
|
||||
CMD ["java", "-Dcom.sun.management.jmxremote", "-Xmx128m", "-jar", "dev.amatos.restcountries.jar"]
|
||||
CMD ["java", "-Dcom.sun.management.jmxremote", "-Xmx128m", "-jar", "com.restcountries.jar"]
|
||||
@@ -0,0 +1,37 @@
|
||||
# AOT configuration properties for jar packaging
|
||||
# Please review carefully the optimizations enabled below
|
||||
# Check https://micronaut-projects.github.io/micronaut-aot/latest/guide/ for more details
|
||||
|
||||
# Caches environment property values: environment properties will be deemed immutable after application startup.
|
||||
cached.environment.enabled=true
|
||||
|
||||
# Precomputes Micronaut configuration property keys from the current environment variables
|
||||
precompute.environment.properties.enabled=true
|
||||
|
||||
# Replaces logback.xml with a pure Java configuration
|
||||
logback.xml.to.java.enabled=true
|
||||
|
||||
# Converts YAML configuration files to Java configuration
|
||||
yaml.to.java.config.enabled=true
|
||||
|
||||
# Scans for service types ahead-of-time, avoiding classpath scanning at startup
|
||||
serviceloading.jit.enabled=true
|
||||
|
||||
# Scans reactive types at build time instead of runtime
|
||||
scan.reactive.types.enabled=true
|
||||
|
||||
# Deduces the environment at build time instead of runtime
|
||||
deduce.environment.enabled=true
|
||||
|
||||
# Checks for the existence of some types at build time instead of runtime
|
||||
known.missing.types.enabled=true
|
||||
|
||||
# Precomputes property sources at build time
|
||||
sealed.property.source.enabled=true
|
||||
|
||||
# The list of service types to be scanned (comma separated)
|
||||
service.types=io.micronaut.context.env.PropertySourceLoader,io.micronaut.inject.BeanConfiguration,io.micronaut.inject.BeanDefinitionReference,io.micronaut.http.HttpRequestFactory,io.micronaut.http.HttpResponseFactory,io.micronaut.core.beans.BeanIntrospectionReference,io.micronaut.core.convert.TypeConverterRegistrar,io.micronaut.context.env.PropertyExpressionResolver
|
||||
|
||||
# A list of types that the AOT analyzer needs to check for existence (comma separated)
|
||||
known.missing.types.list=io.reactivex.Observable,reactor.core.publisher.Flux,kotlinx.coroutines.flow.Flow,io.reactivex.rxjava3.core.Flowable,io.reactivex.rxjava3.core.Observable,io.reactivex.Single,reactor.core.publisher.Mono,io.reactivex.Maybe,io.reactivex.rxjava3.core.Single,io.reactivex.rxjava3.core.Maybe,io.reactivex.Completable,io.reactivex.rxjava3.core.Completable,io.methvin.watchservice.MacOSXListeningWatchService,io.micronaut.core.async.publisher.CompletableFuturePublisher,io.micronaut.core.async.publisher.Publishers.JustPublisher,io.micronaut.core.async.subscriber.Completable
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
applicationType: default
|
||||
defaultPackage: dev.amatos.restcountries
|
||||
defaultPackage: com.restcountries
|
||||
testFramework: junit
|
||||
sourceLanguage: java
|
||||
buildTool: maven
|
||||
features: [app-name, docker, file-watch, http-client, java, java-application, junit, logback, maven, netty-server, readme, shade, yaml]
|
||||
features: [app-name, http-client, java, java-application, junit, logback, maven, maven-enforcer-plugin, micronaut-aot, micronaut-http-validation, netty-server, properties, readme, serialization-jackson, shade, static-resources, validation]
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# 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
|
||||
@@ -19,7 +19,7 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven2 Start Up Batch script
|
||||
# Apache Maven Wrapper startup batch script, version 3.1.1
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
@@ -27,7 +27,6 @@
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@@ -36,6 +35,10 @@
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /usr/local/etc/mavenrc ] ; then
|
||||
. /usr/local/etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
@@ -58,9 +61,9 @@ case "`uname`" in
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
JAVA_HOME="`/usr/libexec/java_home`"; export JAVA_HOME
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
@@ -72,36 +75,8 @@ if [ -z "$JAVA_HOME" ] ; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
@@ -110,11 +85,8 @@ fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
# TODO classpath?
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
@@ -146,7 +118,7 @@ if [ -z "$JAVACMD" ] ; then
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`which java`"
|
||||
JAVACMD="`\\unset -f command; \\command -v java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -160,12 +132,9 @@ if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
@@ -185,7 +154,7 @@ find_maven_basedir() {
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
printf '%s' "$(cd "$basedir"; pwd)"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
@@ -195,11 +164,16 @@ concat_lines() {
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
BASE_DIR=$(find_maven_basedir "$(dirname $0)")
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
@@ -212,40 +186,67 @@ else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||
fi
|
||||
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar"
|
||||
if [ -n "$MVNW_REPOURL" ]; then
|
||||
wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar"
|
||||
else
|
||||
wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar"
|
||||
fi
|
||||
while IFS="=" read key value; do
|
||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||
case "$key" in (wrapperUrl) wrapperUrl="$value"; break ;;
|
||||
esac
|
||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Downloading from: $jarUrl"
|
||||
echo "Downloading from: $wrapperUrl"
|
||||
fi
|
||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
if $cygwin; then
|
||||
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
|
||||
fi
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
QUIET="--quiet"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
QUIET=""
|
||||
fi
|
||||
wget "$jarUrl" -O "$wrapperJarPath"
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
wget $QUIET "$wrapperUrl" -O "$wrapperJarPath"
|
||||
else
|
||||
wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath"
|
||||
fi
|
||||
[ $? -eq 0 ] || rm -f "$wrapperJarPath"
|
||||
elif command -v curl > /dev/null; then
|
||||
QUIET="--silent"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
QUIET=""
|
||||
fi
|
||||
curl -o "$wrapperJarPath" "$jarUrl"
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L
|
||||
else
|
||||
curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L
|
||||
fi
|
||||
[ $? -eq 0 ] || rm -f "$wrapperJarPath"
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
if [ -e "$javaClass" ]; then
|
||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
javaSource="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class"
|
||||
# For Cygwin, switch paths to Windows format before running javac
|
||||
if $cygwin; then
|
||||
javaSource=`cygpath --path --windows "$javaSource"`
|
||||
javaClass=`cygpath --path --windows "$javaClass"`
|
||||
fi
|
||||
if [ -e "$javaSource" ]; then
|
||||
if [ ! -e "$javaClass" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
# Compiling the Java class
|
||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||
("$JAVA_HOME/bin/javac" "$javaSource")
|
||||
fi
|
||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
if [ -e "$javaClass" ]; then
|
||||
# Running the downloader
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Running MavenWrapperDownloader.java ..."
|
||||
@@ -259,16 +260,10 @@ fi
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
fi
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
@@ -277,10 +272,16 @@ if $cygwin; then
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
$MAVEN_DEBUG_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@@ -18,13 +18,12 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven2 Start Up Batch script
|
||||
@REM Apache Maven Wrapper startup batch script, version 3.1.1
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@@ -37,7 +36,7 @@
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
|
||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
@@ -46,8 +45,8 @@ if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
|
||||
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
@@ -120,24 +119,51 @@ SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar"
|
||||
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||
set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar"
|
||||
|
||||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Found %WRAPPER_JAR%
|
||||
)
|
||||
) else (
|
||||
if not "%MVNW_REPOURL%" == "" (
|
||||
SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar"
|
||||
)
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
|
||||
echo Downloading from: %WRAPPER_URL%
|
||||
)
|
||||
|
||||
powershell -Command "&{"^
|
||||
"$webclient = new-object System.Net.WebClient;"^
|
||||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||
"}"^
|
||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
|
||||
"}"
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||
@REM work with both Windows and non-Windows executions.
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
%MAVEN_JAVA_EXE% ^
|
||||
%JVM_CONFIG_MAVEN_PROPS% ^
|
||||
%MAVEN_OPTS% ^
|
||||
%MAVEN_DEBUG_OPTS% ^
|
||||
-classpath %WRAPPER_JAR% ^
|
||||
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
|
||||
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
@@ -149,8 +175,8 @@ set ERROR_CODE=1
|
||||
|
||||
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
|
||||
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
@@ -158,4 +184,4 @@ if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
||||
cmd /C exit /B %ERROR_CODE%
|
||||
|
||||
@@ -1,45 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>dev.amatos.restcountries</groupId>
|
||||
<artifactId>dev.amatos.restcountries</artifactId>
|
||||
<version>1</version>
|
||||
<groupId>com.restcountries</groupId>
|
||||
<artifactId>restcountries</artifactId>
|
||||
<version>2025.04.20</version>
|
||||
<packaging>${packaging}</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>io.micronaut</groupId>
|
||||
<groupId>io.micronaut.platform</groupId>
|
||||
<artifactId>micronaut-parent</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<version>4.7.6</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<packaging>jar</packaging>
|
||||
<jdk.version>17</jdk.version>
|
||||
<!-- If you are building with JDK 9 or higher, you can uncomment the lines below to set the release version -->
|
||||
<release.version>17</release.version>
|
||||
<micronaut.version>2.0.1</micronaut.version>
|
||||
<micronautopenapi.version>2.0.0</micronautopenapi.version>
|
||||
<exec.mainClass>dev.amatos.restcountries.Application</exec.mainClass>
|
||||
<java.version>17</java.version>
|
||||
<micronaut.version>4.7.6</micronaut.version>
|
||||
<micronaut.runtime>netty</micronaut.runtime>
|
||||
<micronaut.aot.enabled>false</micronaut.aot.enabled>
|
||||
<micronaut.aot.packageName>com.restcountries.aot.generated</micronaut.aot.packageName>
|
||||
<exec.mainClass>com.restcountries.Application</exec.mainClass>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jcenter.bintray.com</id>
|
||||
<url>https://jcenter.bintray.com</url>
|
||||
<id>central</id>
|
||||
<url>https://repo.maven.apache.org/maven2</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.micronaut</groupId>
|
||||
<artifactId>micronaut-inject</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.micronaut</groupId>
|
||||
<artifactId>micronaut-validation</artifactId>
|
||||
<artifactId>micronaut-http-client</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -48,13 +42,18 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.micronaut</groupId>
|
||||
<artifactId>micronaut-http-client</artifactId>
|
||||
<groupId>io.micronaut.serde</groupId>
|
||||
<artifactId>micronaut-serde-jackson</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.micronaut</groupId>
|
||||
<artifactId>micronaut-runtime</artifactId>
|
||||
<groupId>io.micronaut.validation</groupId>
|
||||
<artifactId>micronaut-validation</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.validation</groupId>
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -62,6 +61,11 @@
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.micronaut.test</groupId>
|
||||
<artifactId>micronaut-test-junit5</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
@@ -72,24 +76,14 @@
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.micronaut.test</groupId>
|
||||
<artifactId>micronaut-test-junit5</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.micronaut</groupId>
|
||||
<artifactId>micronaut-management</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.9.0</version>
|
||||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.17.2</version>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.spec.javax.ws.rs</groupId>
|
||||
@@ -97,87 +91,77 @@
|
||||
<version>1.0.1.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-common</artifactId>
|
||||
<version>3.0.4</version>
|
||||
<groupId>jakarta.ws.rs</groupId>
|
||||
<artifactId>jakarta.ws.rs-api</artifactId>
|
||||
<version>4.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-client</artifactId>
|
||||
<version>6.0.1.Final</version>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.17.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.micronaut.build</groupId>
|
||||
<groupId>io.micronaut.maven</groupId>
|
||||
<artifactId>micronaut-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<configFile>aot-${packaging}.properties</configFile>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<!-- Uncomment to enable incremental compilation -->
|
||||
<!-- <useIncrementalCompilation>false</useIncrementalCompilation> -->
|
||||
|
||||
<annotationProcessorPaths combine.children="append">
|
||||
<path>
|
||||
<groupId>io.micronaut</groupId>
|
||||
<artifactId>micronaut-inject-java</artifactId>
|
||||
<version>${micronaut.version}</version>
|
||||
<artifactId>micronaut-http-validation</artifactId>
|
||||
<version>${micronaut.core.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>io.micronaut.serde</groupId>
|
||||
<artifactId>micronaut-serde-processor</artifactId>
|
||||
<version>${micronaut.serialization.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.micronaut</groupId>
|
||||
<artifactId>micronaut-validation</artifactId>
|
||||
<version>${micronaut.version}</version>
|
||||
<artifactId>micronaut-inject</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>io.micronaut.openapi</groupId>
|
||||
<artifactId>micronaut-openapi</artifactId>
|
||||
<version>${micronautopenapi.version}</version>
|
||||
<groupId>io.micronaut.validation</groupId>
|
||||
<artifactId>micronaut-validation-processor</artifactId>
|
||||
<version>${micronaut.validation.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.micronaut</groupId>
|
||||
<artifactId>micronaut-inject</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
<compilerArgs>
|
||||
<arg>-Amicronaut.processing.group=dev.amatos.restcountries</arg>
|
||||
<arg>-Amicronaut.processing.module=dev.amatos.restcountries</arg>
|
||||
<arg>-Amicronaut.processing.group=com.restcountries</arg>
|
||||
<arg>-Amicronaut.processing.module=restcountries</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<goals>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>io.micronaut</groupId>
|
||||
<artifactId>micronaut-inject-java</artifactId>
|
||||
<version>${micronaut.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>io.micronaut</groupId>
|
||||
<artifactId>micronaut-validation</artifactId>
|
||||
<version>${micronaut.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.restcountries;
|
||||
|
||||
import io.micronaut.runtime.Micronaut;
|
||||
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Micronaut.run(Application.class, args);
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,12 +1,12 @@
|
||||
package dev.amatos.restcountries.controller;
|
||||
package com.restcountries.controller;
|
||||
|
||||
import static dev.amatos.restcountries.utils.Constants.CACHE_CONTROL_VALUE;
|
||||
import static io.micronaut.http.HttpHeaders.CACHE_CONTROL;
|
||||
|
||||
import dev.amatos.restcountries.domain.ResponseEntity;
|
||||
import com.restcountries.domain.ResponseEntity;
|
||||
import io.micronaut.http.HttpResponse;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import static com.restcountries.utils.Constants.CACHE_CONTROL_VALUE;
|
||||
import static io.micronaut.http.HttpHeaders.CACHE_CONTROL;
|
||||
|
||||
public class ControllerHelper {
|
||||
|
||||
protected static final String[] COUNTRY_FIELDS_V2 = new String[]{
|
||||
+9
-12
@@ -1,21 +1,18 @@
|
||||
package dev.amatos.restcountries.controller;
|
||||
package com.restcountries.controller;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import dev.amatos.restcountries.domain.ICountryRestSymbols;
|
||||
import dev.amatos.restcountries.domain.base.BaseCountry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import com.restcountries.domain.ICountryRestSymbols;
|
||||
import com.restcountries.domain.base.BaseCountry;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ControllerV3Helper {
|
||||
|
||||
protected Object checkFieldsAndParseCountries(Optional<String> fields,
|
||||
Set<? extends dev.amatos.restcountries.domain.base.BaseCountry> countries) {
|
||||
Set<? extends com.restcountries.domain.base.BaseCountry> countries) {
|
||||
if (fields.isPresent()) {
|
||||
return parsedCountries(countries, fields.get());
|
||||
} else {
|
||||
@@ -23,7 +20,7 @@ public class ControllerV3Helper {
|
||||
}
|
||||
}
|
||||
|
||||
protected Object checkFieldsAndParseCountry(Set<? extends dev.amatos.restcountries.domain.base.BaseCountry> countries, Optional<String> fields) {
|
||||
protected Object checkFieldsAndParseCountry(Set<? extends com.restcountries.domain.base.BaseCountry> countries, Optional<String> fields) {
|
||||
if (fields.isPresent()) {
|
||||
return parsedCountry(countries, fields.get());
|
||||
} else {
|
||||
@@ -31,7 +28,7 @@ public class ControllerV3Helper {
|
||||
}
|
||||
}
|
||||
|
||||
protected Object parsedCountries(Set<? extends dev.amatos.restcountries.domain.base.BaseCountry> countries, String excludedFields) {
|
||||
protected Object parsedCountries(Set<? extends com.restcountries.domain.base.BaseCountry> countries, String excludedFields) {
|
||||
if (excludedFields == null || excludedFields.isEmpty()) {
|
||||
return countries;
|
||||
} else {
|
||||
@@ -60,7 +57,7 @@ public class ControllerV3Helper {
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
private String getCountriesJson(Set<? extends dev.amatos.restcountries.domain.base.BaseCountry> countries, List<String> fields) {
|
||||
private String getCountriesJson(Set<? extends com.restcountries.domain.base.BaseCountry> countries, List<String> fields) {
|
||||
var gson = new Gson();
|
||||
var jsonArray = JsonParser.parseString(gson.toJson(countries)).getAsJsonArray();
|
||||
var resultArray = new JsonArray();
|
||||
+6
-5
@@ -1,12 +1,12 @@
|
||||
package dev.amatos.restcountries.controller;
|
||||
package com.restcountries.controller;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import dev.amatos.restcountries.domain.ICountryRestSymbols;
|
||||
import dev.amatos.restcountries.domain.v2.Country;
|
||||
import dev.amatos.restcountries.service.v2.CountryServiceV2;
|
||||
import com.restcountries.domain.ICountryRestSymbols;
|
||||
import com.restcountries.domain.v2.Country;
|
||||
import com.restcountries.service.v2.CountryServiceV2;
|
||||
import io.micronaut.http.HttpResponse;
|
||||
import io.micronaut.http.MediaType;
|
||||
import io.micronaut.http.annotation.Controller;
|
||||
@@ -14,11 +14,12 @@ import io.micronaut.http.annotation.Get;
|
||||
import io.micronaut.http.annotation.PathVariable;
|
||||
import io.micronaut.http.annotation.QueryValue;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
|
||||
import javax.ws.rs.QueryParam;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import javax.ws.rs.QueryParam;
|
||||
|
||||
@Hidden
|
||||
@Controller("/v2/")
|
||||
+4
-3
@@ -1,6 +1,6 @@
|
||||
package dev.amatos.restcountries.controller;
|
||||
package com.restcountries.controller;
|
||||
|
||||
import dev.amatos.restcountries.service.v3.CountryServiceV3;
|
||||
import com.restcountries.service.v3.CountryServiceV3;
|
||||
import io.micronaut.http.HttpResponse;
|
||||
import io.micronaut.http.MediaType;
|
||||
import io.micronaut.http.annotation.Controller;
|
||||
@@ -8,8 +8,9 @@ import io.micronaut.http.annotation.Get;
|
||||
import io.micronaut.http.annotation.PathVariable;
|
||||
import io.micronaut.http.annotation.QueryValue;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.ws.rs.QueryParam;
|
||||
import java.util.Optional;
|
||||
|
||||
@Hidden
|
||||
@Controller("/v3/")
|
||||
+4
-3
@@ -1,6 +1,6 @@
|
||||
package dev.amatos.restcountries.controller;
|
||||
package com.restcountries.controller;
|
||||
|
||||
import dev.amatos.restcountries.service.v3.v31.CountryServiceV31;
|
||||
import com.restcountries.service.v3.v31.CountryServiceV31;
|
||||
import io.micronaut.http.HttpResponse;
|
||||
import io.micronaut.http.MediaType;
|
||||
import io.micronaut.http.annotation.Controller;
|
||||
@@ -8,9 +8,10 @@ import io.micronaut.http.annotation.Get;
|
||||
import io.micronaut.http.annotation.PathVariable;
|
||||
import io.micronaut.http.annotation.QueryValue;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.Optional;
|
||||
|
||||
@Controller("/v3.1/")
|
||||
public class CountryControllerV31 extends ControllerV3Helper {
|
||||
+4
-1
@@ -1,8 +1,11 @@
|
||||
package dev.amatos.restcountries.domain;
|
||||
package com.restcountries.domain;
|
||||
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class BaseCountry {
|
||||
|
||||
protected String name;
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package dev.amatos.restcountries.domain;
|
||||
package com.restcountries.domain;
|
||||
|
||||
public interface ICountryRestSymbols {
|
||||
String COLON = ",";
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package dev.amatos.restcountries.domain;
|
||||
package com.restcountries.domain;
|
||||
|
||||
public class ResponseEntity {
|
||||
|
||||
+4
-1
@@ -1,8 +1,11 @@
|
||||
package dev.amatos.restcountries.domain.base;
|
||||
package com.restcountries.domain.base;
|
||||
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class BaseCountry {
|
||||
|
||||
private Name name;
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
package dev.amatos.restcountries.domain.base;
|
||||
package com.restcountries.domain.base;
|
||||
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class Car {
|
||||
private List<String> signs;
|
||||
private String side;
|
||||
+4
-1
@@ -1,5 +1,8 @@
|
||||
package dev.amatos.restcountries.domain.base;
|
||||
package com.restcountries.domain.base;
|
||||
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class Currency {
|
||||
private String name;
|
||||
private String symbol;
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
package dev.amatos.restcountries.domain.base;
|
||||
package com.restcountries.domain.base;
|
||||
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class Idd {
|
||||
private String root;
|
||||
private List<String> suffixes;
|
||||
+4
-1
@@ -1,8 +1,11 @@
|
||||
package dev.amatos.restcountries.domain.base;
|
||||
package com.restcountries.domain.base;
|
||||
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class Name {
|
||||
private String common;
|
||||
private String official;
|
||||
+4
-1
@@ -1,5 +1,8 @@
|
||||
package dev.amatos.restcountries.domain.base;
|
||||
package com.restcountries.domain.base;
|
||||
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class NativeName {
|
||||
private String official;
|
||||
private String common;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package dev.amatos.restcountries.domain.v2;
|
||||
package com.restcountries.domain.v2;
|
||||
|
||||
/**
|
||||
* Created by fayder on 24/02/2017.
|
||||
+4
-2
@@ -1,12 +1,14 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package dev.amatos.restcountries.domain.v2;
|
||||
package com.restcountries.domain.v2;
|
||||
|
||||
import dev.amatos.restcountries.domain.BaseCountry;
|
||||
import com.restcountries.domain.BaseCountry;
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class Country extends BaseCountry {
|
||||
|
||||
private List<Currency> currencies;
|
||||
+4
-1
@@ -1,8 +1,11 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package dev.amatos.restcountries.domain.v2;
|
||||
package com.restcountries.domain.v2;
|
||||
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class Currency {
|
||||
|
||||
private String code;
|
||||
+4
-1
@@ -1,5 +1,8 @@
|
||||
package dev.amatos.restcountries.domain.v2;
|
||||
package com.restcountries.domain.v2;
|
||||
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class Flag {
|
||||
private String svg;
|
||||
private String png;
|
||||
+4
-1
@@ -1,8 +1,11 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package dev.amatos.restcountries.domain.v2;
|
||||
package com.restcountries.domain.v2;
|
||||
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class Language {
|
||||
|
||||
private String iso639_1;
|
||||
+4
-1
@@ -1,5 +1,8 @@
|
||||
package dev.amatos.restcountries.domain.v2;
|
||||
package com.restcountries.domain.v2;
|
||||
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class Maps {
|
||||
private String gmaps;
|
||||
private String openstreetmap;
|
||||
+4
-1
@@ -1,4 +1,6 @@
|
||||
package dev.amatos.restcountries.domain.v2;
|
||||
package com.restcountries.domain.v2;
|
||||
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -6,6 +8,7 @@ import java.util.List;
|
||||
/**
|
||||
* Created by fayder on 30/04/2017.
|
||||
*/
|
||||
@Serdeable.Serializable
|
||||
public class RegionalBloc {
|
||||
|
||||
private String acronym;
|
||||
+4
-1
@@ -1,9 +1,12 @@
|
||||
package dev.amatos.restcountries.domain.v2;
|
||||
package com.restcountries.domain.v2;
|
||||
|
||||
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
/**
|
||||
* Created by fayder on 05/03/2017.
|
||||
*/
|
||||
@Serdeable.Serializable
|
||||
public class Translations {
|
||||
|
||||
private String br;
|
||||
+5
-2
@@ -1,8 +1,11 @@
|
||||
package dev.amatos.restcountries.domain.v3;
|
||||
package com.restcountries.domain.v3;
|
||||
|
||||
import com.restcountries.domain.base.BaseCountry;
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
import dev.amatos.restcountries.domain.base.BaseCountry;
|
||||
import java.util.List;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class Country extends BaseCountry {
|
||||
private List<String> flags;
|
||||
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
package dev.amatos.restcountries.domain.v3.v31;
|
||||
package com.restcountries.domain.v3.v31;
|
||||
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class CapitalInformation {
|
||||
|
||||
private List<Double> latlng;
|
||||
+5
-2
@@ -1,8 +1,11 @@
|
||||
package dev.amatos.restcountries.domain.v3.v31;
|
||||
package com.restcountries.domain.v3.v31;
|
||||
|
||||
import com.restcountries.domain.base.BaseCountry;
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
import dev.amatos.restcountries.domain.base.BaseCountry;
|
||||
import java.util.Map;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class Country extends BaseCountry {
|
||||
private Flag flags;
|
||||
private Flag coatOfArms;
|
||||
+4
-1
@@ -1,5 +1,8 @@
|
||||
package dev.amatos.restcountries.domain.v3.v31;
|
||||
package com.restcountries.domain.v3.v31;
|
||||
|
||||
import io.micronaut.serde.annotation.Serdeable;
|
||||
|
||||
@Serdeable.Serializable
|
||||
public class Flag {
|
||||
private String png;
|
||||
private String svg;
|
||||
+5
-8
@@ -1,12 +1,14 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package dev.amatos.restcountries.service.v2;
|
||||
package com.restcountries.service.v2;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import dev.amatos.restcountries.domain.BaseCountry;
|
||||
import dev.amatos.restcountries.domain.ICountryRestSymbols;
|
||||
import com.restcountries.domain.BaseCountry;
|
||||
import com.restcountries.domain.ICountryRestSymbols;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -14,12 +16,9 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.text.Normalizer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class CountryServiceBaseV2 {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(CountryServiceBaseV2.class);
|
||||
|
||||
protected <T extends BaseCountry> T getByAlpha(String alpha, List<T> countries) {
|
||||
int alphaLength = alpha.length();
|
||||
@@ -155,7 +154,6 @@ public class CountryServiceBaseV2 {
|
||||
|
||||
protected List<? extends BaseCountry> loadJson(String filename,
|
||||
Class<? extends BaseCountry> clazz) {
|
||||
logger.info("Loading JSON {}", filename);
|
||||
List<BaseCountry> countries = new ArrayList<>();
|
||||
InputStream is = CountryServiceBaseV2.class.getClassLoader().getResourceAsStream(filename);
|
||||
var gson = new Gson();
|
||||
@@ -170,7 +168,6 @@ public class CountryServiceBaseV2 {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Could not load JSON {}", filename);
|
||||
}
|
||||
return countries;
|
||||
}
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package dev.amatos.restcountries.service.v2;
|
||||
package com.restcountries.service.v2;
|
||||
|
||||
import dev.amatos.restcountries.domain.v2.Country;
|
||||
import dev.amatos.restcountries.domain.v2.Currency;
|
||||
import dev.amatos.restcountries.domain.v2.RegionalBloc;
|
||||
import com.restcountries.domain.v2.Country;
|
||||
import com.restcountries.domain.v2.Currency;
|
||||
import com.restcountries.domain.v2.RegionalBloc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
+4
-3
@@ -1,12 +1,13 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package dev.amatos.restcountries.service.v3;
|
||||
package com.restcountries.service.v3;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import dev.amatos.restcountries.domain.ICountryRestSymbols;
|
||||
import dev.amatos.restcountries.domain.base.BaseCountry;
|
||||
import com.restcountries.domain.ICountryRestSymbols;
|
||||
import com.restcountries.domain.base.BaseCountry;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
+6
-4
@@ -1,9 +1,10 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package dev.amatos.restcountries.service.v3;
|
||||
package com.restcountries.service.v3;
|
||||
|
||||
import com.restcountries.domain.v3.Country;
|
||||
|
||||
import dev.amatos.restcountries.domain.v3.Country;
|
||||
import java.text.Normalizer;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -22,7 +23,7 @@ public class CountryServiceV3 extends CountryServiceBaseV3 {
|
||||
}
|
||||
|
||||
public static CountryServiceV3 getInstance() {
|
||||
return CountryServiceV3.InstanceHolder.INSTANCE;
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
public Set<Country> getAll() {
|
||||
@@ -84,6 +85,7 @@ public class CountryServiceV3 extends CountryServiceBaseV3 {
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
countries = (Set<Country>) super.loadJson("countriesV3.json", Country.class);
|
||||
var c = (Set<Country>) super.loadJson("countriesV3.json", Country.class);
|
||||
countries = c;
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,13 +1,13 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package dev.amatos.restcountries.service.v3.v31;
|
||||
package com.restcountries.service.v3.v31;
|
||||
|
||||
import com.restcountries.domain.v3.v31.Country;
|
||||
import com.restcountries.service.v3.CountryServiceBaseV3;
|
||||
|
||||
import dev.amatos.restcountries.domain.v3.v31.Country;
|
||||
import dev.amatos.restcountries.service.v3.CountryServiceBaseV3;
|
||||
import java.text.Normalizer;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -25,7 +25,7 @@ public class CountryServiceV31 extends CountryServiceBaseV3 {
|
||||
}
|
||||
|
||||
public static CountryServiceV31 getInstance() {
|
||||
return CountryServiceV31.InstanceHolder.INSTANCE;
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
public Set<Country> getAll() {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package dev.amatos.restcountries.utils;
|
||||
package com.restcountries.utils;
|
||||
|
||||
public class Constants {
|
||||
public static final String CACHE_CONTROL_VALUE="public, immutable, max-age=31556926";
|
||||
@@ -1,25 +0,0 @@
|
||||
package dev.amatos.restcountries;
|
||||
|
||||
import io.micronaut.runtime.Micronaut;
|
||||
|
||||
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
|
||||
import io.swagger.v3.oas.annotations.info.Contact;
|
||||
import io.swagger.v3.oas.annotations.info.Info;
|
||||
import io.swagger.v3.oas.annotations.info.License;
|
||||
import io.swagger.v3.oas.annotations.servers.Server;
|
||||
|
||||
|
||||
@OpenAPIDefinition(
|
||||
info = @Info(
|
||||
title = "rest-countries",
|
||||
version = "3.1",
|
||||
description = "Get information about countries via a RESTful API",
|
||||
license = @License(name = "Mozilla Public License MPL 2.0", url = "https://www.mozilla.org/en-US/MPL/2.0/"),
|
||||
contact = @Contact(url = "https://restcountries.com", name = "Alejandro Matos")
|
||||
)
|
||||
)
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
Micronaut.run(Application.class, args);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,11 @@
|
||||
#Wed Mar 12 15:11:47 UTC 2025
|
||||
micronaut:
|
||||
application:
|
||||
name: dev.amatos.restcountries
|
||||
name=restcountries
|
||||
router.static-resources.default:
|
||||
enabled: true
|
||||
paths: classpath:static
|
||||
mapping: "/**"
|
||||
router:
|
||||
static-resources:
|
||||
swagger:
|
||||
paths: classpath:META-INF/swagger
|
||||
mapping: /openapi/**
|
||||
server:
|
||||
cors:
|
||||
enabled: true
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<configuration>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<withJansi>false</withJansi>
|
||||
<!-- encoders are assigned the type
|
||||
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
|
||||
<encoder>
|
||||
|
||||
+6
-9
@@ -1,16 +1,13 @@
|
||||
package dev.amatos.restcountries;
|
||||
package com.restcountries;
|
||||
|
||||
import dev.amatos.restcountries.domain.v2.Country;
|
||||
import dev.amatos.restcountries.domain.v2.Currency;
|
||||
import dev.amatos.restcountries.domain.v2.Language;
|
||||
import dev.amatos.restcountries.domain.v2.RegionalBloc;
|
||||
import dev.amatos.restcountries.domain.v2.Translations;
|
||||
import dev.amatos.restcountries.service.v2.CountryServiceV2;
|
||||
import io.micronaut.test.annotation.MicronautTest;
|
||||
import java.util.List;
|
||||
import com.restcountries.domain.v2.*;
|
||||
import com.restcountries.service.v2.CountryServiceV2;
|
||||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@MicronautTest
|
||||
class RestCountriesV2Test {
|
||||
|
||||
+6
-19
@@ -1,29 +1,16 @@
|
||||
package dev.amatos.restcountries;
|
||||
package com.restcountries;
|
||||
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import dev.amatos.restcountries.domain.v3.v31.Country;
|
||||
import dev.amatos.restcountries.service.v3.v31.CountryServiceV31;
|
||||
import io.micronaut.http.client.RxHttpClient;
|
||||
import io.micronaut.http.client.annotation.Client;
|
||||
import io.micronaut.test.annotation.MicronautTest;
|
||||
import java.security.spec.ECField;
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.inject.Inject;
|
||||
import com.restcountries.service.v3.v31.CountryServiceV31;
|
||||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@MicronautTest
|
||||
class RestCountriesV31Test {
|
||||
|
||||
@Inject
|
||||
@Client("/")
|
||||
RxHttpClient rxHttpClient;
|
||||
|
||||
@Test
|
||||
void getAll() {
|
||||
var countries = CountryServiceV31.getInstance().getAll();
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package dev.amatos.restcountries;
|
||||
package com.restcountries;
|
||||
|
||||
import dev.amatos.restcountries.service.v3.CountryServiceV3;
|
||||
import io.micronaut.test.annotation.MicronautTest;
|
||||
import com.restcountries.service.v3.CountryServiceV3;
|
||||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.restcountries;
|
||||
|
||||
import io.micronaut.runtime.EmbeddedApplication;
|
||||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
@MicronautTest
|
||||
class RestcountriesTest {
|
||||
|
||||
@Inject
|
||||
EmbeddedApplication<?> application;
|
||||
|
||||
@Test
|
||||
void testItWorks() {
|
||||
Assertions.assertTrue(application.isRunning());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user