diff --git a/pom.xml b/pom.xml index 90c59456185..decdfc4e50a 100644 --- a/pom.xml +++ b/pom.xml @@ -328,6 +328,7 @@ com/google/genai/types/AutoValue_*.class + com/google/genai/shaded/**/*.class @@ -393,6 +394,48 @@ + + org.apache.maven.plugins + maven-shade-plugin + 3.6.0 + + + package + + shade + + + + + org.jetbrains.kotlin:kotlin-stdlib-jdk8 + org.jetbrains.kotlin:kotlin-stdlib + com.fasterxml.jackson.module:jackson-module-kotlin + + + + + kotlin. + com.google.genai.shaded.kotlin. + + + com.fasterxml.jackson.module.kotlin. + com.google.genai.shaded.jackson.module.kotlin. + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + org.codehaus.mojo build-helper-maven-plugin diff --git a/run_interactions_examples.sh b/run_interactions_examples.sh new file mode 100755 index 00000000000..e4b84dd2256 --- /dev/null +++ b/run_interactions_examples.sh @@ -0,0 +1,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