REFACTOR END

This commit is contained in:
2025-09-28 10:10:01 +03:00
parent 394e0040de
commit 9b914b2904
117 changed files with 3070 additions and 5447 deletions

115
scripts/smart-build.sh Normal file
View File

@@ -0,0 +1,115 @@
#!/bin/bash
# Smart Gradle Build Wrapper
# Reduces semantic noise and provides clear error reporting
set -e
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$PROJECT_ROOT"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Pre-build checks
check_prerequisites() {
print_status "Checking prerequisites..."
# Check if Java is available
if ! command -v java &> /dev/null; then
print_error "Java is not installed or not in PATH"
exit 1
fi
# Check Android SDK
if [ -z "$ANDROID_HOME" ]; then
print_warning "ANDROID_HOME not set, using default detection"
fi
}
# Clean build artifacts
clean_build() {
print_status "Cleaning previous build artifacts..."
./gradlew clean --quiet --console=plain
}
# Run build with reduced verbosity
run_build() {
print_status "Starting Gradle build..."
# Capture build output
if ./gradlew build --quiet --console=plain --parallel 2>&1 | tee build.log; then
print_status "Build completed successfully!"
return 0
else
print_error "Build failed!"
return 1
fi
}
# Analyze build results
analyze_results() {
if [ -f "build.log" ]; then
# Extract key error information
errors=$(grep -c "ERROR" build.log || true)
warnings=$(grep -c "WARNING" build.log || true)
if [ "$errors" -gt 0 ]; then
print_error "Found $errors errors in build log"
echo "Top errors:"
grep "ERROR" build.log | head -5
fi
if [ "$warnings" -gt 0 ]; then
print_warning "Found $warnings warnings in build log"
fi
# Check for specific common issues
if grep -q "Unresolved reference" build.log; then
print_error "Found unresolved references - check imports and dependencies"
fi
if grep -q "MissingTranslation" build.log; then
print_error "Found missing translations - check string resources"
fi
fi
}
# Main execution
main() {
echo "========================================"
echo " HomeboxLens Smart Build System"
echo "========================================"
check_prerequisites
clean_build
if run_build; then
analyze_results
print_status "Build successful!"
exit 0
else
analyze_results
print_error "Build failed. Check build.log for details."
exit 1
fi
}
# Run main function
main "$@"