aboutsummaryrefslogtreecommitdiffstats
path: root/build.bat
diff options
context:
space:
mode:
authorKostya <mail@sartin.in>2026-07-25 14:59:02 +0000
committerKostya <mail@sartin.in>2026-07-25 14:59:02 +0000
commit325d40e9bcc54d3389450fb951c873ffb466bb64 (patch)
tree1e67e8fc8caed8ccbca47df367706312c4ec581b /build.bat
parent0290b3ea1c810f21ce29efc3b7f24969aeeba9c4 (diff)
downloadjava-bootstrap-325d40e9bcc54d3389450fb951c873ffb466bb64.tar.gz
java-bootstrap-325d40e9bcc54d3389450fb951c873ffb466bb64.tar.xz
java-bootstrap-325d40e9bcc54d3389450fb951c873ffb466bb64.zip
fat jar build
Diffstat (limited to 'build.bat')
-rw-r--r--build.bat56
1 files changed, 56 insertions, 0 deletions
diff --git a/build.bat b/build.bat
new file mode 100644
index 0000000..e1f3d72
--- /dev/null
+++ b/build.bat
@@ -0,0 +1,56 @@
1@echo off
2setlocal enabledelayedexpansion
3
4echo === 1. Cleaning Workspace ===
5if exist bin rmdir /s /q bin
6if exist bin-test rmdir /s /q bin-test
7if exist fat-stage rmdir /s /q fat-stage
8if exist app.jar del app.jar
9mkdir bin
10mkdir bin-test
11mkdir fat-stage
12
13echo === 2. Compiling Production Code ===
14javac -d bin -cp "lib/*" src/com/example/App.java
15if %errorlevel% neq 0 exit /b %errorlevel%
16
17echo === 3. Compiling Test Code ===
18javac -d bin-test -cp "bin;lib/*" test/com/example/AppTest.java
19if %errorlevel% neq 0 exit /b %errorlevel%
20
21echo === 4. Running Automated Tests ===
22set "JUNIT_JAR="
23for %%f in (lib\junit-platform-console-standalone-*.jar) do set "JUNIT_JAR=%%f"
24if not defined JUNIT_JAR (echo JUnit jar missing. & exit /b 1)
25
26java -jar "!JUNIT_JAR!" --classpath "bin;bin-test;lib/*" --scan-class-path
27if %errorlevel% neq 0 (
28 echo ❌ Tests failed! Aborting build package.
29 exit /b %errorlevel%
30)
31echo ✅ Tests passed successfully!
32
33echo === 5. Extracting Dependencies for Fat JAR ===
34cd fat-stage
35for %%j in (..\lib\*.jar) do (
36 echo %%j | findstr /i "junit-platform-console-standalone" >nul
37 if errorlevel 1 (
38 echo Extracting: %%~nxj
39 jar -xf "%%j"
40 )
41)
42if exist META-INF rmdir /s /q META-INF
43cd ..
44
45echo === 6. Merging Assets into Fat JAR ===
46xcopy /e /q /y bin\* fat-stage\
47jar cfm app.jar manifest.txt -C fat-stage/ .
48if %errorlevel% neq 0 exit /b %errorlevel%
49
50rmdir /s /q fat-stage
51echo ======================================
52echo 🎉 Fat JAR Created! Run it anywhere using:
53echo java -jar app.jar
54echo ======================================
55pause
56