From b23fe9559af225a80ae665402d6270e8d0a05150 Mon Sep 17 00:00:00 2001 From: Adetunji Date: Sat, 20 Jul 2024 10:29:11 -0400 Subject: [PATCH 1/5] Bup to Compose 2.0 --- build-logic/convention/build.gradle.kts | 1 + .../kotlin/android-app-library-convention.kt | 7 ----- build.gradle.kts | 1 + gradle/libs.versions.toml | 31 ++++++++++--------- library/compose/build.gradle.kts | 1 + sample/android/build.gradle.kts | 1 + sample/browser/build.gradle.kts | 1 + sample/common/build.gradle.kts | 1 + sample/desktop/build.gradle.kts | 1 + settings.gradle.kts | 4 +-- 10 files changed, 25 insertions(+), 24 deletions(-) diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index fda5679..9b70587 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -29,5 +29,6 @@ dependencies { implementation(libs.jetbrains.compose.gradlePlugin) implementation(libs.kotlin.gradlePlugin) implementation(libs.android.gradlePlugin) + implementation(libs.compose.compiler.plugin) implementation(libs.dokka.gradlePlugin) } diff --git a/build-logic/convention/src/main/kotlin/android-app-library-convention.kt b/build-logic/convention/src/main/kotlin/android-app-library-convention.kt index f35fc5e..4314b28 100644 --- a/build-logic/convention/src/main/kotlin/android-app-library-convention.kt +++ b/build-logic/convention/src/main/kotlin/android-app-library-convention.kt @@ -51,13 +51,6 @@ fun org.gradle.api.Project.androidConfiguration( buildFeatures { compose = true } - composeOptions { - val composeCompilerVersion = versionCatalog - .findVersion("androidxComposeCompiler") - .get() - .requiredVersion - kotlinCompilerExtensionVersion = composeCompilerVersion - } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 diff --git a/build.gradle.kts b/build.gradle.kts index bf8feb3..1d76bed 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -39,6 +39,7 @@ plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.android.library) apply false alias(libs.plugins.androidx.benchmark) apply false + alias(libs.plugins.compose.compiler) apply false alias(libs.plugins.jetbrains.compose) apply false alias(libs.plugins.jetbrains.dokka) apply false alias(libs.plugins.kotlin.android) apply false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 234e025..b198b0c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,24 +1,23 @@ [versions] androidGradlePlugin = "8.0.2" -androidxActivity = "1.8.2" -androidxAppCompat = "1.6.1" +androidxActivity = "1.9.0" +androidxAppCompat = "1.7.0" androidxBenchmark = "1.2.4" -androidxCore = "1.12.0" -androidxCompose = "1.6.1" -androidxComposeCompiler = "1.5.8" +androidxCore = "1.13.1" +androidxCompose = "1.6.7" androidxPaging = "3.2.1" -androidxTestCore = "1.5.0" -androidxTestExt = "1.1.5" -androidxTestRunner = "1.5.2" -androidxTestRules = "1.5.0" +androidxTestCore = "1.6.1" +androidxTestExt = "1.2.1" +androidxTestRunner = "1.6.1" +androidxTestRules = "1.6.1" dokka = "1.8.10" -jetbrainsCompose = "1.6.0-rc01" +jetbrainsCompose = "1.6.11" junit4 = "4.13.2" -kotlin = "1.9.22" -kotlinxCoroutines = "1.7.3" -googleMaterial = "1.11.0" -tunjidMutator = "0.0.9" -tunjidTreeNav = "0.0.6" +kotlin = "2.0.0" +kotlinxCoroutines = "1.9.0-RC" +googleMaterial = "1.12.0" +tunjidMutator = "1.1.0" +tunjidTreeNav = "0.0.7" turbine = "0.12.1" [libraries] @@ -45,6 +44,7 @@ androidx-test-junit = { group = "androidx.test.ext", name = "junit", version.ref androidx-test-rules = { group = "androidx.test", name = "rules", version.ref = "androidxTestRules" } androidx-test-runner = { group = "androidx.test", name = "runner", version.ref = "androidxTestRunner" } cashapp-turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" } +compose-compiler-plugin = { group = "org.jetbrains.kotlin", name = "compose-compiler-gradle-plugin", version.ref = "kotlin" } google-material = { group = "com.google.android.material", name = "material", version.ref = "googleMaterial" } jetbrains-compose-animation = { group = "org.jetbrains.compose.animation", name = "animation", version.ref = "jetbrainsCompose" } jetbrains-compose-foundation = { group = "org.jetbrains.compose.foundation", name = "foundation", version.ref = "jetbrainsCompose" } @@ -74,6 +74,7 @@ tunjid-treenav-common = { group = "com.tunjid.treenav", name = "treenav", versio android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" } androidx-benchmark = { id = "androidx.benchmark", version.ref = "androidxBenchmark" } +compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } diff --git a/library/compose/build.gradle.kts b/library/compose/build.gradle.kts index 789d643..7551db4 100644 --- a/library/compose/build.gradle.kts +++ b/library/compose/build.gradle.kts @@ -22,6 +22,7 @@ plugins { signing id("org.jetbrains.dokka") id("org.jetbrains.compose") + alias(libs.plugins.compose.compiler) } kotlin { diff --git a/sample/android/build.gradle.kts b/sample/android/build.gradle.kts index bb342a6..d1a9207 100644 --- a/sample/android/build.gradle.kts +++ b/sample/android/build.gradle.kts @@ -17,6 +17,7 @@ plugins { id("android-application-convention") id("kotlin-android") + alias(libs.plugins.compose.compiler) } android { diff --git a/sample/browser/build.gradle.kts b/sample/browser/build.gradle.kts index e32a3be..14d45b3 100755 --- a/sample/browser/build.gradle.kts +++ b/sample/browser/build.gradle.kts @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension plugins { kotlin("multiplatform") id("org.jetbrains.compose") + alias(libs.plugins.compose.compiler) } kotlin { diff --git a/sample/common/build.gradle.kts b/sample/common/build.gradle.kts index a924544..b49b6bb 100755 --- a/sample/common/build.gradle.kts +++ b/sample/common/build.gradle.kts @@ -18,6 +18,7 @@ plugins { id("android-library-convention") id("kotlin-library-convention") id("org.jetbrains.compose") + alias(libs.plugins.compose.compiler) } kotlin { diff --git a/sample/desktop/build.gradle.kts b/sample/desktop/build.gradle.kts index ba7d6ec..f55ff32 100755 --- a/sample/desktop/build.gradle.kts +++ b/sample/desktop/build.gradle.kts @@ -20,6 +20,7 @@ plugins { kotlin("multiplatform") // kotlin("jvm") doesn't work well in IDEA/AndroidStudio (https://github.com/JetBrains/compose-jb/issues/22) id("org.jetbrains.compose") id("kotlin-jvm-convention") + alias(libs.plugins.compose.compiler) } kotlin { diff --git a/settings.gradle.kts b/settings.gradle.kts index 7849467..7636e0a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -39,6 +39,6 @@ include( ":sample:android", ":sample:desktop", ":sample:browser", - ":benchmarks:benchmarkable", - ":benchmarks:microbenchmark", +// ":benchmarks:benchmarkable", +// ":benchmarks:microbenchmark", ) From 297a8fd6e26f17c0327edd3930a369b11c0891b2 Mon Sep 17 00:00:00 2001 From: Adetunji Date: Sat, 20 Jul 2024 10:45:30 -0400 Subject: [PATCH 2/5] Fix broken benchmark toolchain --- benchmarks/benchmarkable/build.gradle.kts | 2 +- benchmarks/microbenchmark/build.gradle.kts | 2 +- settings.gradle.kts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/benchmarks/benchmarkable/build.gradle.kts b/benchmarks/benchmarkable/build.gradle.kts index 42f03a0..0a32a05 100644 --- a/benchmarks/benchmarkable/build.gradle.kts +++ b/benchmarks/benchmarkable/build.gradle.kts @@ -5,7 +5,7 @@ plugins { kotlin { - jvmToolchain(11) + jvmToolchain(17) } android { namespace = "com.example.benchmarks" diff --git a/benchmarks/microbenchmark/build.gradle.kts b/benchmarks/microbenchmark/build.gradle.kts index a99eadc..e228630 100644 --- a/benchmarks/microbenchmark/build.gradle.kts +++ b/benchmarks/microbenchmark/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } kotlin { - jvmToolchain(11) + jvmToolchain(17) } android { namespace = "com.example.microbenchmark" diff --git a/settings.gradle.kts b/settings.gradle.kts index 7636e0a..7849467 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -39,6 +39,6 @@ include( ":sample:android", ":sample:desktop", ":sample:browser", -// ":benchmarks:benchmarkable", -// ":benchmarks:microbenchmark", + ":benchmarks:benchmarkable", + ":benchmarks:microbenchmark", ) From 5e1caa0b18076e477bb312a3082ed26aa38c0806 Mon Sep 17 00:00:00 2001 From: Adetunji Date: Sat, 20 Jul 2024 10:57:36 -0400 Subject: [PATCH 3/5] Bump agp --- .../src/main/kotlin/android-app-library-convention.kt | 2 +- gradle/libs.versions.toml | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build-logic/convention/src/main/kotlin/android-app-library-convention.kt b/build-logic/convention/src/main/kotlin/android-app-library-convention.kt index 4314b28..cdbe676 100644 --- a/build-logic/convention/src/main/kotlin/android-app-library-convention.kt +++ b/build-logic/convention/src/main/kotlin/android-app-library-convention.kt @@ -39,7 +39,7 @@ import org.gradle.api.artifacts.VersionCatalogsExtension * Sets common values for Android Applications and Libraries */ fun org.gradle.api.Project.androidConfiguration( - extension: CommonExtension<*, *, *, *> + extension: CommonExtension<*, *, *, *, *, *> ) = extension.apply { namespace = "com.tunjid.tiler.${project.name}" compileSdk = 34 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b198b0c..fc081a8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -androidGradlePlugin = "8.0.2" +androidGradlePlugin = "8.5.1" androidxActivity = "1.9.0" androidxAppCompat = "1.7.0" androidxBenchmark = "1.2.4" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1a48bad..d990e30 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -16,7 +16,7 @@ #Mon Jul 05 07:23:39 EDT 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME From 6d0c28331a94b0f49d385c6c04f83a526eae2f1f Mon Sep 17 00:00:00 2001 From: Adetunji Date: Sat, 20 Jul 2024 11:10:21 -0400 Subject: [PATCH 4/5] Bump to compose 1.7.0 --- gradle/libs.versions.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fc081a8..c223513 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,14 +4,14 @@ androidxActivity = "1.9.0" androidxAppCompat = "1.7.0" androidxBenchmark = "1.2.4" androidxCore = "1.13.1" -androidxCompose = "1.6.7" +androidxCompose = "1.7.0-beta05" androidxPaging = "3.2.1" androidxTestCore = "1.6.1" androidxTestExt = "1.2.1" androidxTestRunner = "1.6.1" androidxTestRules = "1.6.1" dokka = "1.8.10" -jetbrainsCompose = "1.6.11" +jetbrainsCompose = "1.7.0-dev1731" junit4 = "4.13.2" kotlin = "2.0.0" kotlinxCoroutines = "1.9.0-RC" From e97138b3a62d364686fe5f902ff1ed66417d1473 Mon Sep 17 00:00:00 2001 From: Adetunji Date: Mon, 22 Jul 2024 11:51:45 -0400 Subject: [PATCH 5/5] Add iOS demo --- gradle.properties | 2 ++ library/compose/build.gradle.kts | 11 +++++++++++ library/tiler/build.gradle.kts | 13 +++++++++++-- .../kotlin/com/tunjid/tiler/TileKtTest.kt | 16 ++++++++-------- .../tunjid/tiler/TilingIterationOrderTest.kt | 2 +- .../com/tunjid/utilities/PivotingKtTest.kt | 2 +- sample/common/build.gradle.kts | 19 +++++++++++++++++++ sample/common/src/iosMain/kotlin/main.ios.kt | 9 +++++++++ settings.gradle.kts | 2 +- 9 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 sample/common/src/iosMain/kotlin/main.ios.kt diff --git a/gradle.properties b/gradle.properties index 0527e6b..6085be2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -35,3 +35,5 @@ android.useAndroidX=true kotlin.code.style=official org.jetbrains.compose.experimental.jscanvas.enabled=true kotlin.mpp.androidSourceSetLayoutVersion=2 +xcodeproj=~/sample/ios + diff --git a/library/compose/build.gradle.kts b/library/compose/build.gradle.kts index 7551db4..e2a2cfa 100644 --- a/library/compose/build.gradle.kts +++ b/library/compose/build.gradle.kts @@ -26,6 +26,7 @@ plugins { } kotlin { + applyDefaultHierarchyTemplate() js(IR) { nodejs() browser() @@ -36,6 +37,16 @@ kotlin { useJUnit() } } + listOf( + iosX64(), + iosArm64(), + iosSimulatorArm64(), + ).forEach { iosTarget -> + iosTarget.binaries.framework { + baseName = "tiler-compose" + isStatic = true + } + } sourceSets { commonMain { diff --git a/library/tiler/build.gradle.kts b/library/tiler/build.gradle.kts index 920db78..edf8774 100644 --- a/library/tiler/build.gradle.kts +++ b/library/tiler/build.gradle.kts @@ -24,6 +24,7 @@ plugins { } kotlin { + applyDefaultHierarchyTemplate() js(IR) { nodejs() browser() @@ -34,8 +35,16 @@ kotlin { useJUnit() } } - applyDefaultHierarchyTemplate() - iosSimulatorArm64() + listOf( + iosX64(), + iosArm64(), + iosSimulatorArm64(), + ).forEach { iosTarget -> + iosTarget.binaries.framework { + baseName = "tiler" + isStatic = true + } + } linuxX64() macosX64() macosArm64() diff --git a/library/tiler/src/commonTest/kotlin/com/tunjid/tiler/TileKtTest.kt b/library/tiler/src/commonTest/kotlin/com/tunjid/tiler/TileKtTest.kt index b247b8a..d37f169 100644 --- a/library/tiler/src/commonTest/kotlin/com/tunjid/tiler/TileKtTest.kt +++ b/library/tiler/src/commonTest/kotlin/com/tunjid/tiler/TileKtTest.kt @@ -248,7 +248,7 @@ class TileKtTest { ) // Reverse sort by page - requests.emit(Tile.Order.Sorted(comparator = Comparator(Int::compareTo).reversed())) + requests.emit(Tile.Order.Sorted(comparator = Comparator(Int::compareTo).reversed())) assertEquals( expected = 8.tiledTestRange() + 3.tiledTestRange() + 1.tiledTestRange(), actual = awaitItem() @@ -279,7 +279,7 @@ class TileKtTest { ) // Sort ascending - requests.emit(Tile.Order.Sorted(comparator = Comparator(Int::compareTo))) + requests.emit(Tile.Order.Sorted(comparator = Comparator(Int::compareTo))) assertEquals( expected = 1.tiledTestRange() + 3.tiledTestRange() + 8.tiledTestRange(), actual = awaitItem() @@ -296,7 +296,7 @@ class TileKtTest { requests.emit( Tile.Order.PivotSorted( query = 4, - comparator = Comparator(Int::compareTo) + comparator = Comparator(Int::compareTo) ) ) assertEquals( @@ -305,7 +305,7 @@ class TileKtTest { ) // Sort ascending in absolute terms - requests.emit(Tile.Order.Sorted(comparator = Comparator(Int::compareTo))) + requests.emit(Tile.Order.Sorted(comparator = Comparator(Int::compareTo))) assertEquals( 1.tiledTestRange() + 3.tiledTestRange() + 4.tiledTestRange(), awaitItem() @@ -414,7 +414,7 @@ class TileKtTest { @Test fun pivoting_pipeline_should_only_emit_when_data_is_available_from_pivot_query() = runTest { - val comparator = Comparator(Int::compareTo) + val comparator = Comparator(Int::compareTo) val tiler = listTiler( order = Tile.Order.PivotSorted( query = 0, @@ -481,7 +481,7 @@ class TileKtTest { ) // Reverse sort by page - requests.emit(Tile.Order.Sorted(comparator = Comparator(Int::compareTo).reversed())) + requests.emit(Tile.Order.Sorted(comparator = Comparator(Int::compareTo).reversed())) assertEquals( expected = 3.tiledTestRange() + 2.tiledTestRange(), actual = awaitItem() @@ -491,7 +491,7 @@ class TileKtTest { requests.emit( Tile.Order.PivotSorted( query = 2, - comparator = Comparator(Int::compareTo) + comparator = Comparator(Int::compareTo) ) ) assertEquals( @@ -503,7 +503,7 @@ class TileKtTest { requests.emit( Tile.Order.PivotSorted( query = 2, - comparator = Comparator(Int::compareTo).reversed() + comparator = Comparator(Int::compareTo).reversed() ) ) assertEquals( diff --git a/library/tiler/src/commonTest/kotlin/com/tunjid/tiler/TilingIterationOrderTest.kt b/library/tiler/src/commonTest/kotlin/com/tunjid/tiler/TilingIterationOrderTest.kt index 4747e71..1059b64 100644 --- a/library/tiler/src/commonTest/kotlin/com/tunjid/tiler/TilingIterationOrderTest.kt +++ b/library/tiler/src/commonTest/kotlin/com/tunjid/tiler/TilingIterationOrderTest.kt @@ -213,7 +213,7 @@ class ListMapTilingSamenessTest { val range = (0..15) (1..10).forEach { itemsPerPage -> (3..10).forEach { numPages -> - val comparator = Comparator(Int::compareTo) + val comparator = Comparator(Int::compareTo) val pivotRequest: PivotRequest = PivotRequest( onCount = numPages, offCount = 0, diff --git a/library/tiler/src/commonTest/kotlin/com/tunjid/utilities/PivotingKtTest.kt b/library/tiler/src/commonTest/kotlin/com/tunjid/utilities/PivotingKtTest.kt index 0c9f8ef..1e7c313 100644 --- a/library/tiler/src/commonTest/kotlin/com/tunjid/utilities/PivotingKtTest.kt +++ b/library/tiler/src/commonTest/kotlin/com/tunjid/utilities/PivotingKtTest.kt @@ -37,7 +37,7 @@ import kotlin.test.assertEquals class PivotingKtTest { - private val comparator: Comparator = Comparator(Int::compareTo) + private val comparator: Comparator = Comparator(Int::compareTo) private val pivotRequest: PivotRequest = PivotRequest( onCount = 3, diff --git a/sample/common/build.gradle.kts b/sample/common/build.gradle.kts index b49b6bb..804f216 100755 --- a/sample/common/build.gradle.kts +++ b/sample/common/build.gradle.kts @@ -22,6 +22,16 @@ plugins { } kotlin { + listOf( + iosX64(), + iosArm64(), + iosSimulatorArm64(), + ).forEach { iosTarget -> + iosTarget.binaries.framework { + baseName = "common" + isStatic = true + } + } sourceSets { named("commonMain") { dependencies { @@ -46,6 +56,15 @@ kotlin { implementation(libs.androidx.compose.foundation.layout) } } + val iosX64Main by getting + val iosArm64Main by getting + val iosSimulatorArm64Main by getting + val iosMain by creating { + dependsOn(named("commonMain").get()) + iosX64Main.dependsOn(this) + iosArm64Main.dependsOn(this) + iosSimulatorArm64Main.dependsOn(this) + } val jsMain by getting { dependencies { } diff --git a/sample/common/src/iosMain/kotlin/main.ios.kt b/sample/common/src/iosMain/kotlin/main.ios.kt new file mode 100644 index 0000000..cc47d8f --- /dev/null +++ b/sample/common/src/iosMain/kotlin/main.ios.kt @@ -0,0 +1,9 @@ +import androidx.compose.ui.window.ComposeUIViewController +import com.tunjid.demo.common.ui.AppTheme +import com.tunjid.demo.common.ui.Root + +fun MainViewController() = ComposeUIViewController { + AppTheme { + Root() + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 7849467..788bc88 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -38,7 +38,7 @@ include( ":sample:common", ":sample:android", ":sample:desktop", - ":sample:browser", +// ":sample:browser", ":benchmarks:benchmarkable", ":benchmarks:microbenchmark", )