refactor: Move Realm models to an included build#2930
Conversation
There was a problem hiding this comment.
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
OldKotlincomposite 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-modelsas 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.
| 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) | ||
| } |
There was a problem hiding this comment.
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.
|
This PR/issue depends on:
|
9e051ae to
ac8c080
Compare
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.
0b0aa00 to
2206e2e
Compare
|



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