Skip to content

refactor: Move Realm models to an included build#2930

Open
LouisCAD wants to merge 13 commits into
mainfrom
move-realm-models-to-included-build
Open

refactor: Move Realm models to an included build#2930
LouisCAD wants to merge 13 commits into
mainfrom
move-realm-models-to-included-build

Conversation

@LouisCAD
Copy link
Copy Markdown
Contributor

@LouisCAD LouisCAD commented Jun 3, 2026

This allows using a newer Kotlin version in the project, while having Realm models compiled with an older
Kotlin compiler, so it works with the no-longer
maintained compiler plugin.

Depends on Infomaniak/android-core#788

Copilot AI review requested due to automatic review settings June 3, 2026 12:38
@LouisCAD LouisCAD requested a review from sirambd June 3, 2026 12:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR restructures the project so Realm-related models can be built in a separate included build (OldKotlin) with a Kotlin compiler compatible with the legacy Realm compiler plugin, while the main app can move forward to a newer Kotlin toolchain.

Changes:

  • Adds an OldKotlin composite build and moves Realm/emoji-reaction model sources into it (with their own Gradle setup/version catalog).
  • Refactors the app to consume realm-models / emoji-reaction-models as dependencies and shifts previously in-model logic into extension functions in the app module.
  • Updates build configuration (repositories, JVM target configuration) and adjusts imports/usages across the app to the new model types/locations.

Reviewed changes

Copilot reviewed 176 out of 183 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
settings.gradle.kts Adds mavenLocal() + includes the OldKotlin composite build.
OldKotlin/settings.gradle.kts New settings for the included build (plugin + dependency resolution).
OldKotlin/build.gradle.kts Declares shared plugins for the included build.
OldKotlin/gradle/libs.versions.toml Defines toolchain + dependencies used by OldKotlin modules.
OldKotlin/gradle.properties New Gradle properties for the included build.
OldKotlin/realm-models/build.gradle.kts New Android library module producing realm-models.
OldKotlin/emoji-reaction-models/build.gradle.kts New Android library module producing emoji-reaction-models.
OldKotlin/emoji-reaction-models/src/main/kotlin/com/infomaniak/emojicomponents/data/Reaction.kt Copyright/header update.
gradle/libs.versions.toml Adds versions + new published module coordinates for old-Kotlin artifacts.
build.gradle.kts Removes root Realm plugin alias application.
app/build.gradle.kts Stops using direct Realm base dependency and switches to libs.realm.models.
HtmlCleaner/build.gradle.kts Migrates JVM target config to kotlin.compilerOptions.
EmojiComponents/build.gradle.kts Migrates JVM target config; adds API dep on emoji reaction models.
app/src/main/java/com/infomaniak/mail/data/api/ApiRoutes.kt Route utility edits (includes a new stray suspend test method).
app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt Flow error handling changed for folder flows.
app/src/main/java/com/infomaniak/mail/data/models/extensions/ThreadExtensions.kt New Thread extension helpers moved out of model.
app/src/main/java/com/infomaniak/mail/data/models/extensions/MessageExtensions.kt New Message extension helpers moved out of model.
app/src/main/java/com/infomaniak/mail/data/models/extensions/CorrespondentExtensions.kt New Correspondent extension helpers (initials/me checks/etc.).
app/src/main/java/com/infomaniak/mail/data/models/thread/Thread.kt Removes old Thread model from app module.
OldKotlin/realm-models/src/main/kotlin/com/infomaniak/mail/data/models/Thread.kt New Thread Realm model in included build.
app/src/main/java/com/infomaniak/mail/data/models/message/EmojiReactionNotAllowedReason.kt Removes old enum from app module.
OldKotlin/realm-models/src/main/kotlin/com/infomaniak/mail/data/models/message/EmojiReactionNotAllowedReason.kt Reintroduces enum in included build using MailApiEnum.
OldKotlin/realm-models/src/main/kotlin/com/infomaniak/mail/data/models/message/SplitBody.kt Moves SplitBody to model module (but has a null-crashing hashCode).
app/src/main/java/com/infomaniak/mail/utils/MessageBodyUtils.kt Removes nested SplitBody in favor of model-module type.
app/src/main/java/com/infomaniak/mail/ui/main/thread/ThreadState.kt Updates SplitBody import.
app/src/main/res/navigation/main_navigation.xml Updates nav arg type for AttachmentType.
app/src/main/res/navigation/new_message_navigation.xml Updates nav arg type for AttachmentType.
app/src/main/java/com/infomaniak/mail/data/models/Attachable.kt Removes old Attachable interface from app module.
OldKotlin/realm-models/src/main/kotlin/com/infomaniak/mail/data/models/Attachable.kt New slim Attachable interface in included build.
app/src/main/java/com/infomaniak/mail/data/models/AttachmentType.kt New top-level AttachmentType enum in app module.
OldKotlin/realm-models/src/main/kotlin/com/infomaniak/mail/utils/extensions/RealmInstantConversion.kt Moves RealmInstant/Date conversion helpers (currently incorrect units).
OldKotlin/realm-models/src/main/kotlin/com/infomaniak/mail/data/api/UnwrappingJsonListSerializer.kt New serializer for inReplyTo (empty-array handling currently unsafe).
OldKotlin/realm-models/src/main/kotlin/com/infomaniak/core/common/utils/MailApiEnum.kt New enum mapping delegate helpers (typo in function name).
app/src/test/java/com/infomaniak/mail/workers/MailActionsManagerTest.kt Updates DraftAction import + moves helper usages to extensions.
app/src/test/java/com/infomaniak/mail/FolderRoleUtilsTest.kt Updates FolderRole import.
app/src/test/java/com/infomaniak/mail/CalendarEventResponseTest.kt Updates AttendanceState import path.
(Multiple app src files) Broad import refactors to new model locations + new extension-based APIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread settings.gradle.kts
Comment thread settings.gradle.kts
Comment on lines +23 to +29
fun RealmInstant.toDate(): Date = Date(epochSeconds * 1_000L + nanosecondsOfSecond / 1_000L)

fun Date.toRealmInstant(): RealmInstant {
val seconds = time / 1_000L
val nanoseconds = (time - seconds * 1_000L).toInt()
return RealmInstant.from(seconds, nanoseconds)
}
Copy link
Copy Markdown
Contributor Author

@LouisCAD LouisCAD Jun 3, 2026

Choose a reason for hiding this comment

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

Good catch. Predates this PR, it's only in the diff because of code moving. It should have no repercussion on the user since we never show milliseconds granularity to the user, and it's only used for the UI. Will fix this in a subsequent PR.

Comment thread app/src/main/java/com/infomaniak/mail/data/api/ApiRoutes.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt
Comment thread app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 175 out of 182 changed files in this pull request and generated 3 comments.

Comment thread gradle/libs.versions.toml Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

This PR/issue depends on:

@LouisCAD LouisCAD force-pushed the move-realm-models-to-included-build branch from 9e051ae to ac8c080 Compare June 4, 2026 10:30
@LouisCAD LouisCAD force-pushed the move-realm-models-to-included-build branch from 0b0aa00 to 2206e2e Compare June 4, 2026 15:31
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 4, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependent This MR depends on another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants