@echo off setlocal enabledelayedexpansion echo === 1. Cleaning Workspace === if exist bin rmdir /s /q bin if exist bin-test rmdir /s /q bin-test if exist fat-stage rmdir /s /q fat-stage if exist app.jar del app.jar mkdir bin mkdir bin-test mkdir fat-stage echo === 2. Compiling Production Code === javac -d bin -cp "lib/*" src/com/example/App.java if %errorlevel% neq 0 exit /b %errorlevel% echo === 3. Compiling Test Code === javac -d bin-test -cp "bin;lib/*" test/com/example/AppTest.java if %errorlevel% neq 0 exit /b %errorlevel% echo === 4. Running Automated Tests === set "JUNIT_JAR=" for %%f in (lib\junit-platform-console-standalone-*.jar) do set "JUNIT_JAR=%%f" if not defined JUNIT_JAR (echo JUnit jar missing. & exit /b 1) java -jar "!JUNIT_JAR!" --classpath "bin;bin-test;lib/*" --scan-class-path if %errorlevel% neq 0 ( echo ❌ Tests failed! Aborting build package. exit /b %errorlevel% ) echo ✅ Tests passed successfully! echo === 5. Extracting Dependencies for Fat JAR === cd fat-stage for %%j in (..\lib\*.jar) do ( echo %%j | findstr /i "junit-platform-console-standalone" >nul if errorlevel 1 ( echo Extracting: %%~nxj jar -xf "%%j" ) ) if exist META-INF rmdir /s /q META-INF cd .. echo === 6. Merging Assets into Fat JAR === xcopy /e /q /y bin\* fat-stage\ jar cfm app.jar manifest.txt -C fat-stage/ . if %errorlevel% neq 0 exit /b %errorlevel% rmdir /s /q fat-stage echo ====================================== echo 🎉 Fat JAR Created! Run it anywhere using: echo java -jar app.jar echo ====================================== pause