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

[#513] [KMM Support] Migrate to Gradle 8 #508

Merged
merged 12 commits into from
Oct 2, 2023

Conversation

luongvo
Copy link
Member

@luongvo luongvo commented Aug 22, 2023

Closes #513

What happened 👀

Insight 📝

  • All build plugin versions are defined from the root build.gradle.
  • There are a new pluginManagement and dependencyResolutionManagement blocks from the root settings.gradle.
  • Skip android.enableJetifier=true flag, as most dependencies are now written for AndroidX.
  • Gradle 8 does not generate the BuildConfig class anymore 👉 temporarily enables to optimize in a separate class.
  • There are some new issues when switching to compile with JDK 17 (which has been listing here https://qiita.com/Nabe1216/items/05c9981fd12eb2fa1df0):
    • R8: Missing class java.lang.invoke.StringConcatFactory
      ERROR: R8: Missing class java.lang.invoke.StringConcatFactory (referenced from: java.lang.String co.nimblehq.template.compose.data.response.ErrorResponse.toString() and 1 other context)
      
      👉 To solve this, we can suppress this warning by adding a proguard rule -dontwarn java.lang.invoke.StringConcatFactory in the data module ✅
    • R8: Missing classes from org.bouncycastle, org.conscrypt and org.openjsse
      ERROR: R8: Missing class org.bouncycastle.jsse.BCSSLParameters (referenced from: void okhttp3.internal.platform.BouncyCastlePlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List) and 1 other context)
      Missing class org.bouncycastle.jsse.BCSSLSocket (referenced from: void okhttp3.internal.platform.BouncyCastlePlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List) and 5 other contexts)
      Missing class org.bouncycastle.jsse.provider.BouncyCastleJsseProvider (referenced from: void okhttp3.internal.platform.BouncyCastlePlatform.<init>())
      Missing class org.conscrypt.Conscrypt$Version (referenced from: boolean okhttp3.internal.platform.ConscryptPlatform$Companion.atLeastVersion(int, int, int))
      Missing class org.conscrypt.Conscrypt (referenced from: boolean okhttp3.internal.platform.ConscryptPlatform$Companion.atLeastVersion(int, int, int) and 4 other contexts)
      Missing class org.conscrypt.ConscryptHostnameVerifier (referenced from: okhttp3.internal.platform.ConscryptPlatform$DisabledHostnameVerifier)
      Missing class org.openjsse.javax.net.ssl.SSLParameters (referenced from: void okhttp3.internal.platform.OpenJSSEPlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List))
      Missing class org.openjsse.javax.net.ssl.SSLSocket (referenced from: void okhttp3.internal.platform.OpenJSSEPlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List) and 1 other context)
      Missing class org.openjsse.net.ssl.OpenJSSE (referenced from: void okhttp3.internal.platform.OpenJSSEPlatform.<init>())
      
      👉 To solve this, adding these proguard rules in the app module
      -dontwarn okhttp3.internal.platform.**
      -dontwarn org.conscrypt.**
      -dontwarn org.bouncycastle.**
      -dontwarn org.openjsse.**
      
      Or upgrade OkHttp to version 4.11.0 to get the default added proguard rules from the dependency

Proof Of Work 📹

The app works properly after migrating: both debug and release builds.

image

References

@luongvo luongvo self-assigned this Aug 22, 2023
@luongvo luongvo temporarily deployed to template-compose August 22, 2023 10:54 — with GitHub Actions Inactive
@github-actions
Copy link

github-actions bot commented Aug 22, 2023

1 Warning
⚠️ Uh oh! Your project is under 80% coverage!

Kover report for template-xml:

🧛 Template - XML Unit Tests Code Coverage: 34.25%

Coverage of Modified Files:

File Coverage

Modified Files Not Found In Coverage Report:

