Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Deps] Update Kotlin to 2.0.21 #12896

Open
wants to merge 14 commits into
base: trunk
Choose a base branch
from
Open

Conversation

ParaskP7
Copy link
Contributor

@ParaskP7 ParaskP7 commented Nov 8, 2024

Project Thread: paaHJt-7n2-p2
Associated Metrics: paaHJt-7n2-p2#comment-9682

This PR updates Kotlin to 2.0 (2.0.21).

Description

FYI: I recommend reviewing this PR commit-by-commit just to make sure that Kotlin has been updated appropriately and that there isn't any left-overs that need addressing.

PS: Main commits for some extra focus:

Testing information

  • Smoke test the app and verify everything is working as expected.
  • Try to test for build time increases both, locally and on CI.
  • You could also run the ./gradlew buildHealth task locally and verify that everything is working as expected (CI).
  • Review the project dependencies & build environment changes (via CI artifacts and assert correctness. (*)

(*) Unfortunately, this comment exceeds 65400 characters and thus the only way for us to check on the diff is to do it via the CI artifacts. You could focus on:

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on big (tablet) and small (phone) in case of UI changes, and no regressions are added.

FYI: This kotlinOptions/jvmTarget configuration is already available on
the root level 'build.gradle' file, which applies that automatically to
all modules.
Although this change is not required, it is high time it is done in
order to update the Java target and compatibility across the project and
thus be prepared for any future updates.

------------------------------------------------------------------------

FYI: For example, on JP/WPAndroid this change was actually necessary
because otherwise updating to Kotlin 2.0 was failing the build with the
below:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':libs:processors:compileKotlin'.
> Could not resolve all files for configuration
   ':libs:processors:compileClasspath'.
   > Could not resolve com.google.devtools.ksp:symbol-processing-api:
      2.0.21-1.0.26.
     Required by:
         project :libs:processors
      > Dependency resolution is looking for a library compatible with
       JVM runtime version 8, but 'com.google.devtools.ksp:
       symbol-processing-api:2.0.21-1.0.26' is only compatible with JVM
       runtime version 11 or newer.

PR Commit: https://github.com/wordpress-mobile/WordPress-Android/pull/
21428/commits/6abe01ec983d0765d4bd1466030097109867ac56
With this change, changing the 'java' version value within the
'libs.versions.toml' next time, will be all it takes to update JVM to
point to '17' or beyond.
Starting in Kotlin 2.0, the Compose Compiler Gradle plugin is required
when compose is enabled. This change addresses that, along with removing
the outdated 'androidx-compose-compiler' configuration.

------------------------------------------------------------------------
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':WooCommerce'.
> com.android.builder.errors.EvalIssueException: Starting in Kotlin 2.0,
 the Compose Compiler Gradle plugin is required
  when compose is enabled. See the following link for more information:
  https://d.android.com/r/studio-ui/compose-compiler
Warning Messages: "This declaration overrides a deprecated member but is
not marked as deprecated itself. Please add the '@deprecated' annotation
or suppress the diagnostic."
Warning Messages: "Inline property cannot have a backing field.
This will become an error in Kotlin 2.1."

FYI: For both, the 'ProductListAdapter' and 'AttributeBaseAdapter'
classes, this 'inline' keyword got added to 'clickListener' and
'onItemClick' correspondingly, but for no good reason other than
fixing an unknown Lint error, and then, probably due to copy-pasting.

For more info refer to commits below:
- 499904a
- 16fb4f5
Warning Messages: "Non-public primary constructor is exposed via the
generated 'copy()' method of the 'data' class."

FYI: There is no good reason for this constructor to be 'private',
that is, instead of it being the default 'public'.
------------------------------------------------------------------------

UpdateAnalyticsHubStatsTest > when syncing stats data starts with
 forceUpdate false, then follow data store response FAILED
    kotlin.NoWhenBranchMatchedException at
     UpdateAnalyticsHubStatsTest.kt:478

UpdateAnalyticsHubStatsTest > when data store allows new stats fetch,
 then request data with ForceNew strategy FAILED
    kotlin.NoWhenBranchMatchedException at
     UpdateAnalyticsHubStatsTest.kt:385

UpdateAnalyticsHubStatsTest > when syncing stats data stats with Stored
 strategy, then do not store the timestamp FAILED
    kotlin.NoWhenBranchMatchedException at
     UpdateAnalyticsHubStatsTest.kt:526

UpdateAnalyticsHubStatsTest > when syncing stats data starts with
 forceUpdate true, then trigger update with ForceNew Strategy FAILED
    kotlin.NoWhenBranchMatchedException at
     UpdateAnalyticsHubStatsTest.kt:453

UpdateAnalyticsHubStatsTest > when selection type is CUSTOM, then follow
 the data store and request data with Stored strategy FAILED
    kotlin.NoWhenBranchMatchedException at
     UpdateAnalyticsHubStatsTest.kt:425

UpdateAnalyticsHubStatsTest > when data store does NOT allows net stats
 fetch, then request data with Saved strategy FAILED
    kotlin.NoWhenBranchMatchedException at
     UpdateAnalyticsHubStatsTest.kt:397
This is done in order to avoid having the generated during build time
Kotlin session files being seen by Git.
@ParaskP7 ParaskP7 added this to the 21.2 milestone Nov 8, 2024
@ParaskP7 ParaskP7 changed the title [Deps] Update Kotlin to 2.0.21 #21428 [Deps] Update Kotlin to 2.0.21 Nov 8, 2024
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 8, 2024

Build environment changes

Content exceeds 65400 characters. Navigate to Buildkite build artifacts to see details.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 8, 2024

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commita65218c
Direct Downloadwoocommerce-wear-prototype-build-pr12896-a65218c.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 8, 2024

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commita65218c
Direct Downloadwoocommerce-prototype-build-pr12896-a65218c.apk

@codecov-commenter
Copy link

codecov-commenter commented Nov 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 39.61%. Comparing base (3444338) to head (a65218c).

Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #12896      +/-   ##
============================================
- Coverage     40.17%   39.61%   -0.57%     
- Complexity     5798     5918     +120     
============================================
  Files          1258     1258              
  Lines         71547    72739    +1192     
  Branches       9979     9950      -29     
============================================
+ Hits          28747    28813      +66     
- Misses        40161    41362    +1201     
+ Partials       2639     2564      -75     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ParaskP7 ParaskP7 marked this pull request as ready for review November 11, 2024 13:49
Copy link
Contributor

@wzieba wzieba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving some suggestions. Is there any place to review build performance changes for this update?

@ParaskP7
Copy link
Contributor Author

👋 @wzieba !

Is there any place to review build performance changes for this update?

Don't you mean this: Associated Metrics: paaHJt-7n2-p2#comment-9682 (see PR description, on top) 🤔

Or, do you have something else in mind? 🤔

@wzieba
Copy link
Contributor

wzieba commented Nov 12, 2024

Don't you mean this: Associated Metrics: paaHJt-7n2-p2#comment-9682 (see PR description, on top) 🤔

Yes, thanks!

This way both the non-public primary constructor being exposed via the
generated 'copy()' method of the 'data' class warning, as well as the
'DataClassPrivateConstructor' warning are solved, but at the same time
the signature and functionality of the 'ReviewModerationRequest' data
class remains unchanged.

PR Comment: https://github.com/woocommerce/woocommerce-android/pull/
12896#discussion_r1837889124
Copy link
Contributor

@wzieba wzieba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for considering and applying improvements! All LGTM 👍

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