Skip to content

Commit 6d55874

Browse files
gnodetclaude
andcommitted
chore: conditionally enable OpenRewrite FQCN shortening in CI
Instead of always running OpenRewrite (which quadruples build time), detect FQCNs in the diff and only enable -Prewrite when needed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 041bd06 commit 6d55874

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

etc/scripts/regen.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,34 @@ set -e
2121
# Move to top directory
2222
cd `dirname "$0"`/../..
2323

24+
# Conditionally enable OpenRewrite FQCN shortening only when needed
25+
DIFF_BASE=""
26+
if [ -n "$GITHUB_BASE_REF" ]; then
27+
git fetch origin "$GITHUB_BASE_REF" --depth=1 --quiet 2>/dev/null || true
28+
DIFF_BASE="origin/$GITHUB_BASE_REF"
29+
elif git rev-parse HEAD~1 >/dev/null 2>&1; then
30+
DIFF_BASE="HEAD~1"
31+
else
32+
git fetch --deepen=1 --quiet 2>/dev/null || true
33+
if git rev-parse HEAD~1 >/dev/null 2>&1; then
34+
DIFF_BASE="HEAD~1"
35+
fi
36+
fi
37+
38+
if [ -n "$DIFF_BASE" ] && \
39+
git diff "$DIFF_BASE"...HEAD -- '*.java' ':!*/src/generated/*' \
40+
| grep '^+[^+]' \
41+
| grep -v '^+ *import ' \
42+
| grep -v '^+ *package ' \
43+
| grep -v '^+ *//' \
44+
| grep -v '^+ *\*' \
45+
| grep -qE '[a-z][a-z0-9]*(\.[a-z][a-z0-9]*)+\.[A-Z]'; then
46+
MAVEN_EXTRA_ARGS="${MAVEN_EXTRA_ARGS} -Prewrite"
47+
echo "FQCNs detected in diff, enabling OpenRewrite (-Prewrite)"
48+
else
49+
echo "No FQCNs detected in diff, skipping OpenRewrite"
50+
fi
51+
2452
# Force clean
2553
git clean -fdx
2654
rm -Rf **/src/generated/

0 commit comments

Comments
 (0)