Skip to content

Commit

Permalink
Merge pull request #1 from tunjid/tj/kotlin-2.0
Browse files Browse the repository at this point in the history
Kotlin 2.0
  • Loading branch information
tunjid authored Jul 22, 2024
2 parents 1d383e2 + e97138b commit a37bf42
Show file tree
Hide file tree
Showing 19 changed files with 91 additions and 40 deletions.
2 changes: 1 addition & 1 deletion benchmarks/benchmarkable/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {


kotlin {
jvmToolchain(11)
jvmToolchain(17)
}
android {
namespace = "com.example.benchmarks"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/microbenchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

kotlin {
jvmToolchain(11)
jvmToolchain(17)
}
android {
namespace = "com.example.microbenchmark"
Expand Down
1 change: 1 addition & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

33 changes: 17 additions & 16 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
[versions]
androidGradlePlugin = "8.0.2"
androidxActivity = "1.8.2"
androidxAppCompat = "1.6.1"
androidGradlePlugin = "8.5.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.7.0-beta05"
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.7.0-dev1731"
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]
Expand All @@ -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" }
Expand Down Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions library/compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ plugins {
signing
id("org.jetbrains.dokka")
id("org.jetbrains.compose")
alias(libs.plugins.compose.compiler)
}

kotlin {
applyDefaultHierarchyTemplate()
js(IR) {
nodejs()
browser()
Expand All @@ -35,6 +37,16 @@ kotlin {
useJUnit()
}
}
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64(),
).forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = "tiler-compose"
isStatic = true
}
}

sourceSets {
commonMain {
Expand Down
13 changes: 11 additions & 2 deletions library/tiler/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ plugins {
}

kotlin {
applyDefaultHierarchyTemplate()
js(IR) {
nodejs()
browser()
Expand All @@ -34,8 +35,16 @@ kotlin {
useJUnit()
}
}
applyDefaultHierarchyTemplate()
iosSimulatorArm64()
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64(),
).forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = "tiler"
isStatic = true
}
}
linuxX64()
macosX64()
macosArm64()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>(Int::compareTo).reversed()))
assertEquals(
expected = 8.tiledTestRange() + 3.tiledTestRange() + 1.tiledTestRange(),
actual = awaitItem()
Expand Down Expand Up @@ -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>(Int::compareTo)))
assertEquals(
expected = 1.tiledTestRange() + 3.tiledTestRange() + 8.tiledTestRange(),
actual = awaitItem()
Expand All @@ -296,7 +296,7 @@ class TileKtTest {
requests.emit(
Tile.Order.PivotSorted(
query = 4,
comparator = Comparator(Int::compareTo)
comparator = Comparator<Int>(Int::compareTo)
)
)
assertEquals(
Expand All @@ -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>(Int::compareTo)))
assertEquals(
1.tiledTestRange() + 3.tiledTestRange() + 4.tiledTestRange(),
awaitItem()
Expand Down Expand Up @@ -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>(Int::compareTo)
val tiler = listTiler(
order = Tile.Order.PivotSorted(
query = 0,
Expand Down Expand Up @@ -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>(Int::compareTo).reversed()))
assertEquals(
expected = 3.tiledTestRange() + 2.tiledTestRange(),
actual = awaitItem()
Expand All @@ -491,7 +491,7 @@ class TileKtTest {
requests.emit(
Tile.Order.PivotSorted(
query = 2,
comparator = Comparator(Int::compareTo)
comparator = Comparator<Int>(Int::compareTo)
)
)
assertEquals(
Expand All @@ -503,7 +503,7 @@ class TileKtTest {
requests.emit(
Tile.Order.PivotSorted(
query = 2,
comparator = Comparator(Int::compareTo).reversed()
comparator = Comparator<Int>(Int::compareTo).reversed()
)
)
assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>(Int::compareTo)
val pivotRequest: PivotRequest<Int, Int> = PivotRequest(
onCount = numPages,
offCount = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import kotlin.test.assertEquals

class PivotingKtTest {

private val comparator: Comparator<Int> = Comparator(Int::compareTo)
private val comparator: Comparator<Int> = Comparator<Int>(Int::compareTo)

private val pivotRequest: PivotRequest<Int, Int> = PivotRequest(
onCount = 3,
Expand Down
1 change: 1 addition & 0 deletions sample/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
plugins {
id("android-application-convention")
id("kotlin-android")
alias(libs.plugins.compose.compiler)
}

android {
Expand Down
1 change: 1 addition & 0 deletions sample/browser/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 20 additions & 0 deletions sample/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,20 @@ plugins {
id("android-library-convention")
id("kotlin-library-convention")
id("org.jetbrains.compose")
alias(libs.plugins.compose.compiler)
}

kotlin {
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64(),
).forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = "common"
isStatic = true
}
}
sourceSets {
named("commonMain") {
dependencies {
Expand All @@ -45,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 {
}
Expand Down
9 changes: 9 additions & 0 deletions sample/common/src/iosMain/kotlin/main.ios.kt
Original file line number Diff line number Diff line change
@@ -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()
}
}
1 change: 1 addition & 0 deletions sample/desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ include(
":sample:common",
":sample:android",
":sample:desktop",
":sample:browser",
// ":sample:browser",
":benchmarks:benchmarkable",
":benchmarks:microbenchmark",
)

0 comments on commit a37bf42

Please # to comment.