-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·205 lines (161 loc) · 4.52 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·205 lines (161 loc) · 4.52 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#!/bin/bash
BLUE='\033[34m'
GREEN='\033[32m'
RED='\033[31m'
YELLOW='\033[33m'
BOLD='\033[1m'
NC='\033[0m'
OUTPUT_FILE=$(mktemp)
exec 1> >(tee -a "$OUTPUT_FILE")
exec 2> >(tee -a "$OUTPUT_FILE" >&2)
find_java_17() {
#MacOS, use java_home utility
if [[ "$OSTYPE" == "darwin"* ]]; then
if command -v /usr/libexec/java_home >/dev/null 2>&1; then
echo $(/usr/libexec/java_home -v 17)
return 0
fi
fi
# on other systems, check JAVA_HOME first
if [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ]; then
echo "$JAVA_HOME"
return 0
fi
# if JAVA_HOME is not set, try to find it using java command
if command -v java >/dev/null 2>&1; then
local java_bin=$(readlink -f $(which java))
local java_path=$(dirname $(dirname "$java_bin"))
if [[ -d "$java_path" ]]; then
echo "$java_path"
return 0
fi
fi
return 1
}
cleanup_and_ask() {
local exit_code=$1
echo -e "\nWould you like to see the complete output? (y/N): "
read -r show_output
if [[ "$show_output" =~ ^[Yy]$ ]]; then
less "$OUTPUT_FILE"
fi
rm -f "$OUTPUT_FILE"
exit $exit_code
}
spinner() {
local command="$1"
local message="$2"
local spin='-\|/'
local tmp_file=$(mktemp)
eval "$command" > "$tmp_file" 2>&1 &
local pid=$!
local i=0
printf " "
while kill -0 $pid 2>/dev/null; do
i=$(( (i+1) %4 ))
printf "\r%s %c %s" " " "${spin:$i:1}" "${message}"
sleep 0.1
done
wait $pid
local status=$?
cat "$tmp_file" >> "$OUTPUT_FILE"
printf "\r"
rm -f "$tmp_file"
return $status
}
print_header() {
echo -e "\n${BLUE}${BOLD}==> $1${NC}"
}
print_success() {
echo -e "${GREEN}✓ $1${NC}"
}
print_warning() {
echo -e "${YELLOW}! $1${NC}"
}
print_error() {
echo -e "${RED}✗ $1${NC}"
}
verify_jar() {
local jar_path=$1
if [[ -f "$jar_path" ]]; then
print_success "Verified $jar_path"
else
print_error "JAR file missing: $jar_path"
cleanup_and_ask 1
fi
}
print_header "Locating Java 17"
export JAVA_HOME=$(find_java_17)
if [ -z "$JAVA_HOME" ]; then
print_error "Java 17 not found. Please install Java 17."
cleanup_and_ask 1
fi
print_success "Found Java 17: $JAVA_HOME"
print_header "Building Plugin"
cd plugin
chmod +x compile.sh
spinner "./compile.sh" "Compiling plugin..."
if [ $? -eq 0 ]; then
print_success "Plugin compilation successful"
else
print_error "Plugin compilation failed"
cleanup_and_ask 1
fi
chmod +x compileInstall.sh
spinner "./compileInstall.sh" "Installing plugin..."
if [ $? -eq 0 ]; then
print_success "Plugin installation successful"
else
print_error "Plugin installation failed"
cleanup_and_ask 1
fi
cd ..
print_header "Building Backend Module"
cd backend
print_header "Compiling Backend"
spinner "JAVA_HOME=\"$JAVA_HOME\" mvn clean compile" "Compiling backend..."
if [ $? -eq 0 ]; then
print_success "Backend compilation successful"
else
print_error "Backend compilation failed"
cleanup_and_ask 1
fi
print_header "Installing Backend"
spinner "JAVA_HOME=\"$JAVA_HOME\" mvn clean install -DskipTests" "Installing backend..."
if [ $? -eq 0 ]; then
print_success "Backend installation successful"
else
print_error "Backend installation failed"
cleanup_and_ask 1
fi
verify_jar "target/backend-1.0-SNAPSHOT.jar"
cd ..
print_header "Building Frontend Module"
cd frontend
print_header "Compiling Frontend"
spinner "JAVA_HOME=\"$JAVA_HOME\" mvn clean compile" "Compiling frontend..."
if [ $? -eq 0 ]; then
print_success "Frontend compilation successful"
else
cleanup_and_ask 1
fi
print_header "Packaging Frontend"
spinner "JAVA_HOME=\"$JAVA_HOME\" mvn clean package -DskipTests" "Packaging frontend..."
if [ $? -eq 0 ]; then
print_success "Frontend packaging successful"
else
print_error "Frontend packaging failed"
cleanup_and_ask 1
fi
verify_jar "target/frontend-1.0-SNAPSHOT-jar-with-dependencies.jar"
cd ..
print_header "Build Summary"
echo -e "${BOLD}Plugin:${NC} Installed successfully"
echo -e "${BOLD}Backend module:${NC} Installed and verified"
echo -e "${BOLD}Frontend module:${NC} Packaged and verified"
echo -e "${BOLD}Build artifacts:${NC}"
echo " • Plugin JAR: plugin/target/plugin-1.0-SNAPSHOT.jar"
echo " • Backend JAR: backend/target/backend-1.0-SNAPSHOT.jar"
echo " • Frontend JAR: frontend/target/frontend-1.0-SNAPSHOT-jar-with-dependencies.jar"
print_success "Build completed successfully!"
cleanup_and_ask 0