Files
distribution_erp/build-mac.sh
T
chpark 3e135041ac Initial commit: ILSHIN PLM 프로젝트 소스 코드
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 17:49:38 +09:00

169 lines
4.6 KiB
Bash
Executable File
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
# macOS 전용 Java 애플리케이션 빌드 스크립트
# Windows build-windows.bat의 macOS 버전
set -e # 오류 발생 시 스크립트 중단
echo "==============================================="
echo " Java Application Build for macOS"
echo "==============================================="
echo ""
# macOS 확인
if [[ "$(uname -s)" != "Darwin" ]]; then
echo "❌ ERROR: This script is designed for macOS only."
echo "Current OS: $(uname -s)"
exit 1
fi
echo "🍎 Running on macOS..."
echo "[1] Checking Java environment..."
# Java 런타임 확인
if ! command -v java &> /dev/null; then
echo "❌ ERROR: Java not found in PATH"
echo "Please install Java and add to PATH"
exit 1
fi
# Java 컴파일러 확인
if ! command -v javac &> /dev/null; then
echo "❌ ERROR: Java compiler not found"
echo "Please install JDK"
exit 1
fi
# Java 버전 표시
java_version=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2)
javac_version=$(javac -version 2>&1 | cut -d' ' -f2)
echo "✅ Java Runtime: $java_version"
echo "✅ Java Compiler: $javac_version"
echo "Java environment OK"
echo "[2] Cleaning previous build..."
if [ -d "WebContent/WEB-INF/classes" ]; then
rm -rf WebContent/WEB-INF/classes
fi
echo "✅ Previous build cleaned"
echo "[3] Creating directories..."
mkdir -p WebContent/WEB-INF/classes
mkdir -p WebContent/WEB-INF/lib
mkdir -p logs
echo "✅ Directories created"
echo "[4] Checking libraries..."
SERVLET_JAR1="WebContent/WEB-INF/lib/javax.servlet-api-4.0.1.jar"
SERVLET_JAR2="WebContent/WEB-INF/lib/servlet-api.jar"
if [ ! -f "$SERVLET_JAR1" ] && [ ! -f "$SERVLET_JAR2" ]; then
echo "❌ ERROR: Servlet API JAR not found"
echo "Need: $SERVLET_JAR1 or $SERVLET_JAR2"
echo ""
echo "💡 You can download it from:"
echo " - Maven Central Repository"
echo " - Tomcat distribution's 'lib' folder"
exit 1
fi
if [ -f "$SERVLET_JAR1" ]; then
echo "✅ Found: $SERVLET_JAR1"
elif [ -f "$SERVLET_JAR2" ]; then
echo "✅ Found: $SERVLET_JAR2"
fi
echo "Libraries OK"
echo "[5] Setting classpath..."
CLASSPATH="src:WebContent/WEB-INF/lib/*"
echo "📋 Classpath: $CLASSPATH"
echo "[6] Finding Java files..."
# 임시 파일 생성
JAVA_SOURCES_FILE=$(mktemp)
trap "rm -f $JAVA_SOURCES_FILE" EXIT
# Java 파일 찾기
find src -name "*.java" -type f > "$JAVA_SOURCES_FILE"
java_count=$(wc -l < "$JAVA_SOURCES_FILE" | tr -d ' ')
if [ "$java_count" -eq 0 ]; then
echo "⚠️ WARNING: No Java files found"
else
echo "✅ Found $java_count Java files"
fi
echo "[7] Compiling Java files..."
if [ -s "$JAVA_SOURCES_FILE" ]; then
echo "⚙️ Starting compilation..."
# Java 파일 컴파일 (Java 7 호환성 유지)
javac \
-encoding UTF-8 \
-source 1.7 \
-target 1.7 \
-d WebContent/WEB-INF/classes \
-cp "$CLASSPATH" \
-Xlint:unchecked \
-Xlint:deprecation \
@"$JAVA_SOURCES_FILE"
if [ $? -eq 0 ]; then
echo "✅ Compilation completed successfully"
else
echo "❌ ERROR: Compilation failed"
exit 1
fi
else
echo "️ No Java files to compile"
fi
echo "[8] Copying resources..."
resource_count=0
# 리소스 파일 복사 (XML, Properties, SQL)
find src -type f \( -name "*.xml" -o -name "*.properties" -o -name "*.sql" \) -print0 | \
while IFS= read -r -d '' source_file; do
# 'src/' 접두사를 제거하여 상대 경로 생성
relative_path="${source_file#src/}"
target_file="WebContent/WEB-INF/classes/$relative_path"
# 대상 디렉토리 생성
target_dir="$(dirname "$target_file")"
if [ ! -d "$target_dir" ]; then
mkdir -p "$target_dir"
fi
# 파일 복사
if cp "$source_file" "$target_file" 2>/dev/null; then
resource_count=$((resource_count + 1))
fi
done
echo "✅ Copied $resource_count resource files"
echo ""
echo "==============================================="
echo "🎉 Build completed successfully!"
echo "==============================================="
echo "📁 Classes: WebContent/WEB-INF/classes/"
echo "📚 Libraries: WebContent/WEB-INF/lib/"
echo "📝 Logs: logs/"
echo ""
# 빌드 결과 요약
echo "📊 Build Summary:"
if [ -d "WebContent/WEB-INF/classes" ]; then
class_count=$(find WebContent/WEB-INF/classes -name "*.class" | wc -l | tr -d ' ')
echo " - Compiled classes: $class_count"
fi
if [ -d "WebContent/WEB-INF/lib" ]; then
lib_count=$(find WebContent/WEB-INF/lib -name "*.jar" | wc -l | tr -d ' ')
echo " - Library JARs: $lib_count"
fi
echo " - Resource files: $resource_count"
echo ""
echo "🏁 Ready for deployment!"