-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile.bat
More file actions
63 lines (52 loc) · 1.45 KB
/
compile.bat
File metadata and controls
63 lines (52 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
@echo off
setlocal enabledelayedexpansion
REM Set the JAR filename
set NAME_JAR=JavaTest.jar
REM Set output folders
set BUILD_DIR=build
set LIBS_DIR=%BUILD_DIR%\libs
REM Make sure output folders exist
if not exist %LIBS_DIR% mkdir %LIBS_DIR%
REM Compile all Java files recursively, including any jars in libs for compilation
set CP=
for %%J in (libraries\*\*\*\*\*\*.java) do (
set CP=!CP!;%%J
)
for /R %%f in (*.java) do (
if defined CP (
javac -d %BUILD_DIR% -cp ".!CP!" %%f
) else (
javac -d %BUILD_DIR% %%f
)
)
for /R %%f in (*\*\*\*\*\*\*.java) do (
if defined CP (
javac -d %BUILD_DIR% -cp ".!CP!" %%f
) else (
javac -d %BUILD_DIR% %%f
)
)
REM Initialize JAR command with entry point
set JAR_CMD=jar cfe %LIBS_DIR%\%NAME_JAR% main.Main
REM Include all directories in build except 'libs'
for /D %%D in (%BUILD_DIR%\*) do (
if /I not "%%~nxD"=="libs" (
set JAR_CMD=!JAR_CMD! -C %BUILD_DIR% %%~nxD
)
)
REM Include any files directly inside BUILD_DIR (excluding 'libs')
for %%F in (%BUILD_DIR%\*) do (
if not "%%~nxF"=="libs" if not "%%~aF"=="d" (
set JAR_CMD=!JAR_CMD! -C %BUILD_DIR% %%~nxF
)
)
REM Include all libraries inside libraries/ into the final JAR (unpacked)
for %%J in (%LIBS_DIR%\*.java) do (
echo Adding %%~nxJ to JAR...
pushd %LIBS_DIR%
jar xf %%~nxJ
popd
)
REM Execute JAR command
%JAR_CMD%
echo Compilation finished! JAR is at %LIBS_DIR%\%NAME_JAR%