AndroidManifest.xml
AndroidManifest.xml
AndroidManifest.xml
Plugins.kt
Versions.kt
backup_rules.xml
build.gradle.kts
build.gradle.kts
build.gradle.kts
build.gradle.kts
consumer-rules.pro
data_extraction_rules.xml
deploy_staging_and_production_to_firebase_app_distribution.yml
gradle-wrapper.jar
gradle-wrapper.properties
gradle.properties
gradlew.bat
ic_launcher.webp
ic_launcher.webp
ic_launcher.webp
ic_launcher.webp
ic_launcher.webp
ic_launcher.xml
ic_launcher_background.xml
ic_launcher_foreground.xml
ic_launcher_round.webp
ic_launcher_round.webp
ic_launcher_round.webp
ic_launcher_round.webp
ic_launcher_round.webp
ic_launcher_round.xml
new_project.kts
proguard-rules.pro
review_pull_request.yml
review_pull_request.yml
run_detekt_and_unit_tests.yml
run_detekt_and_unit_tests.yml
settings.gradle.kts
themes.xml
verify_newproject_script.yml

Codebase cunningly covered by count Shroud 🧛

Kover report for template-compose:

🧛 Template - Compose Unit Tests Code Coverage: 62.05%

Coverage of Modified Files:

File Coverage

Modified Files Not Found In Coverage Report:

AndroidManifest.xml
AndroidManifest.xml
AndroidManifest.xml
Plugins.kt
Versions.kt
backup_rules.xml
build.gradle.kts
build.gradle.kts
build.gradle.kts
build.gradle.kts
consumer-rules.pro
data_extraction_rules.xml
deploy_staging_and_production_to_firebase_app_distribution.yml
gradle-wrapper.jar
gradle-wrapper.properties
gradle.properties
gradlew.bat
ic_launcher.webp
ic_launcher.webp
ic_launcher.webp
ic_launcher.webp
ic_launcher.webp
ic_launcher.xml
ic_launcher_background.xml
ic_launcher_foreground.xml
ic_launcher_round.webp
ic_launcher_round.webp
ic_launcher_round.webp
ic_launcher_round.webp
ic_launcher_round.webp
ic_launcher_round.xml
new_project.kts
proguard-rules.pro
review_pull_request.yml
review_pull_request.yml
run_detekt_and_unit_tests.yml
run_detekt_and_unit_tests.yml
settings.gradle.kts
themes.xml
verify_newproject_script.yml

Codebase cunningly covered by count Shroud 🧛

Generated by 🚫 Danger

@luongvo luongvo temporarily deployed to template-compose August 22, 2023 11:15 — with GitHub Actions Inactive
@luongvo luongvo temporarily deployed to template-compose August 23, 2023 04:14 — with GitHub Actions Inactive
@luongvo luongvo temporarily deployed to template-compose August 23, 2023 04:15 — with GitHub Actions Inactive
@luongvo luongvo temporarily deployed to template-compose August 23, 2023 07:28 — with GitHub Actions Inactive
@luongvo luongvo temporarily deployed to template-compose August 23, 2023 07:32 — with GitHub Actions Inactive
@luongvo luongvo temporarily deployed to template-compose August 23, 2023 08:34 — with GitHub Actions Inactive
@luongvo luongvo temporarily deployed to template-compose August 23, 2023 08:34 — with GitHub Actions Inactive
@@ -2,4 +2,5 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">

Choose a reason for hiding this comment

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

⚠️ The application adaptive icon is missing a monochrome tag

Copy link
Contributor

Choose a reason for hiding this comment

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

False-negative warning? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

@lydiasama monochrome is a new feature of Adaptive Icon from API 33. It's default generated from the new project by AS as that is to prepare for the support 🤷‍♂️

