Skip to content

Fix: Add ProGuard rules for jsoup's optional RE2J dependency to fix release build #22521

Merged
crazytonyli merged 1 commit intorelease/26.5from
fix/release-build-fix
Jan 23, 2026
Merged

Fix: Add ProGuard rules for jsoup's optional RE2J dependency to fix release build #22521
crazytonyli merged 1 commit intorelease/26.5from
fix/release-build-fix

Conversation

@adalpari
Copy link
Contributor

Description

See the build issue: https://buildkite.com/automattic/wordpress-android/builds/24599

Fixes the beta release build failure caused by R8 detecting missing com.google.re2j classes referenced by jsoup's optional RE2J
regex support.

jsoup 1.22.1 added optional support for Google's RE2J regex engine for CSS selectors. Since RE2J is not included as a dependency in
this project, R8 fails the release build when it encounters references to the missing classes.

The fix adds -dontwarn rules to proguard.cfg to suppress these warnings, which is the standard approach for optional dependencies.

Why this won't break the app

RE2J is an optional dependency in jsoup. The library is designed to:

  • Detect at runtime whether RE2J is available on the classpath
  • Gracefully fall back to Java's built-in regex engine if RE2J is not present

The -dontwarn rules only tell R8 not to fail the build when it sees references to classes that might not exist at runtime. They
don't change any runtime behavior.

At runtime, jsoup checks if com.google.re2j classes are available. Since they're not included in the app, jsoup automatically uses
Java's standard java.util.regex engine instead - which is what the app was using before jsoup added RE2J support.

@dangermattic
Copy link
Collaborator

dangermattic commented Jan 23, 2026

1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

@sonarqubecloud
Copy link

@wpmobilebot
Copy link
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
FlavorJalapeno
Build TypeDebug
Versionpr22521-0732803
Commit0732803
Direct Downloadjetpack-prototype-build-pr22521-0732803.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
FlavorJalapeno
Build TypeDebug
Versionpr22521-0732803
Commit0732803
Direct Downloadwordpress-prototype-build-pr22521-0732803.apk
Note: Google Login is not supported on these builds.

@adalpari
Copy link
Contributor Author

@claude

@claude
Copy link
Contributor

claude bot commented Jan 23, 2026

Claude finished @adalpari's task in 1m 21s —— View job


Code Review

Progress

  • Read and analyze the ProGuard configuration changes
  • Review for correctness and best practices
  • Provide comprehensive feedback

Summary

The PR correctly addresses the R8 build failure by adding -dontwarn rules for jsoup's optional RE2J dependency. The implementation is clean, well-documented, and follows established patterns in the codebase.

✅ Strengths

  1. Correct Approach: Using -dontwarn for optional dependencies is the standard and recommended approach for ProGuard/R8 configuration.

  2. Proper Documentation: The inline comment clearly explains why these rules are needed (# jsoup has optional support for Google's RE2J regex library which is not included).

  3. Consistent Formatting: The change follows the existing convention used throughout proguard.cfg:

    • Section markers with ###### jsoup - begin and ###### jsoup - end
    • Clear, descriptive comments
    • Proper spacing
  4. Complete Coverage: Both RE2J classes that jsoup optionally uses are covered:

    • com.google.re2j.Matcher
    • com.google.re2j.Pattern
  5. Right Location: The rules are added to WordPress/proguard.cfg, which is correctly referenced in WordPress/build.gradle:278 for release builds.

  6. Safe at Runtime: As explained in the PR description, jsoup gracefully falls back to Java's standard regex when RE2J is not available, so these warnings can be safely suppressed.

📋 Observations

  1. Version Context: The codebase is using jsoup 1.22.1 (gradle/libs.versions.toml:84), which introduced optional RE2J support. This confirms the need for these rules.

  2. Scope: jsoup is used extensively across the codebase (15+ files), primarily for HTML parsing in posts, media processors, reader, and stats. The -dontwarn rules won't affect any of this functionality.

  3. Build Configuration: ProGuard rules are applied via build.gradle:278 using proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg', so this change will be included in release builds.

✅ Approval

This is a straightforward, correct fix for the build failure. The change:

  • ✅ Solves the immediate build problem
  • ✅ Uses the recommended approach for optional dependencies
  • ✅ Is well-documented and follows existing conventions
  • ✅ Has no impact on runtime behavior
  • ✅ No security concerns
  • ✅ No performance implications

Recommendation: Approve and merge.


@crazytonyli crazytonyli merged commit aa05311 into release/26.5 Jan 23, 2026
25 checks passed
@crazytonyli crazytonyli deleted the fix/release-build-fix branch January 23, 2026 08:51
crazytonyli added a commit that referenced this pull request Jan 23, 2026
* Bump version number

* Update draft release notes for 26.5

* Update draft release notes for Jetpack 26.5.

* Release Notes: add new section for next version (26.6)

* Add release notes

These are compiled based on git commits

* Merge strings from libraries for translation

* Freeze strings for translation

* Adding an ignore rule to the optional classes check (#22521)

---------

Co-authored-by: Tony Li <tony.li@automattic.com>
Co-authored-by: Adalberto Plaza <adalpari@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants