@@ -20,11 +20,13 @@ jobs:
2020 java-version : ${{ env.JAVA_VERSION }}
2121 - name : Set up Workspace Environment Variable
2222 run : echo "WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV
23- - name : Cache Maven dependencies
24- uses : actions/cache@v4
25- with :
26- path : /home/runner/.m2/repository
27- key : ${{ runner.os }}-maven-0-${{ hashFiles('**/pom.xml') }}
23+ - name : Cache Maven and p2 dependencies
24+ uses : actions/cache@v4
25+ with :
26+ path : |
27+ /home/runner/.m2/repository
28+ /home/runner/.p2
29+ key : ${{ runner.os }}-maven-0-${{ hashFiles('**/pom.xml') }}
2830 - name : Compile with Maven
2931 run : mvn clean compile -f ./ddk-parent/pom.xml --batch-mode -T3C
3032 - name : Upload compiled artifacts
@@ -108,11 +110,13 @@ jobs:
108110 java-version : ${{ env.JAVA_VERSION }}
109111 - name : Set up Workspace Environment Variable
110112 run : echo "WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV
111- - name : Cache Maven dependencies
112- uses : actions/cache@v4
113- with :
114- path : /home/runner/.m2/repository
115- key : ${{ runner.os }}-maven-0-${{ hashFiles('**/pom.xml') }}
113+ - name : Cache Maven and p2 dependencies
114+ uses : actions/cache@v4
115+ with :
116+ path : |
117+ /home/runner/.m2/repository
118+ /home/runner/.p2
119+ key : ${{ runner.os }}-maven-0-${{ hashFiles('**/pom.xml') }}
116120 - name : Run ${{ matrix.tool }}
117121 run : |
118122 case "${{ matrix.tool }}" in
@@ -140,18 +144,125 @@ jobs:
140144 java-version : ${{ env.JAVA_VERSION }}
141145 - name : Set up Workspace Environment Variable
142146 run : echo "WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV
143- - name : Cache Maven dependencies
144- uses : actions/cache@v4
145- with :
146- path : /home/runner/.m2/repository
147- key : ${{ runner.os }}-maven-0-${{ hashFiles('**/pom.xml') }}
147+ - name : Cache Maven and p2 dependencies
148+ uses : actions/cache@v4
149+ with :
150+ path : |
151+ /home/runner/.m2/repository
152+ /home/runner/.p2
153+ key : ${{ runner.os }}-maven-0-${{ hashFiles('**/pom.xml') }}
148154 - name : Download compiled artifacts
149155 uses : actions/download-artifact@v4
150156 with :
151157 name : compiled-classes
152158 path : .
153- - name : Run SpotBugs
154- run : mvn spotbugs:check -f ./ddk-parent/pom.xml --batch-mode -T2C
159+ - name : Run SpotBugs
160+ run : |
161+ set -eo pipefail
162+ mkdir -p target/spotbugs
163+
164+ # Collect all compiled class directories
165+ mapfile -t CLASS_DIRS < <(find . -type d -path '*/target/classes' -print | sort)
166+ if [ "${#CLASS_DIRS[@]}" -eq 0 ]; then
167+ echo "No class directories found. Did the compile artifacts download?"
168+ exit 1
169+ fi
170+
171+ # Build classpath from all class directories
172+ CLASS_CP=$(IFS=:; echo "${CLASS_DIRS[*]}")
173+
174+ # Add Tycho-resolved target platform bundles from the local Maven repo p2 cache
175+ P2_ROOT="$HOME/.m2/repository/p2"
176+ P2_CP=""
177+ if [ -d "$P2_ROOT" ]; then
178+ echo "Collecting p2 bundle jars from $P2_ROOT"
179+ mapfile -t P2_JARS < <(find "$P2_ROOT" -type f \( -path '*/plugins/*.jar' -o -path '*/bundles/*.jar' \) -print | sort -u)
180+ if [ "${#P2_JARS[@]}" -gt 0 ]; then
181+ P2_CP=$(IFS=:; echo "${P2_JARS[*]}")
182+ fi
183+ else
184+ echo "WARNING: p2 cache not found at $P2_ROOT; aux classpath may be incomplete"
185+ fi
186+
187+ # Also include Tycho cache location used by some setups
188+ TYCHO_CACHE_ROOT="$HOME/.m2/repository/.cache/tycho"
189+ TYCHO_CP=""
190+ if [ -d "$TYCHO_CACHE_ROOT" ]; then
191+ echo "Collecting Tycho cache bundle jars from $TYCHO_CACHE_ROOT"
192+ mapfile -t TYCHO_JARS < <(find "$TYCHO_CACHE_ROOT" -type f \( -path '*/plugins/*.jar' -o -path '*/bundles/*.jar' \) -print | sort -u)
193+ if [ "${#TYCHO_JARS[@]}" -gt 0 ]; then
194+ TYCHO_CP=$(IFS=:; echo "${TYCHO_JARS[*]}")
195+ fi
196+ fi
197+
198+ # Include Eclipse p2 shared pool used by Tycho on GitHub runners
199+ P2_POOL_ROOT="$HOME/.p2/pool"
200+ P2_POOL_CP=""
201+ if [ -d "$P2_POOL_ROOT" ]; then
202+ echo "Collecting p2 pool bundle jars from $P2_POOL_ROOT"
203+ mapfile -t P2_POOL_JARS < <(find "$P2_POOL_ROOT" -type f -path '*/plugins/*.jar' -print | sort -u)
204+ if [ "${#P2_POOL_JARS[@]}" -gt 0 ]; then
205+ P2_POOL_CP=$(IFS=:; echo "${P2_POOL_JARS[*]}")
206+ fi
207+ fi
208+
209+ # Combine to final AUX_CP
210+ AUX_CP="$CLASS_CP"
211+ if [ -n "$P2_CP" ]; then
212+ AUX_CP="$AUX_CP:$P2_CP"
213+ fi
214+ if [ -n "$TYCHO_CP" ]; then
215+ AUX_CP="$AUX_CP:$TYCHO_CP"
216+ fi
217+ if [ -n "$P2_POOL_CP" ]; then
218+ AUX_CP="$AUX_CP:$P2_POOL_CP"
219+ fi
220+
221+ # Fetch SpotBugs distribution ZIP (includes all dependencies)
222+ mvn -q dependency:copy \
223+ -Dartifact=com.github.spotbugs:spotbugs:4.9.6:zip \
224+ -DoutputDirectory=target/spotbugs
225+
226+ unzip -q -o target/spotbugs/spotbugs-4.9.6.zip -d target/spotbugs/dist
227+ SPOTBUGS_HOME=$(find target/spotbugs/dist -maxdepth 1 -type d -name 'spotbugs-*' | head -n1)
228+ echo "Using SpotBugs home: $SPOTBUGS_HOME"
229+
230+ # Run SpotBugs CLI via main class with full lib classpath
231+ set +e
232+ java -Xmx6g -cp "$SPOTBUGS_HOME/lib/*" edu.umd.cs.findbugs.LaunchAppropriateUI \
233+ -textui -effort:max -low -maxRank 15 -exitcode \
234+ -exclude ddk-configuration/findbugs/exclusion-filter.xml \
235+ -auxclasspath "$AUX_CP" \
236+ -xml:withMessages \
237+ -output target/spotbugs/spotbugs.xml \
238+ "${CLASS_DIRS[@]}" 2>&1 | tee target/spotbugs/spotbugs.log
239+ SPOTBUGS_RC=${PIPESTATUS[0]}
240+ set -e
241+
242+ # Optional: fail if any missing classes remain
243+ MISSING=0
244+ if grep -q "needed for analysis were missing" target/spotbugs/spotbugs.log; then
245+ echo "ERROR: SpotBugs reported missing classes. Aux classpath is incomplete."
246+ MISSING=1
247+ fi
248+
249+ # Preserve SpotBugs exit status but still report missing-classes
250+ if [ "$SPOTBUGS_RC" -ne 0 ]; then
251+ exit "$SPOTBUGS_RC"
252+ fi
253+ if [ "$MISSING" -ne 0 ]; then
254+ exit 2
255+ fi
256+
257+ - name : Upload SpotBugs report
258+ if : always()
259+ uses : actions/upload-artifact@v4
260+ with :
261+ name : spotbugs-report
262+ path : |
263+ target/spotbugs/spotbugs.xml
264+ target/spotbugs/spotbugs.log
265+ retention-days : 7
155266
156267 integration-tests :
157268 needs : compile
@@ -169,11 +280,13 @@ jobs:
169280 java-version : ${{ env.JAVA_VERSION }}
170281 - name : Set up Workspace Environment Variable
171282 run : echo "WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV
172- - name : Cache Maven dependencies
173- uses : actions/cache@v4
174- with :
175- path : /home/runner/.m2/repository
176- key : ${{ runner.os }}-maven-0-${{ hashFiles('**/pom.xml') }}
283+ - name : Cache Maven and p2 dependencies
284+ uses : actions/cache@v4
285+ with :
286+ path : |
287+ /home/runner/.m2/repository
288+ /home/runner/.p2
289+ key : ${{ runner.os }}-maven-0-${{ hashFiles('**/pom.xml') }}
177290 - name : Download compiled artifacts
178291 uses : actions/download-artifact@v4
179292 with :
0 commit comments