diff options
Diffstat (limited to 'tools/build.bat')
| -rw-r--r-- | tools/build.bat | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/tools/build.bat b/tools/build.bat deleted file mode 100644 index eb6b460..0000000 --- a/tools/build.bat +++ /dev/null | |||
| @@ -1,72 +0,0 @@ | |||
| 1 | @echo off | ||
| 2 | setlocal enabledelayedexpansion | ||
| 3 | |||
| 4 | echo === 1. Cleaning Workspace === | ||
| 5 | if exist bin rmdir /s /q bin | ||
| 6 | if exist stage rmdir /s /q stage | ||
| 7 | if exist dist rmdir /s /q dist | ||
| 8 | mkdir bin\classes | ||
| 9 | mkdir bin\test-classes | ||
| 10 | mkdir stage | ||
| 11 | mkdir dist | ||
| 12 | |||
| 13 | echo === 2. Compiling Production Code === | ||
| 14 | dir /s /b src\main\java\*.java > sources.txt | ||
| 15 | javac -d bin\classes -cp "lib/*" @sources.txt | ||
| 16 | if %errorlevel% neq 0 exit /b %errorlevel% | ||
| 17 | |||
| 18 | echo === 3. Compiling Test Code === | ||
| 19 | dir /s /b src\test\java\*.java > test-sources.txt | ||
| 20 | javac -d bin\test-classes -cp "bin\classes;lib/*" @test-sources.txt | ||
| 21 | if %errorlevel% neq 0 exit /b %errorlevel% | ||
| 22 | |||
| 23 | echo === 4. Running Automated Tests === | ||
| 24 | set "JUNIT_JAR=" | ||
| 25 | for %%f in (lib\junit-platform-console-standalone-*.jar) do set "JUNIT_JAR=%%f" | ||
| 26 | if not defined JUNIT_JAR (echo JUnit jar missing. & exit /b 1) | ||
| 27 | |||
| 28 | rem JUnit's --class-path does NOT expand lib\* -> build it explicitly | ||
| 29 | set "TEST_CP=bin\classes;bin\test-classes" | ||
| 30 | for %%j in (lib\*.jar) do set "TEST_CP=!TEST_CP!;%%j" | ||
| 31 | |||
| 32 | java -jar "!JUNIT_JAR!" execute -cp "!TEST_CP!" --scan-classpath | ||
| 33 | if %errorlevel% neq 0 ( | ||
| 34 | echo [X] Tests failed! Aborting build package. | ||
| 35 | exit /b %errorlevel% | ||
| 36 | ) | ||
| 37 | echo [OK] Tests passed successfully! | ||
| 38 | |||
| 39 | echo === 5. Extracting Dependencies for Fat JAR === | ||
| 40 | cd stage | ||
| 41 | for %%j in (..\lib\*.jar) do ( | ||
| 42 | echo %%~nxj | findstr /i "junit-platform-console-standalone" >nul | ||
| 43 | if errorlevel 1 ( | ||
| 44 | echo Extracting: %%~nxj | ||
| 45 | jar -xf "%%j" | ||
| 46 | ) | ||
| 47 | ) | ||
| 48 | |||
| 49 | rem Strip signatures + manifests (they break repacking) but KEEP | ||
| 50 | rem META-INF\services so ServiceLoader-based deps still work at runtime. | ||
| 51 | if exist META-INF ( | ||
| 52 | del /s /q META-INF\*.SF >nul 2>&1 | ||
| 53 | del /s /q META-INF\*.RSA >nul 2>&1 | ||
| 54 | del /s /q META-INF\*.DSA >nul 2>&1 | ||
| 55 | del /q META-INF\MANIFEST.MF >nul 2>&1 | ||
| 56 | ) | ||
| 57 | cd .. | ||
| 58 | |||
| 59 | echo === 6. Merging Assets into Fat JAR === | ||
| 60 | rem Merge ONLY production classes on top of the extracted deps | ||
| 61 | xcopy /e /q /y /i bin\classes\* stage\ >nul | ||
| 62 | rem Package the whole tree (deps + your classes), not just stage\classes | ||
| 63 | jar cfe dist/app.jar com.example.App -C stage . | ||
| 64 | if %errorlevel% neq 0 exit /b %errorlevel% | ||
| 65 | |||
| 66 | del sources.txt test-sources.txt >nul 2>&1 | ||
| 67 | rmdir /s /q stage | ||
| 68 | echo ====================================== | ||
| 69 | echo Fat JAR Created! Run it with: | ||
| 70 | echo java -jar dist/app.jar | ||
| 71 | echo ====================================== | ||
| 72 | pause | ||