@luongvo luongvo temporarily deployed to template-compose August 23, 2023 08:55 — with GitHub Actions Inactive
@luongvo luongvo temporarily deployed to template-compose August 23, 2023 09:13 — with GitHub Actions Inactive
@luongvo luongvo temporarily deployed to template-compose August 23, 2023 09:13 — with GitHub Actions Inactive
@luongvo luongvo force-pushed the feature/kmm-support-upgrade-to-gradle-8 branch from 5c675b7 to d1a6dd2 Compare August 25, 2023 03:57
@luongvo luongvo temporarily deployed to template-compose August 25, 2023 03:58 — with GitHub Actions Inactive
@luongvo luongvo temporarily deployed to template-compose August 29, 2023 15:21 — with GitHub Actions Inactive
@luongvo luongvo changed the title [KMM Support] Migrate to Gradle 8 [#513] [KMM Support] Migrate to Gradle 8 Aug 31, 2023
@luongvo luongvo temporarily deployed to template-compose August 31, 2023 04:49 — with GitHub Actions Inactive
@luongvo luongvo temporarily deployed to template-compose August 31, 2023 04:49 — with GitHub Actions Inactive
@luongvo luongvo linked an issue Aug 31, 2023 that may be closed by this pull request
@luongvo luongvo added this to the 3.24.0 milestone Aug 31, 2023
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove the Cache gems step and set the bundler-cache: true at Set up Ruby step like we did in KMM Templates?

Copy link
Member Author

Choose a reason for hiding this comment

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

@lydiasama Yes, but it's out of this PR's scope. I recommend revising this workflow from this task instead #519.

template-compose/app/build.gradle.kts Show resolved Hide resolved
buildTypes {
getByName(BuildTypes.RELEASE) {
release {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to update this? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

@lydiasama release { is a new supported block from Gradle 8's DSL. We should use any built-in features instead of manual configurations 🤓

android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
tools:targetApi="31">
Copy link
Contributor

Choose a reason for hiding this comment

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

May I know the purpose of this tools:targetApi="31"? 🙏🏻

Copy link
Member Author

Choose a reason for hiding this comment

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

@lydiasama To bypass this warning, it explains the dataExtractionRules attr is used on API 31 only and will be ignored on lower APIs. The tools:targetApi="31" is default generated for the new project by AS with Gradle 8.

image

.github/workflows/review_pull_request.yml Outdated Show resolved Hide resolved
.github/workflows/run_detekt_and_unit_tests.yml Outdated Show resolved Hide resolved
.github/workflows/run_detekt_and_unit_tests.yml Outdated Show resolved Hide resolved
.github/workflows/verify_newproject_script.yml Outdated Show resolved Hide resolved
@luongvo luongvo temporarily deployed to template-compose September 18, 2023 11:05 — with GitHub Actions Inactive
@ryan-conway ryan-conway temporarily deployed to template-compose September 22, 2023 03:07 — with GitHub Actions Inactive
@luongvo luongvo force-pushed the feature/kmm-support-upgrade-to-gradle-8 branch from 3b98ce2 to 799ed77 Compare September 22, 2023 03:55
@luongvo luongvo temporarily deployed to template-compose September 22, 2023 03:55 — with GitHub Actions Inactive
Copy link
Contributor

@manh-t manh-t left a comment

Choose a reason for hiding this comment

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

Good work 👏

template-compose/buildSrc/src/main/java/Versions.kt Outdated Show resolved Hide resolved
Copy link

@doannimble doannimble left a comment

Choose a reason for hiding this comment

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

The rest lgtm

.github/workflows/review_pull_request.yml Show resolved Hide resolved
@luongvo luongvo temporarily deployed to template-compose October 2, 2023 04:25 — with GitHub Actions Inactive
@luongvo luongvo requested review from doannimble and manh-t October 2, 2023 04:27
Copy link

@doannimble doannimble left a comment

Choose a reason for hiding this comment

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

lgtm now 🚀

@luongvo luongvo temporarily deployed to template-compose October 2, 2023 04:30 — with GitHub Actions Inactive
Base automatically changed from feature/kmm-support-dependencies to develop October 2, 2023 05:08
@ryan-conway ryan-conway temporarily deployed to template-compose October 2, 2023 05:08 — with GitHub Actions Inactive
@ryan-conway ryan-conway merged commit 72a7df8 into develop Oct 2, 2023
4 checks passed
@ryan-conway ryan-conway deleted the feature/kmm-support-upgrade-to-gradle-8 branch October 2, 2023 05:35
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.

Upgrade to Gradle 8 and JDK 17
7 participants