| #!/bin/bash | |
| # Copyright 2026 Google LLC | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # https://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| # | |
| set -e | |
| # Navigate to the repository root | |
| # KOKORO_ARTIFACTS_DIR is set to /tmpfs/src by default in the Kokoro Ubuntu image. | |
| export KOKORO_ARTIFACTS_DIR="${KOKORO_ARTIFACTS_DIR:-/tmpfs/src}" | |
| cd "${KOKORO_ARTIFACTS_DIR}/git/staging" | |
| # Run Bazel build and test all targets | |
| bazel build ... | |
| bazel test ... | |
| # --- Run Gradle build and unit tests for C2PA Android SDK --- | |
| if [ -d "android" ] && [ -x "android/gradlew" ]; then | |
| if ! java -version 2>&1 | grep -q "17\."; then | |
| echo "Installing OpenJDK 17..." | |
| sudo apt-get update || true | |
| sudo apt-get install -y openjdk-17-jdk || true | |
| export JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64" | |
| export PATH="${JAVA_HOME}/bin:${PATH}" | |
| fi | |
| cd android | |
| ./gradlew assembleDebug testDebugUnitTest --no-daemon --stacktrace | |
| else | |
| echo "No android/gradlew found; skipping Android Gradle build." | |
| fi |