@@ -56,44 +56,72 @@ jobs:
5656 # Create the target directory
5757 mkdir -p build/intermediates/runtime_library_classes_dir/debug
5858
59- # Find all directories containing class files
60- CLASS_DIRS=$(find build -name "*.class" -type f -exec dirname {} \; | sort -u)
59+ # Find all directories containing class files with better patterns
60+ CLASS_DIRS=$(find build -name "*.class" -type f -exec dirname {} \; | sort -u | grep -E "(javac|kotlin-classes|runtime_library)" | head -10 )
6161
6262 if [ -z "$CLASS_DIRS" ]; then
6363 echo "WARNING: No class files found in the build directory!"
64+ echo "Searching in all build subdirectories..."
65+ find build -name "*.class" -type f | head -20
6466 else
6567 echo "Found class files in the following directories:"
6668 echo "$CLASS_DIRS"
6769
68- # Copy classes from the first directory with classes
69- FIRST_CLASS_DIR=$(echo "$CLASS_DIRS" | head -1)
70- echo "Copying classes from $FIRST_CLASS_DIR to build/intermediates/runtime_library_classes_dir/debug"
71- cp -r $FIRST_CLASS_DIR/* build/intermediates/runtime_library_classes_dir/debug/ || echo "Failed to copy from $FIRST_CLASS_DIR"
70+ # Copy classes from all relevant directories, not just the first one
71+ for CLASS_DIR in $CLASS_DIRS; do
72+ if [ -d "$CLASS_DIR" ] && [ "$(find "$CLASS_DIR" -name "*.class" | wc -l)" -gt 0 ]; then
73+ echo "Copying classes from $CLASS_DIR"
74+ cp -r "$CLASS_DIR"/* build/intermediates/runtime_library_classes_dir/debug/ 2>/dev/null || echo "Failed to copy from $CLASS_DIR"
75+ fi
76+ done
7277
7378 # Verify the target directory now has class files
7479 CLASS_COUNT=$(find build/intermediates/runtime_library_classes_dir/debug -name "*.class" | wc -l)
7580 echo "Target directory now contains $CLASS_COUNT class files"
7681 fi
7782
78- # Update sonar-project.properties with all found class directories as a fallback
79- echo "\n# Additional binary paths found during build" >> sonar-project.properties
80- echo "sonar.java.binaries=build/intermediates/runtime_library_classes_dir/debug,$CLASS_DIRS" >> sonar-project.properties
83+ # Update sonar-project.properties with all found class directories
84+ echo "" >> sonar-project.properties
85+ echo "# Additional binary paths found during build" >> sonar-project.properties
86+ if [ -n "$CLASS_DIRS" ]; then
87+ # Convert newlines to commas for sonar.java.binaries
88+ BINARY_PATHS=$(echo "$CLASS_DIRS" | tr '\n' ',' | sed 's/,$//')
89+ echo "sonar.java.binaries=build/intermediates/runtime_library_classes_dir/debug,$BINARY_PATHS" >> sonar-project.properties
90+ else
91+ echo "sonar.java.binaries=build/intermediates/runtime_library_classes_dir/debug" >> sonar-project.properties
92+ fi
8193
8294 echo "Checking for JaCoCo report files..."
83- find build -name "*.xml" | grep jacoco || echo "No XML files found"
84- find build -name "*.exec" | grep jacoco || echo "No exec files found"
95+ find build -name "*.xml" | grep jacoco || echo "No JaCoCo XML files found"
96+ find build -name "*.exec" | grep jacoco || echo "No JaCoCo exec files found"
97+
8598 echo "Contents of JaCoCo report directory:"
8699 ls -la build/reports/jacoco/jacocoTestReport/ || echo "Directory not found"
87100
88- echo "\nChecking test execution results:"
89- find build -name "TEST-*.xml" | xargs cat | grep -E 'tests|failures|errors|skipped' || echo "No test result files found"
101+ echo ""
102+ echo "Checking test execution results:"
103+ TEST_RESULT_FILES=$(find build -name "TEST-*.xml" 2>/dev/null)
104+ if [ -n "$TEST_RESULT_FILES" ]; then
105+ echo "Found test result files:"
106+ echo "$TEST_RESULT_FILES"
107+ # Count total tests, failures, errors
108+ TOTAL_TESTS=$(cat $TEST_RESULT_FILES | grep -o 'tests="[0-9]*"' | cut -d'"' -f2 | awk '{sum+=$1} END {print sum}')
109+ TOTAL_FAILURES=$(cat $TEST_RESULT_FILES | grep -o 'failures="[0-9]*"' | cut -d'"' -f2 | awk '{sum+=$1} END {print sum}')
110+ TOTAL_ERRORS=$(cat $TEST_RESULT_FILES | grep -o 'errors="[0-9]*"' | cut -d'"' -f2 | awk '{sum+=$1} END {print sum}')
111+ echo "Test summary: $TOTAL_TESTS tests, $TOTAL_FAILURES failures, $TOTAL_ERRORS errors"
112+ else
113+ echo "No test result files found"
114+ fi
90115
91- echo "\nChecking JaCoCo report content:"
116+ echo ""
117+ echo "Checking JaCoCo report content:"
92118 if [ -f build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml ]; then
93119 echo "Report file size: $(wc -c < build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml) bytes"
94120 echo "First 500 chars of report:"
95121 head -c 500 build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml
96- echo "\n\nCounting coverage elements:"
122+ echo ""
123+ echo ""
124+ echo "Counting coverage elements:"
97125 grep -c "<package" build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml || echo "No packages found"
98126 grep -c "<class" build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml || echo "No classes found"
99127 grep -c "<method" build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml || echo "No methods found"
@@ -103,12 +131,18 @@ jobs:
103131 echo "JaCoCo report file not found"
104132 fi
105133
106- echo "\nChecking binary directories specified in sonar-project.properties:"
134+ echo ""
135+ echo "Checking binary directories specified in sonar-project.properties:"
107136 echo "build/intermediates/runtime_library_classes_dir/debug:"
108137 ls -la build/intermediates/runtime_library_classes_dir/debug || echo "Directory not found"
109138
110- echo "\nChecking all available class directories:"
111- find build -path "*/build/*" -name "*.class" | head -n 5 || echo "No class files found"
139+ echo ""
140+ echo "Checking all available class directories:"
141+ find build -path "*/build/*" -name "*.class" | head -n 10 || echo "No class files found"
142+
143+ echo ""
144+ echo "Final sonar-project.properties content:"
145+ cat sonar-project.properties
112146
113147 - name : SonarCloud Scan
114148 uses : SonarSource/sonarqube-scan-action@v5
0 commit comments