Files
AuthCenterConsoleApp/bash/build_class.sh
2026-01-14 16:57:27 +08:00

28 lines
825 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 编译目录配置已修正源文件目录为实际的src
BASE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
SRC_DIR="$BASE_DIR/src" # 核心修改源目录从runtime改为src
OUT_DIR="$BASE_DIR/src" # class文件输出到src与源文件同包结构
# 1. 递归查找所有.java源文件
JAVA_FILES=$(find "$SRC_DIR" -name "*.java")
if [ -z "$JAVA_FILES" ]; then
echo "错误:在 $SRC_DIR 目录下未找到任何.java文件"
exit 1
fi
# 2. 确保输出目录存在
mkdir -p "$OUT_DIR"
# 3. 执行编译
echo "开始编译Java文件输出目录$OUT_DIR"
javac -d "$OUT_DIR" $JAVA_FILES
# 4. 结果校验
if [ $? -eq 0 ]; then
echo "编译成功class文件已按包结构生成至 $OUT_DIR"
else
echo "编译失败请检查Java源文件语法或依赖"
exit 1
fi