Skip to content

Commit

Permalink
Switch to using JS-IR compiler only. Rename door-annotations to room-…
Browse files Browse the repository at this point in the history
…annotations to make it clear what the module provides.
  • Loading branch information
mikedawson committed Mar 28, 2023
1 parent 7741357 commit 516cc69
Show file tree
Hide file tree
Showing 29 changed files with 45 additions and 12 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ kotlin {
dependencies {
//Add Door itself
implementation "com.github.UstadMobile.door:door-runtime:$version_door"
compileOnly "com.github.UstadMobile.door:door-annotations:$version_door"
implementation "com.github.UstadMobile.door:room-annotations:$version_door"
}
}
Expand All @@ -96,6 +96,15 @@ dependencies {
}
```

On your Android application module (e.g. the one building the APK), you must exclude room-annotations to avoid a
duplicate class error. This is required due to a Kotlin/JS bug as per this [README](room-annotations/).

```
configurations.all {
exclude group: "com.github.UstadMobile.door", module: "room-annotations"
}
```

2. Now create your database, DAOs, and entities in Kotlin multiplatform common code:

Database:
Expand Down Expand Up @@ -314,7 +323,7 @@ Option 2: Use comment hacks:

* [app-testdb](app-testdb/) Contains a test React/JS app. Used to run manual tests that don't seem to work in automated
JS tests.
* [door-annotations](door-annotations/) Contains androidx annotations identical to those used in room,
* [room-annotations](room-annotations/) Contains androidx annotations identical to those used in room,
used to compile on non-Android targets.
* [door-compiler](door-compiler/) Contains the actual annotation processor based on Kotlin Poet
* [door-runtime](door-runtime/) The main runtime module - contains classes and functions used by generated
Expand Down
2 changes: 1 addition & 1 deletion app-testdb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {
}

kotlin {
js(LEGACY) {
js(IR) {
binaries.executable()
browser {
commonWebpackConfig {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ plugins {


group 'com.github.UstadMobile.door'
version '0.0.63o7'
version '0.0.63o10'

ext.localProperties = new Properties()

Expand Down
2 changes: 1 addition & 1 deletion door-compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ compileTestKotlin {

dependencies {
implementation project(":door-runtime")
implementation project(":door-annotations")
implementation project(':room-annotations')
implementation "org.jetbrains.kotlin:kotlin-stdlib"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$version_kotlinx_serialization"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
Expand Down
5 changes: 3 additions & 2 deletions door-runtime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ kotlin {
}
}

js(BOTH) {
js(IR) {
browser {
testTask {
useKarma {
Expand All @@ -68,7 +68,7 @@ kotlin {
sourceSets {
commonMain {
dependencies {
compileOnly project(":door-annotations")
implementation project(":room-annotations")
implementation kotlin("stdlib-common")
implementation "io.ktor:ktor-client-core:$version_ktor"
implementation "io.ktor:ktor-client-json:$version_ktor"
Expand Down Expand Up @@ -100,6 +100,7 @@ kotlin {
androidMain {
dependsOn commonJvmMain
dependencies {
implementation project(":room-annotations")
implementation "androidx.room:room-runtime:$version_android_room"
implementation "androidx.room:room-ktx:$version_android_room"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$version_androidx_lifecycle"
Expand Down
4 changes: 2 additions & 2 deletions door-testdb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ kotlin {
}
}

js(LEGACY) {
js(IR) {
browser {
testTask {
useKarma {
Expand All @@ -69,7 +69,7 @@ kotlin {
dependencies {
implementation kotlin('stdlib-common')
implementation project(":door-runtime")
compileOnly project(":door-annotations")
implementation project(":room-annotations")

implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$version_kotlinx_serialization"
implementation "io.ktor:ktor-client-content-negotiation:$version_ktor"
Expand Down
5 changes: 5 additions & 0 deletions kotlin-js-store/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2853,6 +2853,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.5.tgz#586f0dba300cde8be52dd1ac4f7e1009c1b13f36"
integrity sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==

[email protected]:
version "4.7.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==

ua-parser-js@^0.7.30:
version "0.7.31"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.31.tgz#649a656b191dffab4f21d5e053e27ca17cbff5c6"
Expand Down
11 changes: 11 additions & 0 deletions room-annotations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# room-annotations

This module provides a copy of Room annotations so that they can be used on multiplatform code.

It must be excluded from any Android app build to avoid a duplicate class error. Normally it would be used as a compileOnly
dependency, however [Kotlin bug KT-43500](https://youtrack.jetbrains.com/issue/KT-43500) means that any consumer using
the JS-IR compiler will not compile.

Using expect/actual on annotation won't work because 1) Room's symbol processor won't recognize the link and 2) using
a typealias prevents multiplatform code from using default parameters.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ android {
consumerProguardFiles 'proguard-rules.pro'
}
}
namespace 'com.ustadmobile.door.annotations'
namespace 'com.ustadmobile.door.roomannotations'
}

kotlin {
Expand All @@ -54,7 +54,7 @@ kotlin {
}
}

js(BOTH) {
js(IR) {
browser()
}

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ include 'door-testdb'
include 'app-testdb'
include ':test-app-android'
include 'door-testdb-server'
include 'door-annotations'
include 'room-annotations'
include 'door-shallowcopy'

7 changes: 7 additions & 0 deletions test-app-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ android {
namespace 'com.ustadmobile.door.testandroid'
}

/*
* Excluded as per README for the room-annotations module.
*/
configurations.all {
exclude module: "room-annotations"
}

dependencies {
implementation project(":door-runtime")
implementation project(":door-testdb")
Expand Down

0 comments on commit 516cc69

Please sign in to comment.