-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild_all.sh
executable file
·60 lines (50 loc) · 1.84 KB
/
build_all.sh
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
#!/bin/bash
# Script to build all modules in the multi-module Gradle project
# This will run a clean build on each module and report success/failure
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Auto-discover modules by finding all build.gradle.kts files
echo "Discovering modules..."
# Use a more portable approach instead of mapfile (which is bash 4+ only)
MODULES=()
while IFS= read -r line; do
MODULES+=("$line")
done < <(find . -type f -name "build.gradle.kts" -not -path "./build.gradle.kts" | sed -e 's|^./||' -e 's|/build.gradle.kts||' | sed -e 's|/|-|g' | awk '{print ":" $0}')
# Print discovered modules
echo -e "${GREEN}Found ${#MODULES[@]} modules:${NC}"
printf " %s\n" "${MODULES[@]}"
echo ""
# Track success and failure
SUCCESS_COUNT=0
FAILED_COUNT=0
FAILED_MODULES=""
# Start in the project root directory
cd "$(dirname "$0")"
# Loop through each module and run gradle build
for module in "${MODULES[@]}"; do
echo -e "\n\n${GREEN}Building ${module}${NC}"
echo "========================================"
# Run with clean build and quiet output (just show errors)
if ./gradlew ${module}:clean ${module}:build --quiet; then
echo -e "${GREEN}✓ Build successful for ${module}${NC}"
((SUCCESS_COUNT++))
else
echo -e "${RED}✗ Build failed for ${module}${NC}"
((FAILED_COUNT++))
FAILED_MODULES="${FAILED_MODULES}\n - ${module}"
fi
done
# Print summary
echo -e "\n\n${GREEN}========================================"
echo "BUILD SUMMARY"
echo "========================================${NC}"
echo -e "Total modules: $((SUCCESS_COUNT + FAILED_COUNT))"
echo -e "${GREEN}Successful: ${SUCCESS_COUNT}${NC}"
if [ $FAILED_COUNT -gt 0 ]; then
echo -e "${RED}Failed: ${FAILED_COUNT}${NC}"
echo -e "${RED}Failed modules:${FAILED_MODULES}${NC}"
else
echo -e "${GREEN}All builds successful!${NC}"
fi