From 1c3c423e185fb3c163ac6ae283f54733aa813362 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Mon, 3 Jun 2024 22:20:56 -0500 Subject: [PATCH 01/35] Update to JAVA 21 + SpringBoot 3.3.0 --- .gitignore | 7 +- mvnw | 442 ++++++++---------- mvnw.cmd | 278 +++++------ pom.xml | 20 +- .../taskbackend/TaskBackendApplication.java | 19 - .../tasks_backend/ServletInitializer.java | 13 + .../TasksBackendApplication.java | 13 + .../controller/RootController.java | 2 +- .../controller/TaskController.java | 10 +- .../model/Task.java | 10 +- .../repo/TaskRepo.java | 4 +- .../utils/DateUtils.java | 2 +- .../utils/ValidationException.java | 2 +- src/main/resources/application.properties | 5 +- 14 files changed, 368 insertions(+), 459 deletions(-) delete mode 100644 src/main/java/br/ce/wcaquino/taskbackend/TaskBackendApplication.java create mode 100644 src/main/java/br/ce/wcaquino/tasks_backend/ServletInitializer.java create mode 100644 src/main/java/br/ce/wcaquino/tasks_backend/TasksBackendApplication.java rename src/main/java/br/ce/wcaquino/{taskbackend => tasks_backend}/controller/RootController.java (87%) rename src/main/java/br/ce/wcaquino/{taskbackend => tasks_backend}/controller/TaskController.java (82%) rename src/main/java/br/ce/wcaquino/{taskbackend => tasks_backend}/model/Task.java (74%) rename src/main/java/br/ce/wcaquino/{taskbackend => tasks_backend}/repo/TaskRepo.java (58%) rename src/main/java/br/ce/wcaquino/{taskbackend => tasks_backend}/utils/DateUtils.java (81%) rename src/main/java/br/ce/wcaquino/{taskbackend => tasks_backend}/utils/ValidationException.java (88%) diff --git a/.gitignore b/.gitignore index 2aa2454d6..549e00a2a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ HELP.md target/ !.mvn/wrapper/maven-wrapper.jar -!**/src/main/** -!**/src/test/** +!**/src/main/**/target/ +!**/src/test/**/target/ ### STS ### .apt_generated @@ -26,7 +26,8 @@ target/ /nbdist/ /.nb-gradle/ build/ +!**/src/main/**/build/ +!**/src/test/**/build/ ### VS Code ### .vscode/ -**/.DS_Store diff --git a/mvnw b/mvnw index a16b5431b..ba9212a0d 100644 --- a/mvnw +++ b/mvnw @@ -19,292 +19,232 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir +# Apache Maven Wrapper startup batch script, version 3.3.1 # # 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 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output # ---------------------------------------------------------------------------- -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac -fi +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # 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`" - else - export JAVA_HOME="/Library/Java/Home" + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 fi fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi 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 +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" done + printf %x\\n $h +} - saveddir=`pwd` +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } - M2_HOME=`dirname "$PRG"`/.. +die() { + printf %s\\n "$1" >&2 + exit 1 +} - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl="${value-}" ;; + distributionSha256Sum) distributionSha256Sum="${value-}" ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_HOME="$HOME/.m2/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} -# 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" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" 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)`" -fi +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" fi -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi +mkdir -p -- "${MAVEN_HOME%/*}" -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; 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. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - 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 - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" 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" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - 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 +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" +clean || : +exec_maven "$@" diff --git a/mvnw.cmd b/mvnw.cmd index c8d43372c..406932dae 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,128 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.1 @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 -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@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 -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" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -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.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_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 DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_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('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@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 - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -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" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/pom.xml b/pom.xml index 39068fb8c..6b5713040 100644 --- a/pom.xml +++ b/pom.xml @@ -1,28 +1,25 @@ - 4.0.0 org.springframework.boot spring-boot-starter-parent - 2.2.4.RELEASE - + 3.3.0 + br.ce.wcaquino tasks-backend 0.0.1-SNAPSHOT - tasks-backend war + tasks-backend A very simple task management tool - - 1.8 + 21 jacoco reuseReports ${project.basedir}/target/jacoco.exec - org.springframework.boot @@ -32,12 +29,13 @@ org.springframework.boot spring-boot-starter-web + org.springframework.boot spring-boot-starter-tomcat provided - + org.postgresql postgresql @@ -57,7 +55,6 @@ - tasks-backend org.springframework.boot @@ -66,7 +63,7 @@ org.jacoco jacoco-maven-plugin - 0.8.3 + 0.8.12 @@ -80,5 +77,4 @@ - diff --git a/src/main/java/br/ce/wcaquino/taskbackend/TaskBackendApplication.java b/src/main/java/br/ce/wcaquino/taskbackend/TaskBackendApplication.java deleted file mode 100644 index f01578cc7..000000000 --- a/src/main/java/br/ce/wcaquino/taskbackend/TaskBackendApplication.java +++ /dev/null @@ -1,19 +0,0 @@ -package br.ce.wcaquino.taskbackend; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; - -@SpringBootApplication -public class TaskBackendApplication extends SpringBootServletInitializer { - - public static void main(String[] args) { - SpringApplication.run(TaskBackendApplication.class, args); - } - - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(TaskBackendApplication.class); - } -} diff --git a/src/main/java/br/ce/wcaquino/tasks_backend/ServletInitializer.java b/src/main/java/br/ce/wcaquino/tasks_backend/ServletInitializer.java new file mode 100644 index 000000000..71c28f9d1 --- /dev/null +++ b/src/main/java/br/ce/wcaquino/tasks_backend/ServletInitializer.java @@ -0,0 +1,13 @@ +package br.ce.wcaquino.tasks_backend; + +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +public class ServletInitializer extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(TasksBackendApplication.class); + } + +} diff --git a/src/main/java/br/ce/wcaquino/tasks_backend/TasksBackendApplication.java b/src/main/java/br/ce/wcaquino/tasks_backend/TasksBackendApplication.java new file mode 100644 index 000000000..61c0a8fe0 --- /dev/null +++ b/src/main/java/br/ce/wcaquino/tasks_backend/TasksBackendApplication.java @@ -0,0 +1,13 @@ +package br.ce.wcaquino.tasks_backend; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class TasksBackendApplication { + + public static void main(String[] args) { + SpringApplication.run(TasksBackendApplication.class, args); + } + +} diff --git a/src/main/java/br/ce/wcaquino/taskbackend/controller/RootController.java b/src/main/java/br/ce/wcaquino/tasks_backend/controller/RootController.java similarity index 87% rename from src/main/java/br/ce/wcaquino/taskbackend/controller/RootController.java rename to src/main/java/br/ce/wcaquino/tasks_backend/controller/RootController.java index 534aca5d7..b9e714d55 100644 --- a/src/main/java/br/ce/wcaquino/taskbackend/controller/RootController.java +++ b/src/main/java/br/ce/wcaquino/tasks_backend/controller/RootController.java @@ -1,4 +1,4 @@ -package br.ce.wcaquino.taskbackend.controller; +package br.ce.wcaquino.tasks_backend.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/src/main/java/br/ce/wcaquino/taskbackend/controller/TaskController.java b/src/main/java/br/ce/wcaquino/tasks_backend/controller/TaskController.java similarity index 82% rename from src/main/java/br/ce/wcaquino/taskbackend/controller/TaskController.java rename to src/main/java/br/ce/wcaquino/tasks_backend/controller/TaskController.java index 2b9281372..e51dec96b 100644 --- a/src/main/java/br/ce/wcaquino/taskbackend/controller/TaskController.java +++ b/src/main/java/br/ce/wcaquino/tasks_backend/controller/TaskController.java @@ -1,4 +1,4 @@ -package br.ce.wcaquino.taskbackend.controller; +package br.ce.wcaquino.tasks_backend.controller; import java.util.List; @@ -11,10 +11,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import br.ce.wcaquino.taskbackend.model.Task; -import br.ce.wcaquino.taskbackend.repo.TaskRepo; -import br.ce.wcaquino.taskbackend.utils.DateUtils; -import br.ce.wcaquino.taskbackend.utils.ValidationException; +import br.ce.wcaquino.tasks_backend.model.Task; +import br.ce.wcaquino.tasks_backend.repo.TaskRepo; +import br.ce.wcaquino.tasks_backend.utils.DateUtils; +import br.ce.wcaquino.tasks_backend.utils.ValidationException; @RestController @RequestMapping(value ="/todo") diff --git a/src/main/java/br/ce/wcaquino/taskbackend/model/Task.java b/src/main/java/br/ce/wcaquino/tasks_backend/model/Task.java similarity index 74% rename from src/main/java/br/ce/wcaquino/taskbackend/model/Task.java rename to src/main/java/br/ce/wcaquino/tasks_backend/model/Task.java index e5375db34..8684e6628 100644 --- a/src/main/java/br/ce/wcaquino/taskbackend/model/Task.java +++ b/src/main/java/br/ce/wcaquino/tasks_backend/model/Task.java @@ -1,11 +1,11 @@ -package br.ce.wcaquino.taskbackend.model; +package br.ce.wcaquino.tasks_backend.model; import java.time.LocalDate; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; @Entity public class Task { diff --git a/src/main/java/br/ce/wcaquino/taskbackend/repo/TaskRepo.java b/src/main/java/br/ce/wcaquino/tasks_backend/repo/TaskRepo.java similarity index 58% rename from src/main/java/br/ce/wcaquino/taskbackend/repo/TaskRepo.java rename to src/main/java/br/ce/wcaquino/tasks_backend/repo/TaskRepo.java index 91c9986c7..6f594a010 100644 --- a/src/main/java/br/ce/wcaquino/taskbackend/repo/TaskRepo.java +++ b/src/main/java/br/ce/wcaquino/tasks_backend/repo/TaskRepo.java @@ -1,8 +1,8 @@ -package br.ce.wcaquino.taskbackend.repo; +package br.ce.wcaquino.tasks_backend.repo; import org.springframework.data.jpa.repository.JpaRepository; -import br.ce.wcaquino.taskbackend.model.Task; +import br.ce.wcaquino.tasks_backend.model.Task; public interface TaskRepo extends JpaRepository{ diff --git a/src/main/java/br/ce/wcaquino/taskbackend/utils/DateUtils.java b/src/main/java/br/ce/wcaquino/tasks_backend/utils/DateUtils.java similarity index 81% rename from src/main/java/br/ce/wcaquino/taskbackend/utils/DateUtils.java rename to src/main/java/br/ce/wcaquino/tasks_backend/utils/DateUtils.java index d06537014..d7995f6dc 100644 --- a/src/main/java/br/ce/wcaquino/taskbackend/utils/DateUtils.java +++ b/src/main/java/br/ce/wcaquino/tasks_backend/utils/DateUtils.java @@ -1,4 +1,4 @@ -package br.ce.wcaquino.taskbackend.utils; +package br.ce.wcaquino.tasks_backend.utils; import java.time.LocalDate; diff --git a/src/main/java/br/ce/wcaquino/taskbackend/utils/ValidationException.java b/src/main/java/br/ce/wcaquino/tasks_backend/utils/ValidationException.java similarity index 88% rename from src/main/java/br/ce/wcaquino/taskbackend/utils/ValidationException.java rename to src/main/java/br/ce/wcaquino/tasks_backend/utils/ValidationException.java index 9f9fe465e..45a05d565 100644 --- a/src/main/java/br/ce/wcaquino/taskbackend/utils/ValidationException.java +++ b/src/main/java/br/ce/wcaquino/tasks_backend/utils/ValidationException.java @@ -1,4 +1,4 @@ -package br.ce.wcaquino.taskbackend.utils; +package br.ce.wcaquino.tasks_backend.utils; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 176b13ed1..7e3609f44 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,4 +1,5 @@ -server.port=8001 +server.port=8002 +spring.application.name=tasks-backend ## default connection pool spring.datasource.hikari.connectionTimeout=20000 @@ -12,4 +13,4 @@ spring.datasource.password=${DATABASE_PASSWD:password} #drop n create table again, good for testing, comment this in production spring.jpa.hibernate.ddl-auto=${DATABASE_UPDATE:create} #spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false -spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect \ No newline at end of file +#spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect \ No newline at end of file From e77a6529966a0ceab8c057c1dda22acfd9af8e4e Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Mon, 3 Jun 2024 22:28:48 -0500 Subject: [PATCH 02/35] Fix server port value --- src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 7e3609f44..0fa94de64 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,4 +1,4 @@ -server.port=8002 +server.port=8001 spring.application.name=tasks-backend ## default connection pool From e519d5413e9a8836379d48f3701c04e5e49d7a97 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Tue, 4 Jun 2024 06:29:40 -0500 Subject: [PATCH 03/35] Add final name --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 6b5713040..70e8fea2b 100644 --- a/pom.xml +++ b/pom.xml @@ -55,6 +55,7 @@ + ${project.name} org.springframework.boot From 8ded81989316bcf96ce3868b72ed4922bd9f9ad2 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Tue, 4 Jun 2024 06:31:10 -0500 Subject: [PATCH 04/35] Add final name --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 70e8fea2b..846a75480 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ - ${project.name} + tasks-backend org.springframework.boot From 3e34e40158a29a3acd2bbef8a3441d3864ee430c Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Tue, 4 Jun 2024 06:36:04 -0500 Subject: [PATCH 05/35] Fix package name --- .../ServletInitializer.java | 2 +- .../TasksBackendApplication.java | 2 +- .../controller/RootController.java | 2 +- .../controller/TaskController.java | 10 +++++----- .../{tasks_backend => taskbackend}/model/Task.java | 2 +- .../{tasks_backend => taskbackend}/repo/TaskRepo.java | 4 ++-- .../utils/DateUtils.java | 2 +- .../utils/ValidationException.java | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) rename src/main/java/br/ce/wcaquino/{tasks_backend => taskbackend}/ServletInitializer.java (91%) rename src/main/java/br/ce/wcaquino/{tasks_backend => taskbackend}/TasksBackendApplication.java (88%) rename src/main/java/br/ce/wcaquino/{tasks_backend => taskbackend}/controller/RootController.java (87%) rename src/main/java/br/ce/wcaquino/{tasks_backend => taskbackend}/controller/TaskController.java (82%) rename src/main/java/br/ce/wcaquino/{tasks_backend => taskbackend}/model/Task.java (94%) rename src/main/java/br/ce/wcaquino/{tasks_backend => taskbackend}/repo/TaskRepo.java (58%) rename src/main/java/br/ce/wcaquino/{tasks_backend => taskbackend}/utils/DateUtils.java (81%) rename src/main/java/br/ce/wcaquino/{tasks_backend => taskbackend}/utils/ValidationException.java (88%) diff --git a/src/main/java/br/ce/wcaquino/tasks_backend/ServletInitializer.java b/src/main/java/br/ce/wcaquino/taskbackend/ServletInitializer.java similarity index 91% rename from src/main/java/br/ce/wcaquino/tasks_backend/ServletInitializer.java rename to src/main/java/br/ce/wcaquino/taskbackend/ServletInitializer.java index 71c28f9d1..c40c16d52 100644 --- a/src/main/java/br/ce/wcaquino/tasks_backend/ServletInitializer.java +++ b/src/main/java/br/ce/wcaquino/taskbackend/ServletInitializer.java @@ -1,4 +1,4 @@ -package br.ce.wcaquino.tasks_backend; +package br.ce.wcaquino.taskbackend; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; diff --git a/src/main/java/br/ce/wcaquino/tasks_backend/TasksBackendApplication.java b/src/main/java/br/ce/wcaquino/taskbackend/TasksBackendApplication.java similarity index 88% rename from src/main/java/br/ce/wcaquino/tasks_backend/TasksBackendApplication.java rename to src/main/java/br/ce/wcaquino/taskbackend/TasksBackendApplication.java index 61c0a8fe0..c037bb191 100644 --- a/src/main/java/br/ce/wcaquino/tasks_backend/TasksBackendApplication.java +++ b/src/main/java/br/ce/wcaquino/taskbackend/TasksBackendApplication.java @@ -1,4 +1,4 @@ -package br.ce.wcaquino.tasks_backend; +package br.ce.wcaquino.taskbackend; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/src/main/java/br/ce/wcaquino/tasks_backend/controller/RootController.java b/src/main/java/br/ce/wcaquino/taskbackend/controller/RootController.java similarity index 87% rename from src/main/java/br/ce/wcaquino/tasks_backend/controller/RootController.java rename to src/main/java/br/ce/wcaquino/taskbackend/controller/RootController.java index b9e714d55..534aca5d7 100644 --- a/src/main/java/br/ce/wcaquino/tasks_backend/controller/RootController.java +++ b/src/main/java/br/ce/wcaquino/taskbackend/controller/RootController.java @@ -1,4 +1,4 @@ -package br.ce.wcaquino.tasks_backend.controller; +package br.ce.wcaquino.taskbackend.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/src/main/java/br/ce/wcaquino/tasks_backend/controller/TaskController.java b/src/main/java/br/ce/wcaquino/taskbackend/controller/TaskController.java similarity index 82% rename from src/main/java/br/ce/wcaquino/tasks_backend/controller/TaskController.java rename to src/main/java/br/ce/wcaquino/taskbackend/controller/TaskController.java index e51dec96b..2b9281372 100644 --- a/src/main/java/br/ce/wcaquino/tasks_backend/controller/TaskController.java +++ b/src/main/java/br/ce/wcaquino/taskbackend/controller/TaskController.java @@ -1,4 +1,4 @@ -package br.ce.wcaquino.tasks_backend.controller; +package br.ce.wcaquino.taskbackend.controller; import java.util.List; @@ -11,10 +11,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import br.ce.wcaquino.tasks_backend.model.Task; -import br.ce.wcaquino.tasks_backend.repo.TaskRepo; -import br.ce.wcaquino.tasks_backend.utils.DateUtils; -import br.ce.wcaquino.tasks_backend.utils.ValidationException; +import br.ce.wcaquino.taskbackend.model.Task; +import br.ce.wcaquino.taskbackend.repo.TaskRepo; +import br.ce.wcaquino.taskbackend.utils.DateUtils; +import br.ce.wcaquino.taskbackend.utils.ValidationException; @RestController @RequestMapping(value ="/todo") diff --git a/src/main/java/br/ce/wcaquino/tasks_backend/model/Task.java b/src/main/java/br/ce/wcaquino/taskbackend/model/Task.java similarity index 94% rename from src/main/java/br/ce/wcaquino/tasks_backend/model/Task.java rename to src/main/java/br/ce/wcaquino/taskbackend/model/Task.java index 8684e6628..6f4f2d633 100644 --- a/src/main/java/br/ce/wcaquino/tasks_backend/model/Task.java +++ b/src/main/java/br/ce/wcaquino/taskbackend/model/Task.java @@ -1,4 +1,4 @@ -package br.ce.wcaquino.tasks_backend.model; +package br.ce.wcaquino.taskbackend.model; import java.time.LocalDate; diff --git a/src/main/java/br/ce/wcaquino/tasks_backend/repo/TaskRepo.java b/src/main/java/br/ce/wcaquino/taskbackend/repo/TaskRepo.java similarity index 58% rename from src/main/java/br/ce/wcaquino/tasks_backend/repo/TaskRepo.java rename to src/main/java/br/ce/wcaquino/taskbackend/repo/TaskRepo.java index 6f594a010..91c9986c7 100644 --- a/src/main/java/br/ce/wcaquino/tasks_backend/repo/TaskRepo.java +++ b/src/main/java/br/ce/wcaquino/taskbackend/repo/TaskRepo.java @@ -1,8 +1,8 @@ -package br.ce.wcaquino.tasks_backend.repo; +package br.ce.wcaquino.taskbackend.repo; import org.springframework.data.jpa.repository.JpaRepository; -import br.ce.wcaquino.tasks_backend.model.Task; +import br.ce.wcaquino.taskbackend.model.Task; public interface TaskRepo extends JpaRepository{ diff --git a/src/main/java/br/ce/wcaquino/tasks_backend/utils/DateUtils.java b/src/main/java/br/ce/wcaquino/taskbackend/utils/DateUtils.java similarity index 81% rename from src/main/java/br/ce/wcaquino/tasks_backend/utils/DateUtils.java rename to src/main/java/br/ce/wcaquino/taskbackend/utils/DateUtils.java index d7995f6dc..d06537014 100644 --- a/src/main/java/br/ce/wcaquino/tasks_backend/utils/DateUtils.java +++ b/src/main/java/br/ce/wcaquino/taskbackend/utils/DateUtils.java @@ -1,4 +1,4 @@ -package br.ce.wcaquino.tasks_backend.utils; +package br.ce.wcaquino.taskbackend.utils; import java.time.LocalDate; diff --git a/src/main/java/br/ce/wcaquino/tasks_backend/utils/ValidationException.java b/src/main/java/br/ce/wcaquino/taskbackend/utils/ValidationException.java similarity index 88% rename from src/main/java/br/ce/wcaquino/tasks_backend/utils/ValidationException.java rename to src/main/java/br/ce/wcaquino/taskbackend/utils/ValidationException.java index 45a05d565..9f9fe465e 100644 --- a/src/main/java/br/ce/wcaquino/tasks_backend/utils/ValidationException.java +++ b/src/main/java/br/ce/wcaquino/taskbackend/utils/ValidationException.java @@ -1,4 +1,4 @@ -package br.ce.wcaquino.tasks_backend.utils; +package br.ce.wcaquino.taskbackend.utils; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; From edb4fbee7a9244362b141361c3d9c23a660ac321 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Tue, 4 Jun 2024 06:39:19 -0500 Subject: [PATCH 06/35] Following name patterns --- pom.xml | 2 +- .../java/br/ce/wcaquino/taskbackend/ServletInitializer.java | 2 +- ...sksBackendApplication.java => TaskBackendApplication.java} | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename src/main/java/br/ce/wcaquino/taskbackend/{TasksBackendApplication.java => TaskBackendApplication.java} (69%) diff --git a/pom.xml b/pom.xml index 846a75480..c20dc1bed 100644 --- a/pom.xml +++ b/pom.xml @@ -11,8 +11,8 @@ br.ce.wcaquino tasks-backend 0.0.1-SNAPSHOT - war tasks-backend + war A very simple task management tool 21 diff --git a/src/main/java/br/ce/wcaquino/taskbackend/ServletInitializer.java b/src/main/java/br/ce/wcaquino/taskbackend/ServletInitializer.java index c40c16d52..923914ff9 100644 --- a/src/main/java/br/ce/wcaquino/taskbackend/ServletInitializer.java +++ b/src/main/java/br/ce/wcaquino/taskbackend/ServletInitializer.java @@ -7,7 +7,7 @@ public class ServletInitializer extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(TasksBackendApplication.class); + return application.sources(TaskBackendApplication.class); } } diff --git a/src/main/java/br/ce/wcaquino/taskbackend/TasksBackendApplication.java b/src/main/java/br/ce/wcaquino/taskbackend/TaskBackendApplication.java similarity index 69% rename from src/main/java/br/ce/wcaquino/taskbackend/TasksBackendApplication.java rename to src/main/java/br/ce/wcaquino/taskbackend/TaskBackendApplication.java index c037bb191..6093776d3 100644 --- a/src/main/java/br/ce/wcaquino/taskbackend/TasksBackendApplication.java +++ b/src/main/java/br/ce/wcaquino/taskbackend/TaskBackendApplication.java @@ -4,10 +4,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class TasksBackendApplication { +public class TaskBackendApplication { public static void main(String[] args) { - SpringApplication.run(TasksBackendApplication.class, args); + SpringApplication.run(TaskBackendApplication.class, args); } } From 0790a0f6cc0b07f55a204d8be8bd557396d8d1df Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Tue, 4 Jun 2024 06:41:40 -0500 Subject: [PATCH 07/35] Add final name --- .../ce/wcaquino/taskbackend/ServletInitializer.java | 13 ------------- .../taskbackend/TaskBackendApplication.java | 8 +++++++- 2 files changed, 7 insertions(+), 14 deletions(-) delete mode 100644 src/main/java/br/ce/wcaquino/taskbackend/ServletInitializer.java diff --git a/src/main/java/br/ce/wcaquino/taskbackend/ServletInitializer.java b/src/main/java/br/ce/wcaquino/taskbackend/ServletInitializer.java deleted file mode 100644 index 923914ff9..000000000 --- a/src/main/java/br/ce/wcaquino/taskbackend/ServletInitializer.java +++ /dev/null @@ -1,13 +0,0 @@ -package br.ce.wcaquino.taskbackend; - -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; - -public class ServletInitializer extends SpringBootServletInitializer { - - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(TaskBackendApplication.class); - } - -} diff --git a/src/main/java/br/ce/wcaquino/taskbackend/TaskBackendApplication.java b/src/main/java/br/ce/wcaquino/taskbackend/TaskBackendApplication.java index 6093776d3..f01578cc7 100644 --- a/src/main/java/br/ce/wcaquino/taskbackend/TaskBackendApplication.java +++ b/src/main/java/br/ce/wcaquino/taskbackend/TaskBackendApplication.java @@ -2,12 +2,18 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @SpringBootApplication -public class TaskBackendApplication { +public class TaskBackendApplication extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(TaskBackendApplication.class, args); } + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(TaskBackendApplication.class); + } } From 258ab29a144844a56ea213045561adba197a2b2f Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Wed, 5 Jun 2024 22:16:50 -0500 Subject: [PATCH 08/35] =?UTF-8?q?Testes=20unit=C3=A1rios=20da=20aplica?= =?UTF-8?q?=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 8 +- .../controller/TaskControllerTest.java | 76 +++++++++++++++++++ .../taskbackend/utils/DateUtilsTest.java | 27 +++++++ 3 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 src/test/java/br/ce/wcaquino/taskbackend/controller/TaskControllerTest.java create mode 100644 src/test/java/br/ce/wcaquino/taskbackend/utils/DateUtilsTest.java diff --git a/pom.xml b/pom.xml index c20dc1bed..90294127c 100644 --- a/pom.xml +++ b/pom.xml @@ -47,10 +47,10 @@ test - org.mockito - mockito-all - 1.10.19 - test + org.mockito + mockito-core + 2.22.0 + test diff --git a/src/test/java/br/ce/wcaquino/taskbackend/controller/TaskControllerTest.java b/src/test/java/br/ce/wcaquino/taskbackend/controller/TaskControllerTest.java new file mode 100644 index 000000000..5fe8e289a --- /dev/null +++ b/src/test/java/br/ce/wcaquino/taskbackend/controller/TaskControllerTest.java @@ -0,0 +1,76 @@ +package br.ce.wcaquino.taskbackend.controller; + +import java.time.LocalDate; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; + +import br.ce.wcaquino.taskbackend.model.Task; +import br.ce.wcaquino.taskbackend.repo.TaskRepo; +import br.ce.wcaquino.taskbackend.utils.ValidationException; + +public class TaskControllerTest { + + @Mock + private TaskRepo taskRepo; + + @InjectMocks + private TaskController controller; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void naoDeveSalvarTarefaSemDescricao() { + Task todo = new Task(); + todo.setDueDate(LocalDate.now()); + try { + controller.save(todo); + Assert.fail("Não deveria chegar nesse ponto!"); + } catch (ValidationException e) { + Assert.assertEquals("Fill the task description", e.getMessage()); + } + } + + @Test + public void naoDeveSalvarTarefaSemData() { + Task todo = new Task(); + todo.setTask("Descricao"); + try { + controller.save(todo); + Assert.fail("Não deveria chegar nesse ponto!"); + } catch (ValidationException e) { + Assert.assertEquals("Fill the due date", e.getMessage()); + } + } + + @Test + public void naoDeveSalvarTarefaComDataPassada() { + Task todo = new Task(); + todo.setTask("Descricao"); + todo.setDueDate(LocalDate.of(2010, 01, 01)); + try { + controller.save(todo); + Assert.fail("Não deveria chegar nesse ponto!"); + } catch (ValidationException e) { + Assert.assertEquals("Due date must not be in past", e.getMessage()); + } + } + + @Test + public void deveSalvarTarefaComSucesso() throws ValidationException { + Task todo = new Task(); + todo.setTask("Descricao"); + todo.setDueDate(LocalDate.now()); + controller.save(todo); + + Mockito.verify(taskRepo).save(todo); + } +} \ No newline at end of file diff --git a/src/test/java/br/ce/wcaquino/taskbackend/utils/DateUtilsTest.java b/src/test/java/br/ce/wcaquino/taskbackend/utils/DateUtilsTest.java new file mode 100644 index 000000000..59f6bca23 --- /dev/null +++ b/src/test/java/br/ce/wcaquino/taskbackend/utils/DateUtilsTest.java @@ -0,0 +1,27 @@ +package br.ce.wcaquino.taskbackend.utils; + +import java.time.LocalDate; + +import org.junit.Assert; +import org.junit.Test; + +public class DateUtilsTest { + + @Test + public void deveRetornarTrueParaDatasFuturas() { + LocalDate date = LocalDate.of(2030, 01, 01); + Assert.assertTrue(DateUtils.isEqualOrFutureDate(date)); + } + + @Test + public void deveRetornarFalseParaDatasPassadas() { + LocalDate date = LocalDate.of(2010, 01, 01); + Assert.assertFalse(DateUtils.isEqualOrFutureDate(date)); + } + + @Test + public void deveRetornarTrueParaDataAtual() { + LocalDate date = LocalDate.now(); + Assert.assertTrue(DateUtils.isEqualOrFutureDate(date)); + } +} \ No newline at end of file From 0315a83d27a805f2cf24a59019e3e3a613cf3ac5 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Mon, 10 Jun 2024 07:34:57 -0500 Subject: [PATCH 09/35] adicionando erro --- .../ce/wcaquino/taskbackend/controller/TaskControllerTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/br/ce/wcaquino/taskbackend/controller/TaskControllerTest.java b/src/test/java/br/ce/wcaquino/taskbackend/controller/TaskControllerTest.java index 5fe8e289a..c93b19003 100644 --- a/src/test/java/br/ce/wcaquino/taskbackend/controller/TaskControllerTest.java +++ b/src/test/java/br/ce/wcaquino/taskbackend/controller/TaskControllerTest.java @@ -29,6 +29,8 @@ public void setup() { @Test public void naoDeveSalvarTarefaSemDescricao() { + System.out.println("asdasdas"); + Assert.fail(); Task todo = new Task(); todo.setDueDate(LocalDate.now()); try { From 8c848e7704827f460c0fa780067fc48ce9bf811c Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Mon, 10 Jun 2024 07:36:02 -0500 Subject: [PATCH 10/35] retirando erro --- .../ce/wcaquino/taskbackend/controller/TaskControllerTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/br/ce/wcaquino/taskbackend/controller/TaskControllerTest.java b/src/test/java/br/ce/wcaquino/taskbackend/controller/TaskControllerTest.java index c93b19003..5fe8e289a 100644 --- a/src/test/java/br/ce/wcaquino/taskbackend/controller/TaskControllerTest.java +++ b/src/test/java/br/ce/wcaquino/taskbackend/controller/TaskControllerTest.java @@ -29,8 +29,6 @@ public void setup() { @Test public void naoDeveSalvarTarefaSemDescricao() { - System.out.println("asdasdas"); - Assert.fail(); Task todo = new Task(); todo.setDueDate(LocalDate.now()); try { From 15f45fc24a39ca8949fa1125e24195ea7f66a331 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Sun, 23 Jun 2024 12:20:04 -0500 Subject: [PATCH 11/35] Error message --- src/main/resources/application.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 0fa94de64..e1e5a3db1 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,8 @@ server.port=8001 spring.application.name=tasks-backend +server.error.include-message=always + ## default connection pool spring.datasource.hikari.connectionTimeout=20000 spring.datasource.hikari.maximumPoolSize=5 From 5dbe44cb38262a1aaf4cf36bde366fcee96652a1 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Mon, 8 Jul 2024 20:31:46 -0500 Subject: [PATCH 12/35] acertando jacoco --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 90294127c..b04b9209b 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ 21 jacoco reuseReports - ${project.basedir}/target/jacoco.exec + ${project.basedir}/target/jacoco.xml From 6a3e52d5e81d4ee6825e30dab75833c62b2d77b7 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Mon, 8 Jul 2024 20:52:02 -0500 Subject: [PATCH 13/35] acertando jacoco --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b04b9209b..90294127c 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ 21 jacoco reuseReports - ${project.basedir}/target/jacoco.xml + ${project.basedir}/target/jacoco.exec From 429dd00da7f29fcd762263e37c2c646c1c2bf012 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Mon, 8 Jul 2024 21:15:05 -0500 Subject: [PATCH 14/35] acertando jacoco --- pom.xml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 90294127c..bce6abc5c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,12 +1,13 @@ - 4.0.0 org.springframework.boot spring-boot-starter-parent 3.3.0 - + br.ce.wcaquino tasks-backend @@ -16,9 +17,6 @@ A very simple task management tool 21 - jacoco - reuseReports - ${project.basedir}/target/jacoco.exec @@ -35,7 +33,7 @@ spring-boot-starter-tomcat provided - + org.postgresql postgresql @@ -47,10 +45,10 @@ test - org.mockito - mockito-core - 2.22.0 - test + org.mockito + mockito-core + 2.22.0 + test @@ -71,10 +69,14 @@ prepare-agent + + report + prepare-package + + report + + - - ${sonar.jacoco.reportPath} - From 616027f5f8b807b2f46ec70195cb6d00ac38f9cd Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Thu, 18 Jul 2024 20:52:36 -0500 Subject: [PATCH 15/35] Adicionando Jenkinsfile --- Jenkinsfile | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..3902a5b71 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,8 @@ +pipeline { + agent any + stages { + stage('Just Test') { + bat 'echo deu certo!' + } + } +} \ No newline at end of file From a7c97e40c6882e2e5dc34b83fce4a214604b398f Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Thu, 18 Jul 2024 20:55:17 -0500 Subject: [PATCH 16/35] Adicionando Jenkinsfile --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3902a5b71..656e4e140 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,9 @@ pipeline { agent any stages { stage('Just Test') { - bat 'echo deu certo!' + steps { + bat 'echo deu certo!' + } } } } \ No newline at end of file From a39814d68656a76381dfbf5c478f6ba78f368762 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Thu, 18 Jul 2024 20:58:47 -0500 Subject: [PATCH 17/35] pipeline evol --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 656e4e140..bd26b79df 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,9 +1,9 @@ pipeline { agent any stages { - stage('Just Test') { + stage('Build Backend') { steps { - bat 'echo deu certo!' + bat 'mvn clean package -DskipTests=true' } } } From c69a874a206ff172879800ecb309abda3ff26a29 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Thu, 18 Jul 2024 21:00:02 -0500 Subject: [PATCH 18/35] pipeline evol --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index bd26b79df..c0c663e6b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,5 +6,10 @@ pipeline { bat 'mvn clean package -DskipTests=true' } } + stage('Unit Tests') { + steps { + bat 'mvn test' + } + } } } \ No newline at end of file From 9a636201a77382d5bd0999dfe98e583981cd1c46 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Thu, 18 Jul 2024 21:05:10 -0500 Subject: [PATCH 19/35] pipeline evol --- Jenkinsfile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index c0c663e6b..e82636f6d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,5 +11,15 @@ pipeline { bat 'mvn test' } } + stage('Sonar Analysis') { + environment { + scannerHome = tool 'SONAR_SCANNER' + } + steps { + withSonarQubeEnv('SONAR_LOCAL') { + bat "${scannerHome}/bin/sonar-scanner -e -Dsonar.projectKey=DeployBack -Dsonar.projectName='DeployBack' -Dsonar.host.url=http://localhost:9000 -Dsonar.token=sqp_6e351c42da66a5d11418912d112c46ea217fe6a6 -Dsonar.java.binaries=target -Dsonar.sources=src/main -Dsonar.tests=src/test -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml -Dsonar.coverage.exclusions=**/model/**,**TaskBackendApplication.java" + } + } + } } } \ No newline at end of file From bae7a53b6a015185eb165a8ebe056637b32c621f Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Thu, 18 Jul 2024 21:19:06 -0500 Subject: [PATCH 20/35] pipeline evol --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e82636f6d..8cc812a25 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline { } stage('Unit Tests') { steps { - bat 'mvn test' + bat 'mvn test jacoco:report' } } stage('Sonar Analysis') { From 51b1fda61176ff427372ea697a7a959c04b3947e Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Thu, 18 Jul 2024 21:26:48 -0500 Subject: [PATCH 21/35] pipeline evol --- Jenkinsfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 8cc812a25..3bedda180 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,5 +21,12 @@ pipeline { } } } + stage('Quality Gate') { + steps { + timeout(time: 1, unit: 'MINUTES') { + waitForQualityGate abortPipeline: true + } + } + } } } \ No newline at end of file From e24444ad1b56804a2f68896119eab2080751e4a1 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Thu, 18 Jul 2024 21:27:48 -0500 Subject: [PATCH 22/35] pipeline evol --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 3bedda180..0612b5930 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,6 +23,7 @@ pipeline { } stage('Quality Gate') { steps { + sleep(5) timeout(time: 1, unit: 'MINUTES') { waitForQualityGate abortPipeline: true } From 5d84d5bc334b2e4783052ce13ea08162ec94b917 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Thu, 18 Jul 2024 21:29:29 -0500 Subject: [PATCH 23/35] pipeline evol --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0612b5930..daffd98ff 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,7 +23,7 @@ pipeline { } stage('Quality Gate') { steps { - sleep(5) + sleep(10) timeout(time: 1, unit: 'MINUTES') { waitForQualityGate abortPipeline: true } From 97bae7ca039796dbfc5b3e191419f9a6382805c8 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Fri, 19 Jul 2024 20:52:50 -0500 Subject: [PATCH 24/35] pipeline evol --- Jenkinsfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index daffd98ff..48dad3e2b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,5 +29,9 @@ pipeline { } } } + stage('Deploy Backend') + steps { + deploy adapters: [tomcat9(credentialsId: 'tomcat_login', path: '', url: 'http://localhost:8001/')], contextPath: 'tasks-backend', war: 'target/tasks-backend.war' + } } } \ No newline at end of file From eed4b6aac1379283bbd7a5e9b9a70772ba5d6361 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Fri, 19 Jul 2024 20:53:25 -0500 Subject: [PATCH 25/35] pipeline evol --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 48dad3e2b..4c0523783 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,9 +29,10 @@ pipeline { } } } - stage('Deploy Backend') + stage('Deploy Backend') { steps { deploy adapters: [tomcat9(credentialsId: 'tomcat_login', path: '', url: 'http://localhost:8001/')], contextPath: 'tasks-backend', war: 'target/tasks-backend.war' } + } } } \ No newline at end of file From e75077598b82e904deff138323d29eaee1cab41c Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Fri, 19 Jul 2024 20:57:19 -0500 Subject: [PATCH 26/35] pipeline evol --- Jenkinsfile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4c0523783..c63e550a4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,10 +23,10 @@ pipeline { } stage('Quality Gate') { steps { - sleep(10) - timeout(time: 1, unit: 'MINUTES') { - waitForQualityGate abortPipeline: true - } + // sleep(10) + // timeout(time: 1, unit: 'MINUTES') { + // waitForQualityGate abortPipeline: true + // } } } stage('Deploy Backend') { @@ -34,5 +34,10 @@ pipeline { deploy adapters: [tomcat9(credentialsId: 'tomcat_login', path: '', url: 'http://localhost:8001/')], contextPath: 'tasks-backend', war: 'target/tasks-backend.war' } } + stage('API Test') { + steps { + git credentialsId: 'gmail_wcaquino', url: 'https://github.com/wcca2024/tasks-api-test' + } + } } } \ No newline at end of file From f037184eacbe9b64eaa8a49b9b9497c70cec57af Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Fri, 19 Jul 2024 20:58:03 -0500 Subject: [PATCH 27/35] pipeline evol --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index c63e550a4..22bdd5767 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,6 +23,7 @@ pipeline { } stage('Quality Gate') { steps { + bash 'echo skipping...' // sleep(10) // timeout(time: 1, unit: 'MINUTES') { // waitForQualityGate abortPipeline: true From 37a1bacaafe41533af8763175947f2ef8c43817d Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Fri, 19 Jul 2024 21:01:05 -0500 Subject: [PATCH 28/35] pipeline evol --- Jenkinsfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 22bdd5767..56aa2ea1e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,7 +23,7 @@ pipeline { } stage('Quality Gate') { steps { - bash 'echo skipping...' + bat 'echo skipping...' // sleep(10) // timeout(time: 1, unit: 'MINUTES') { // waitForQualityGate abortPipeline: true @@ -37,7 +37,10 @@ pipeline { } stage('API Test') { steps { - git credentialsId: 'gmail_wcaquino', url: 'https://github.com/wcca2024/tasks-api-test' + dir('api-test') { + git credentialsId: 'gmail_wcaquino', url: 'https://github.com/wcca2024/tasks-api-test' + bat 'mvn test' + } } } } From 15edcd8f348edabf3c1381ccc7fa3ee78fbd266d Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Fri, 19 Jul 2024 21:04:31 -0500 Subject: [PATCH 29/35] pipeline evol --- Jenkinsfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 56aa2ea1e..55eddf18e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -43,5 +43,14 @@ pipeline { } } } + stage('Deploy Backend') { + steps { + dir('frontend') { + git credentialsId: 'gmail_wcaquino', url: 'https://github.com/wcca2024/tasks-frontend' + bat 'mvn clean package' + deploy adapters: [tomcat9(credentialsId: 'tomcat_login', path: '', url: 'http://localhost:8001/')], contextPath: 'tasks', war: 'target/tasks.war' + } + } + } } } \ No newline at end of file From 692270e8ff545812f8301ee407514060c9a5268a Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Fri, 19 Jul 2024 21:05:10 -0500 Subject: [PATCH 30/35] pipeline evol --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 55eddf18e..cd832388d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -43,7 +43,7 @@ pipeline { } } } - stage('Deploy Backend') { + stage('Deploy Frontend') { steps { dir('frontend') { git credentialsId: 'gmail_wcaquino', url: 'https://github.com/wcca2024/tasks-frontend' From 4e0baac54e6d3e015d532d418196bba9f6898afc Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Fri, 19 Jul 2024 21:06:48 -0500 Subject: [PATCH 31/35] pipeline evol --- Jenkinsfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index cd832388d..59fd071f5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -52,5 +52,13 @@ pipeline { } } } + stage('Functional Test') { + steps { + dir('functional-test') { + git credentialsId: 'gmail_wcaquino', url: 'https://github.com/wcca2024/tasks-functional-tests' + bat 'mvn test' + } + } + } } } \ No newline at end of file From d9fdc6fceb61647d163c54e0a32a44ed42d1912d Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Fri, 19 Jul 2024 21:43:59 -0500 Subject: [PATCH 32/35] pipeline evol --- Dockerfile | 6 +++++ Jenkinsfile | 6 +++++ docker-compose.yml | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..95f8a6746 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM tomcat:10.1.24-jdk21 + +ARG WAR_FILE +ARG CONTEXT + +COPY ${WAR_FILE} /usr/local/tomcat/webapps/${CONTEXT}.war \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 59fd071f5..ec4d5d58d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -60,5 +60,11 @@ pipeline { } } } + stage('Deploy Prod') { + steps { + bat 'docker-compose build' + bat 'docker-compose up -d' + } + } } } \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..f3e1b4e81 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,61 @@ +services: + db: + container_name: pg-prod + image: postgres:16.3 + networks: + - prod_net_back + environment: + - POSTGRES_PASSWORD=passwd + - POSTGRES_DB=tasks + volumes: + - prod_postgresql:/var/lib/postgresql + - prod_postgresql_data:/var/lib/postgresql/data + + backend: + container_name: backend-prod + image: back_prod:build_${BUILD_NUMBER} + build: + context: . + args: + - WAR_FILE=target/tasks-backend.war + - CONTEXT=tasks-backend + networks: + - prod_net_back + - prod_net_front + #ports: + # - 9998:8080 + environment: + - DATABASE_HOST=db + - DATABASE_PORT=5432 + - DATABASE_USER=postgres + - DATABASE_PASSWD=passwd + #- DATABASE_UPDATE=none + depends_on: + - db + + frontend: + container_name: frontend-prod + image: front_prod:build_${BUILD_NUMBER} + build: + context: . + args: + - WAR_FILE=frontend/target/tasks.war + - CONTEXT=tasks + networks: + - prod_net_front + ports: + - 9999:8080 + environment: + - BACKEND_HOST=backend + - BACKEND_PORT=8080 + - APP_VERSION=build_${BUILD_NUMBER} + #depends_on: + # - backend + +networks: + prod_net_front: + prod_net_back: + +volumes: + prod_postgresql: + prod_postgresql_data: \ No newline at end of file From 464f7b6bbb9f349924741949e0b0681430fffaee Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Fri, 19 Jul 2024 22:00:46 -0500 Subject: [PATCH 33/35] pipeline evol --- Jenkinsfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index ec4d5d58d..8f733b487 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -66,5 +66,13 @@ pipeline { bat 'docker-compose up -d' } } + stage('Functional Test') { + steps { + sleep(10) + dir('functional-test') { + bat 'mvn verify -Dskip.surefire.tests' + } + } + } } } \ No newline at end of file From e4e4505726c675baed659d3b3b08f6cb8fab4fe6 Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Fri, 19 Jul 2024 22:01:23 -0500 Subject: [PATCH 34/35] pipeline evol --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8f733b487..d0fc9ef2f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -66,7 +66,7 @@ pipeline { bat 'docker-compose up -d' } } - stage('Functional Test') { + stage('Healtha Check') { steps { sleep(10) dir('functional-test') { From 52689f345fccd19e24bf3785b291824dbcd7c00d Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Fri, 19 Jul 2024 22:03:57 -0500 Subject: [PATCH 35/35] pipeline evol --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d0fc9ef2f..192d771b4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -66,7 +66,7 @@ pipeline { bat 'docker-compose up -d' } } - stage('Healtha Check') { + stage('Health Check') { steps { sleep(10) dir('functional-test') {