- Add Docker Compose configurations for dev, prod, and standalone environments - Add database initialization scripts (init-db.sh, init-db-docker.sh) - Add enhanced start-docker-linux.sh with DB init support - Add comprehensive database initialization guide - Support for automatic dbexport.pgsql import on first run - Include safety checks for production environment
173 lines
5.9 KiB
Batchfile
173 lines
5.9 KiB
Batchfile
@echo off
|
|
setlocal enabledelayedexpansion
|
|
|
|
REM ----------------------------------------------------------------------
|
|
REM 기존 빌드 폴더 삭제 및 새로운 빌드 시작
|
|
REM ----------------------------------------------------------------------
|
|
echo Cleaning up old build artifacts...
|
|
if exist "WebContent\WEB-INF\classes\*" (
|
|
rmdir /s /q "WebContent\WEB-INF\classes"
|
|
)
|
|
|
|
echo Building Java application for development...
|
|
|
|
REM 필요한 디렉토리 생성
|
|
if not exist "WebContent\WEB-INF\classes" mkdir "WebContent\WEB-INF\classes"
|
|
if not exist "WebContent\WEB-INF\lib" mkdir "WebContent\WEB-INF\lib"
|
|
|
|
REM ----------------------------------------------------------------------
|
|
REM Servlet API JAR 파일 존재 여부 확인
|
|
REM ----------------------------------------------------------------------
|
|
set "SERVLET_API_JAR_PRIMARY_PATH=WebContent\WEB-INF\lib\javax.servlet-api-4.0.1.jar"
|
|
set "SERVLET_API_JAR_ALTERNATIVE_PATH=WebContent\WEB-INF\lib\servlet-api.jar"
|
|
|
|
if not exist "%SERVLET_API_JAR_PRIMARY_PATH%" if not exist "%SERVLET_API_JAR_ALTERNATIVE_PATH%" (
|
|
echo ---------------------------------------------------------------------------------
|
|
echo ERROR: Servlet API JAR (javax.servlet-api-4.0.1.jar or servlet-api.jar^)
|
|
echo not found in WebContent\WEB-INF\lib\
|
|
echo.
|
|
echo Please add the appropriate Servlet API JAR for your project.
|
|
echo You can typically find this JAR in a Tomcat distribution's 'lib' folder,
|
|
echo or download it from a trusted source like Maven Central Repository.
|
|
echo.
|
|
echo Build cannot proceed without it.
|
|
echo ---------------------------------------------------------------------------------
|
|
exit /b 1
|
|
) else (
|
|
if exist "%SERVLET_API_JAR_PRIMARY_PATH%" (
|
|
echo DEBUG: Confirmed Servlet API JAR is present at %SERVLET_API_JAR_PRIMARY_PATH%
|
|
) else if exist "%SERVLET_API_JAR_ALTERNATIVE_PATH%" (
|
|
echo DEBUG: Confirmed Servlet API JAR is present at %SERVLET_API_JAR_ALTERNATIVE_PATH%
|
|
)
|
|
)
|
|
|
|
REM ----------------------------------------------------------------------
|
|
REM 클래스패스 설정
|
|
set "EFFECTIVE_CLASSPATH=src;WebContent\WEB-INF\lib\*"
|
|
echo DEBUG: Effective classpath for javac: %EFFECTIVE_CLASSPATH%
|
|
|
|
REM src 폴더 내의 모든 .java 파일 컴파일
|
|
echo Compiling Java files for development...
|
|
|
|
REM Java 파일 목록을 임시 파일에 저장
|
|
if exist temp_java_files.txt del temp_java_files.txt
|
|
for /r src %%f in (*.java) do echo %%f >> temp_java_files.txt
|
|
|
|
if exist temp_java_files.txt (
|
|
javac -encoding UTF-8 -source 1.7 -target 1.7 -d WebContent\WEB-INF\classes -cp "%EFFECTIVE_CLASSPATH%" @temp_java_files.txt
|
|
if !errorlevel! neq 0 (
|
|
echo Java compilation failed. Exiting script.
|
|
del temp_java_files.txt
|
|
exit /b 1
|
|
)
|
|
del temp_java_files.txt
|
|
)
|
|
|
|
echo Java compilation successful.
|
|
|
|
REM ----------------------------------------------------------------------
|
|
REM src 폴더 내의 리소스 파일(.xml, .properties 등)을 classes 폴더로 복사
|
|
echo Copying resource files for development...
|
|
|
|
for /r src %%f in (*.xml *.properties) do (
|
|
set "filepath=%%f"
|
|
REM src\ 부분을 제거하여 상대 경로 생성
|
|
set "relative_path=%%f"
|
|
call set "relative_path=%%relative_path:*src\=%%"
|
|
set "target_file=WebContent\WEB-INF\classes\!relative_path!"
|
|
|
|
REM 대상 디렉토리 생성
|
|
for %%d in ("!target_file!") do (
|
|
if not exist "%%~dpd" mkdir "%%~dpd"
|
|
)
|
|
|
|
REM 파일 복사
|
|
copy "!filepath!" "!target_file!" >nul
|
|
if !errorlevel! neq 0 (
|
|
echo Error: Failed to copy !filepath! to !target_file!
|
|
exit /b 1
|
|
)
|
|
)
|
|
|
|
echo Java application build complete for development.
|
|
|
|
REM ----------------------------------------------------------------------
|
|
REM Git 변경사항 커밋 및 푸시
|
|
REM ----------------------------------------------------------------------
|
|
git add .
|
|
git commit -am "auto commit"
|
|
|
|
REM 현재 브랜치 확인
|
|
for /f "tokens=*" %%i in ('git branch --show-current') do set "current_branch=%%i"
|
|
|
|
git push origin %current_branch%
|
|
|
|
REM 마스터 브랜치와 병합 여부 확인
|
|
echo You are currently on branch: %current_branch%
|
|
set /p "proceed_merge=Would you like to merge the current branch with main? (Y/N) [Y]: "
|
|
if "%proceed_merge%"=="" set "proceed_merge=Y"
|
|
|
|
if /i "%proceed_merge%"=="Y" (
|
|
REM 마스터 브랜치로 전환 및 업데이트
|
|
git checkout main
|
|
git pull origin main
|
|
|
|
REM 현재 브랜치를 마스터에 병합
|
|
git merge --no-edit %current_branch%
|
|
|
|
REM 병합 결과 푸시
|
|
git push origin main
|
|
|
|
REM 원래 브랜치로 돌아가기
|
|
git checkout %current_branch%
|
|
)
|
|
|
|
REM 새로운 브랜치 생성
|
|
REM 현재 날짜를 YYYYMMDD 형식으로 가져오기
|
|
for /f "tokens=2 delims==" %%i in ('wmic OS Get localdatetime /value') do set "dt=%%i"
|
|
set "current_date=%dt:~0,8%"
|
|
|
|
REM 브랜치 이름에서 날짜 부분 추출
|
|
set "branch_date=%current_branch:~1,8%"
|
|
|
|
REM 현재 날짜와 브랜치 날짜가 같으면 뒤의 2자리 숫자를 증가시킴
|
|
if "%branch_date%"=="%current_date%" (
|
|
set "branch_number=%current_branch:~9,2%"
|
|
set /a "branch_number=branch_number+1"
|
|
) else (
|
|
set "branch_number=1"
|
|
)
|
|
|
|
REM 사용 가능한 브랜치 이름 찾기
|
|
:find_branch
|
|
if %branch_number% lss 10 (
|
|
set "formatted_number=0%branch_number%"
|
|
) else (
|
|
set "formatted_number=%branch_number%"
|
|
)
|
|
set "new_branch=V%current_date%%formatted_number%"
|
|
|
|
REM 로컬과 원격에 해당 이름의 브랜치가 존재하는지 확인
|
|
git show-ref --quiet refs/heads/%new_branch% >nul 2>&1
|
|
if !errorlevel! equ 0 goto increment_branch
|
|
|
|
git ls-remote --exit-code --heads origin %new_branch% >nul 2>&1
|
|
if !errorlevel! equ 0 goto increment_branch
|
|
|
|
goto create_branch
|
|
|
|
:increment_branch
|
|
set /a "branch_number=branch_number+1"
|
|
goto find_branch
|
|
|
|
:create_branch
|
|
REM 새로운 브랜치 생성
|
|
git checkout -b %new_branch%
|
|
|
|
REM 새로운 브랜치 푸시
|
|
git push origin %new_branch%
|
|
|
|
REM 변경 사항 확인
|
|
git status
|
|
|
|
endlocal |