cls
@echo off

ECHO. "Warning this bat will delete old acpg file!"

@REM set acpg_out file path
set ACPG_CONF_DIR=%~dp0\acpg

@REM set out acpg code path
set ACPG2JAVA=%~dp0\src\main\java\
set ACPG2JAVA_FULL_PATH=%ACPG2JAVA%\com\kfzs\duanduan\datashare\provider

ECHO. "Project Root: %~dp0

ECHO. "==== Your set ===="
ECHO. "acpg_out job dir: %ACPG_CONF_DIR%"
ECHO. "out acpg code dir: %ACPG2JAVA%"
ECHO. "out acpg code full dir: %ACPG2JAVA_FULL_PATH%"

if NOT EXIST %~dp0%ACPG_CONF_DIR% (
ECHO. "can not find %ACPG_CONF_DIR% for job please check"
goto update_error
)

if NOT EXIST %ACPG_CONF_DIR%\acpg-cli-1.12.0.jar (
ECHO. "can not find acpg-cli-1.12.0.jar at %ACPG_CONF_DIR% root path. stop update!"
goto update_error
)

if EXIST %~dp0%ACPG2JAVA_FULL_PATH% (
ECHO. "find old acpg_out out folder try to delete"
rd /s /q %~dp0%ACPG2JAVA_FULL_PATH%
PING 127.0.0.1 -n 3 >nul
)
mkdir %ACPG2JAVA_FULL_PATH%

ECHO. "==== Show Set End ==="

ECHO. "==== Start update acpg_out"
@REM start .\%ACPG_CONF_DIR%\acpg-cli.bat
%ACPG_CONF_DIR%\acpg-cli.bat -i %ACPG_CONF_DIR% -o %ACPG2JAVA%
ECHO. "==== End update acpg_out"
goto update_success

:update_success
ECHO. "update success"
ECHO. "File at %~dp0%ACPG2JAVA%"

:update_error
ECHO. "update error please see CLI out"
