1616
1717# Ensure the report directory exists
1818mkdir -p " $REPORT_DIR "
19+ EXEC_FILES=$( find " $PROJECT_ROOT " -name " *.exec" -type f)
1920
20- # Issue 1: Simplified find command (avoiding array initialization)
21- EXEC_FILES=$( find " $PROJECT_ROOT " -name " jacoco-ut.exec" -type f)
22-
23- # Issue 2: Simplified check for empty results using -z
2421if [ -z " $EXEC_FILES " ]; then
25- echo " Error: No jacoco-ut .exec files found in $PROJECT_ROOT "
22+ echo " Error: No .exec files found in $PROJECT_ROOT "
2623 exit 1
2724fi
2825
@@ -43,21 +40,20 @@ echo "Generating coverage report..."
4340CLASSFILES_ARGS=()
4441SOURCEFILES_ARGS=()
4542
46- # Issue 5: Iterating over the string list instead of an array
47- for exec_file in ${EXEC_FILES} ; do
48- # Extract module path (e.g., core, dlm, rquota) from the exec file path
49- module_path=$( dirname " $( dirname " $( dirname " $exec_file " ) " ) " )
50-
51- # Add classfiles and sourcefiles arguments
52- CLASSFILES_ARGS+=(" --classfiles" " $module_path /target/classes" )
53- SOURCEFILES_ARGS+=(" --sourcefiles" " $module_path /src/main/java" )
43+ for module in $( find modules -maxdepth 1 -mindepth 1 -type d) ; do
44+ if [ -d " $module /target/classes" ]; then
45+ CLASSFILES_ARGS+=(" --classfiles" " $module /target/classes" )
46+ SOURCEFILES_ARGS+=(" --sourcefiles" " $module /src/main/java" )
47+ fi
5448done
5549
5650# Generate the report with dynamic arguments
5751java -jar " $JACOCO_CLI_JAR " report " $MERGED_EXEC " \
5852 " ${CLASSFILES_ARGS[@]} " \
5953 " ${SOURCEFILES_ARGS[@]} " \
60- --html " $REPORT_DIR "
54+ --html " $REPORT_DIR " \
55+ --xml " $PROJECT_ROOT /target/coverage-reports/jacoco-total.xml" \
56+ --csv " $PROJECT_ROOT /target/coverage-reports/jacoco-total.csv"
6157
6258if [ $? -ne 0 ]; then
6359 echo " Error: Failed to generate coverage report"
0 commit comments