#!/usr/bin/env bash # Run Maven inside the DangerousThings smartcard-ci Docker image. # # The image (vivokey/smartcard-ci) ships a pre-built jcardsim-3.0.5-SNAPSHOT, # Oracle JavaCard SDKs, Java 8, and Maven. On first run we seed a named # Docker volume with the image's baseline .m2 so subsequent runs keep # downloaded deps (JUnit etc.) warm between invocations. # # Usage: ./scripts/dt-mvn.sh e.g.: ./scripts/dt-mvn.sh -q test set -euo pipefail IMAGE="vivokey/smartcard-ci:latest" VOLUME="aliro-smartcard-m2" project_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." &> /dev/null && pwd)" if ! docker volume inspect "$VOLUME" >/dev/null 2>&1; then echo "Seeding $VOLUME with baseline .m2 from $IMAGE (one-time)" >&2 docker volume create "$VOLUME" >/dev/null docker run --rm -v "$VOLUME:/dst" --entrypoint sh "$IMAGE" \ -c 'cp -a /root/.m2/. /dst/ && chmod -R a+rwX /dst' fi # GlobalPlatform Amendment H export files (vendored under build-tools/gp-amdh/). # Mounted into the SDK's api_export_files tree so the JC 3.0.5 converter can # resolve org.globalplatform.* imports during CAP conversion. The mount is # unconditional: when the j3r180 profile builds, no source imports those # packages, so the converter never opens these exports. GP_AMDH_EXPORTS="$project_root/build-tools/gp-amdh/exports/org" exec docker run --rm -t \ -v "$project_root:/work" -w /work \ -v "$VOLUME:/root/.m2" \ -v "$GP_AMDH_EXPORTS:/app/sdks/jc305u3_kit/api_export_files/org:ro" \ -e JC_CLASSIC_HOME=/app/sdks/jc305u3_kit \ "$IMAGE" "mvn $*"