@@ -231,9 +231,15 @@ case ${JOB_TYPE} in
231231 dir=$( dirname " ${dir} " )
232232 done
233233 if [ -f " ${dir} /pom.xml" ] && [ " ${dir} " != " ." ]; then
234- # Exclude sample modules as they are not in the default reactor
235- if [[ " ${dir} " != * " samples" * ]]; then
236- echo " Processed file: ${changed_file} -> resolved module: ${dir} "
234+ # Filter out samples, directories with no Java source code, and generated protobuf/gRPC code
235+ if [[ " ${dir} " != * " samples" * ]] && \
236+ [[ " ${dir} " != * " tutorials" * ]] && \
237+ [[ " $( basename " ${dir} " ) " != " proto-google-" * ]] && \
238+ [[ " $( basename " ${dir} " ) " != " grpc-google-" * ]] && \
239+ [[ " $( basename " ${dir} " ) " != * " -bom" ]] && \
240+ [[ " $( basename " ${dir} " ) " != " google-cloud-pom-parent" ]] && \
241+ [[ " $( basename " ${dir} " ) " != " google-cloud-jar-parent" ]]; then
242+
237243 changed_modules+=(" ${dir} " )
238244 fi
239245 fi
@@ -250,32 +256,8 @@ case ${JOB_TYPE} in
250256 echo " Formatting only changed modules: ${unique_modules} "
251257 fi
252258 else
253- echo " BASE_SHA or HEAD_SHA is empty. Skipping file difference check."
254-
255- # Build a list of exclusions to skip formatting generated code.
256- exclusions=" "
257-
258- # Find and exclude generated sub-modules and parent/aggregator POMs:
259- # - proto-google-*, grpc-google-* : Generated protobuf/gRPC code should not be formatted manually.
260- # - *-bom : Bill of Materials modules that contain no valid source code anyway.
261- # - java-* at depth 1 : Top-level aggregator parent POMs for each library module wrapper.
262- # - google-cloud-pom-parent, google-cloud-jar-parent, gapic-libraries-bom : Repo-level parent modules.
263- # The syntax for excluding in Maven requires a "!" prefix before the path in the `-pl` argument.
264- for dir in $( find . -maxdepth 1 -type d -name " java-*" | sort; \
265- find . -maxdepth 2 -type d \( -name " proto-google-*" -o -name " grpc-google-*" -o -name " *-bom" -o -name " google-cloud-pom-parent" -o -name " google-cloud-jar-parent" \) | sort) ; do
266- # Strip leading ./
267- dir=" ${dir# ./ } "
268- if [ -n " ${exclusions} " ]; then
269- exclusions=" ${exclusions} ,!${dir} "
270- else
271- exclusions=" !${dir} "
272- fi
273- done
274-
275- if [ -n " ${exclusions} " ]; then
276- MODULE_FILTER=" -pl ${exclusions} "
277- echo " Excluding generated modules from formatting"
278- fi
259+ echo " BASE_SHA or HEAD_SHA is empty. Cannot continue linting."
260+ exit 1
279261 fi
280262
281263 mvn -B -ntp \
0 commit comments