fix: remove AGP 9 property shims and jcenter() - #31
Conversation
OS-pedrogustavobilro
left a comment
There was a problem hiding this comment.
Overall LGTM. Dropping some remarks of things I noticed, not related to your PR (therefore not aiming for them to be changed here)
| } | ||
|
|
||
| function updateKotlinOptions(gradleFile: string): string { | ||
| const kotlinOptionsRegex = /kotlinOptions\s*\{\s*jvmTarget\s*=\s*['"](\d+\.?\d*)['"][\s\S]*?\}/; |
There was a problem hiding this comment.
Not related to your changes, but wanted to drop a mention to some stuff I noticed when running the command against a few community capacitor plugins. Nothing to change in this PR imo, but possible future work.
1- kotlinOptions
Noticed the kotlinOptions wasn't removed for admob, which causes the build to fail (I think in AGP 8 it was only a warning?):
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not find method kotlinOptions() for arguments [build_1mt6yqirm3mi9g4q4hglnxi3x$_run_closure2$_closure10@51094f08] on object of type com.android.build.gradle.internal.dsl.LibraryExtensionImpl$AgpDecorated.
Per https://github.com/search?q=org%3Acapacitor-community+kotlinOptions+%7B&type=code there's stripe plugin with this configuration. Those plugins should be using a string '' to assign the jvmTarget, but are incorrectly using the enum. While it's an issue in the plugins, perhaps the plugin migrator should cover that scenario as well?
2 - JUnit
After fixing the kotlinOptions, the android build fails with another error related to JUnit (this error doesn't happen pre-migration, so might be something Gradle 9 or AGP 9 related). This isn't covered by the migrator script or any existing documentation, and I've never gotten this error before, unsure if it's because that plugin seems to be using JUnit 5 which Android seem to never have been fully on board of - but maybe it's worth looking into this more in the future.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':testDebugUnitTest' (registered by plugin 'com.android.internal.library').
> Test process encountered an unexpected problem.
> Could not start Gradle Test Executor 2.
> Failed to load JUnit Platform. Please ensure that all JUnit Platform dependencies are available on the test's runtime classpath, including the JUnit Platform launcher.
| filename: string, | ||
| variablesAndClasspaths: { | ||
| variables: any; | ||
| 'com.android.tools.build:gradle': string; |
There was a problem hiding this comment.
Again, not related to any changes here, this already happens today.
I saw a community plugin https://github.com/capacitor-community/bluetooth-le/blob/main/android/build.gradle#L19 that has a different declaration for AGP, and the plugin migrator does not replace it, which causes the build to fail.
Wonder if it's worth considering these kinds of cases in the plugin migrator? (not for this PR specifically, but for future work)
|
can you create a few JIRA tickets for those so we don't forget about them? |
the
gradle.propertiesremoval of properties is basically a copy of ionic-team/capacitor#8584 changesfor
jcenter()removal I simplified it since I don't think we should be addingmavenCentral()also removes the whole
block instead of just
apply plugin: 'kotlin-android', if present