From 7efe95a98658d4b5210fe65088e9efa8c6264fcd Mon Sep 17 00:00:00 2001 From: Buay Kun Gach Date: Thu, 19 Mar 2026 12:19:15 +0300 Subject: [PATCH] Add maven wrapper and clarigy frontend status in readme Fix #26 - add mvn wrapper and clarify frontend status in readme file Fix #25 - Clarify that greencode-frontend/ is planned butnot yet in repository --- .mvn/wrapper/maven-wrapper.properties | 3 + README.md | 2 +- mvnw | 99 ++++++++++++++++++ mvnw.cmd | 140 ++++++++++++++++++++++++++ 4 files changed, 243 insertions(+), 1 deletion(-) create mode 100644 .mvn/wrapper/maven-wrapper.properties create mode 100644 mvnw create mode 100644 mvnw.cmd diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..d570ddc --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,3 @@ +distributionBase=MAVEN_USER_HOME +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip diff --git a/README.md b/README.md index 2decc67..14b5752 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ GreenCode/ ├── src/ # Spring Boot source code ├── config/ # external configuration & scripts ├── docs/ # architecture, API docs -├── greencode-frontend/ # React frontend (new) +├── greencode-frontend/ # React frontend (planned - not yet in repo) ├── pom.xml # Maven build file └── docker-compose.yml # Docker orchestration diff --git a/mvnw b/mvnw new file mode 100644 index 0000000..f42dc5f --- /dev/null +++ b/mvnw @@ -0,0 +1,99 @@ +#!/bin/sh +# ----------------------------------------------------------------------------- +# 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. +# ----------------------------------------------------------------------------- + +# ----------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.2.0 +# +# Required ENV vars: +# JAVA_HOME - location of a JDK home dir +# +# ----------------------------------------------------------------------------- + +set -euf +[ "${MVNW_VERBOSE-}" != true ] || set -x + +# 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 + +# set JAVACMD and JAVA_HOME +if [ -z "${JAVA_HOME-}" ] ; then + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH." +else + JAVACMD="$JAVA_HOME/bin/java" + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME" + fi +fi + +[ -z "$JAVA_HOME" ] && die "JAVA_HOME not set" +[ -x "$JAVA_HOME/bin/java" ] || die "JAVA_HOME is not a valid java home directory" + +# Find the project base dir +cwd="$(pwd)" +MAVEN_PROJECTBASEDIR="${MAVEN_BASEDIR:-$cwd}" + +# Look for the --file switch and use the directory of that file as MAVEN_PROJECTBASEDIR +# This is a workaround for the case where the mvnw is called from a subdirectory +# of the project. +if [ -n "${MAVEN_PROJECTBASEDIR:-}" ] ; then + while [ "$MAVEN_PROJECTBASEDIR" != "/" ] ; do + if [ -f "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" ] ; then + break + fi + MAVEN_PROJECTBASEDIR="$(dirname "$MAVEN_PROJECTBASEDIR")" + done +fi + +# Download the wrapper jar if it doesn't exist +WRAPPER_JAR="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" +if [ ! -f "$WRAPPER_JAR" ] ; then + WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + printf "Downloading %s\n" "$WRAPPER_URL" + if command -v wget >/dev/null 2>&1; then + wget -q -O "$WRAPPER_JAR" "$WRAPPER_URL" || rm -f "$WRAPPER_JAR" + elif command -v curl >/dev/null 2>&1; then + curl -fsSL -o "$WRAPPER_JAR" "$WRAPPER_URL" || rm -f "$WRAPPER_JAR" + else + printf "Could not find wget or curl to download %s\n" "$WRAPPER_URL" + fi +fi + +if [ ! -f "$WRAPPER_JAR" ] ; then + die "ERROR: Could not find or download the Maven wrapper jar" +fi + +# JVM config +JVM_CONFIG_MAVEN_PROPS="" +if [ -f "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config" ] ; then + JVM_CONFIG_MAVEN_PROPS="$(cat "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config")" +fi + +# Execute the wrapper +exec "$JAVA_HOME/bin/java" $JVM_CONFIG_MAVEN_PROPS $MAVEN_OPTS $MAVEN_DEBUG_OPTS \ + -classpath "$WRAPPER_JAR" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + org.apache.maven.wrapper.MavenWrapperMain "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..3c20980 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,140 @@ +@REM ----------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@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 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 +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ----------------------------------------------------------------------------- + +@REM ----------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.2.0 +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM ----------------------------------------------------------------------------- + +@setlocal + +@set ERROR_CODE=0 + +@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 chkMHome + +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 + +:chkMHome +set "M2_HOME=%~dp0.mvn" + +if not "%M2_HOME%" == "" goto valMHome + +echo. +echo Error: M2_HOME is not set. >&2 +echo Please set the M2_HOME variable in your environment to match the >&2 +echo location of your Maven installation. >&2 +echo. +goto error + +:valMHome + +:init + +set "MAVEN_CMD_LINE_ARGS=%*" + +@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%" + +@REM Look for the --file switch and use the directory of that file as MAVEN_PROJECTBASEDIR +@REM This is a workaround for the case where the mvnw is called from a subdirectory +@REM of the project. +:loop +if "%WDIR%" == "%WDIR:~0,1%" goto endDetectBaseDir +if exist "%WDIR%\.mvn" goto endDetectBaseDir +cd /d "%WDIR%" +cd /d ".." +set "WDIR=%CD%" +goto loop + +:endDetectBaseDir +set "MAVEN_PROJECTBASEDIR=%WDIR%" +cd /d "%EXEC_DIR%" + +set "jvmConfig=%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" +if not exist "%jvmConfig%" goto endReadJvmConfig + +@REM Read the JVM config and export it to MAVEN_OPTS +@REM The first line starting with # is treated as a comment +@REM The rest is appended to MAVEN_OPTS +for /F "usebackq delims=" %%a in ("%jvmConfig%") do set "JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a" + +:endReadJvmConfig + +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 "WRAPPER_URL=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + +if exist "%WRAPPER_JAR%" goto runWrapper + +@REM Download the wrapper jar if it doesn't exist + +echo Downloading %WRAPPER_URL% +powershell -Command "& {trap{[System.Console]::Error.Write($_.Exception.Message);exit 1};(New-Object System.Net.WebClient).DownloadFile('%WRAPPER_URL%','%WRAPPER_JAR%');}" +if "%ERRORLEVEL%" == "0" goto runWrapper +echo Couldn't download %WRAPPER_URL% +goto error + +:runWrapper +set "MAVEN_CMD_LINE_ARGS=%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_CMD_LINE_ARGS% +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 "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +exit /B %ERROR_CODE%