Skip to content

Commit 0ff5fbd

Browse files
committed
Handle JaCoCo CLI jars without runnable manifests
1 parent 5bb17c1 commit 0ff5fbd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scripts/run-android-instrumentation-tests.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,15 @@ if [ -n "$COVERAGE_EXEC" ] && [ -f "$COVERAGE_EXEC" ]; then
408408
COVERAGE_XML="$COVERAGE_SITE_DIR/jacoco.xml"
409409
JACOCO_LOG="$COVERAGE_ARTIFACT_DIR/jacoco-report.log"
410410
ra_log "Generating JaCoCo report for Android port sources"
411-
if "$JAVA17_BIN" -jar "$JACOCO_CLI_JAR" report "$COVERAGE_EXEC" \
411+
JACOCO_CMD=("$JAVA17_BIN")
412+
JACOCO_MAIN_CLASS="org.jacoco.cli.internal.Main"
413+
if unzip -p "$JACOCO_CLI_JAR" META-INF/MANIFEST.MF 2>/dev/null | grep -qi 'Main-Class:'; then
414+
JACOCO_CMD+=("-jar" "$JACOCO_CLI_JAR")
415+
else
416+
ra_log "WARN: JaCoCo CLI jar missing Main-Class manifest; using explicit entry point"
417+
JACOCO_CMD+=("-cp" "$JACOCO_CLI_JAR" "$JACOCO_MAIN_CLASS")
418+
fi
419+
if "${JACOCO_CMD[@]}" report "$COVERAGE_EXEC" \
412420
--name "CodenameOneAndroidPort" \
413421
"${CLASSFILE_ARGS[@]}" \
414422
--sourcefiles "$REPO_ROOT/Ports/Android/src" \

0 commit comments

Comments
 (0)