-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathrun_interactions_examples.sh
More file actions
executable file
·67 lines (56 loc) · 1.61 KB
/
run_interactions_examples.sh
File metadata and controls
executable file
·67 lines (56 loc) · 1.61 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
#!/bin/bash
# Script to run Java GenAI SDK Interaction examples using Maven.
ORIGINAL_DIR=$(pwd)
declare -A FAILED_EXAMPLES
# --- Install the package if needed ---
if [ -z "$(find target -name 'google-genai-*.jar')" ]; then
echo "Project JAR not found in target/. Running 'mvn install'..."
mvn install -Dclirr.skip=true
else
echo "Project JAR found. Skipping 'mvn install'."
fi
cd examples
echo "Compiling the examples..."
mvn compile
if [ $? -ne 0 ]; then
echo "----------------------------------------"
echo "ERROR: Maven compilation failed. Exiting."
echo "----------------------------------------"
cd "$ORIGINAL_DIR"
exit 1
fi
declare -a TARGETS=()
for file in src/main/java/com/google/genai/examples/Interaction*.java; do
if [ -f "$file" ]; then
TARGETS+=("$(basename "$file" .java)")
fi
done
if [ ${#TARGETS[@]} -eq 0 ]; then
echo "No interaction examples found matching Interaction*.java"
cd "$ORIGINAL_DIR"
exit 0
fi
for target in "${TARGETS[@]}"; do
echo "========================================"
echo "Running: $target"
echo "========================================"
mvn exec:java -Dexec.mainClass="com.google.genai.examples.$target"
if [ $? -ne 0 ]; then
echo "ERROR: $target failed."
FAILED_EXAMPLES["$target"]="Failed"
else
echo "SUCCESS: $target completed."
fi
done
cd "$ORIGINAL_DIR"
echo "========================================"
if [ ${#FAILED_EXAMPLES[@]} -eq 0 ]; then
echo "All interaction examples passed! ✅"
exit 0
else
echo "The following examples failed: ❌"
for failed in "${!FAILED_EXAMPLES[@]}"; do
echo " - $failed"
done
exit 1
fi