Skip to content

Conversation

@OS-pedrogustavobilro
Copy link
Contributor

PR description

This PR updates the migrate.ts task to detect if the project's root build.gradle file has Kotlin defined (either via kotlin_version variable or set in the kotlin gradle plugin), and if so, update it to match the Kotlin version that Capacitor 8 uses (2.2.0).

Testing

Here's a few examples of the command running (it was run before to make the other Cap 8 changes, so you'll only see the kotlin version change in diff):

You can test yourself by checking this branch, and mapping the cli version to the local source code directory (make sure you run build in cli directory beforehand), then run npx cap migrate on the app.

If you want to run a second time in the same app, you'll need to manually change the version for cli every time, because the migrate command will change the versions of capacitor next. If you're running the migrate command a second time, you can avoid running npm install (replying n to the second question), to not override the cli version afterwards (core and android and ios should already be using next from running migrate the first time, so nothing should change).

Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

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

Would be good to check the existing value so we don't downgrade it if set to 2.2.21 or greater, like we do for other variables, i.e

if (gte(neededDeps[dep], existingVersion)) {

@OS-pedrogustavobilro
Copy link
Contributor Author

Would be good to check the existing value so we don't downgrade it if set to 2.2.21 or greater

@jcesarmobile Done in 43860fc. I extracted some logic to a separate method, basically to replace kotlin_version and/or (most likely just or, but in theory could be both) gradle plugin.

Let me know what you think

@OS-pedrogustavobilro OS-pedrogustavobilro merged commit b4b5532 into main Nov 14, 2025
6 checks passed
@OS-pedrogustavobilro OS-pedrogustavobilro deleted the chore/RMET-4539/migrate-kotlin-version-root branch November 14, 2025 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants