Improvements

try to make it run on Android (still unsuccessful)
This commit is contained in:
Christian Basler
2024-08-21 17:03:52 +02:00
parent 082899152f
commit 8399f98d75
4 changed files with 90 additions and 90 deletions

View File

@@ -1,42 +1,28 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.android.library)
alias(libs.plugins.compose)
alias(libs.plugins.compose.compiler)
}
kotlin {
jvm {
tasks.withType<KotlinJvmCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
}
jvmToolchain(libs.versions.jdk.get().toInt())
androidTarget {
tasks.withType<KotlinJvmCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}
jvm("desktop")
androidTarget()
android.apply {
compileSdk = libs.versions.android.compileSdk.get().toInt()
namespace = "ch.dissem.yaep.common.ui"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
}
// @OptIn(ExperimentalWasmDsl::class)
// wasmJs {
// moduleName = "yaep-commonUI"
// browser()
// binaries.executable()
// }
sourceSets {
commonMain {
dependencies {
val androidMain by getting
val commonTest by getting
commonMain.dependencies {
api(projects.domain)
implementation(compose.components.resources)
@@ -46,15 +32,27 @@ kotlin {
implementation(compose.ui)
implementation(compose.components.uiToolingPreview)
// implementation(libs.compose.ui.text.googlefonts)
implementation(libs.logging)
}
androidMain.dependencies {
implementation(libs.androidx.compose.foundation)
}
val commonTest by getting {
dependencies {
commonTest.dependencies {
implementation(libs.kotlin.test)
implementation(libs.atrium)
}
}
}
android {
compileSdk = libs.versions.android.compileSdk.get().toInt()
namespace = "ch.dissem.yaep.common.ui"
buildFeatures {
compose = true
}
}
compose.resources {

View File

@@ -1,39 +1,29 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.android.library)
}
kotlin {
jvm{
tasks.withType<KotlinJvmCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
}
jvmToolchain(libs.versions.jdk.get().toInt())
androidTarget{
tasks.withType<KotlinJvmCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}
}
jvm()
androidTarget()
android.apply {
compileSdk = libs.versions.android.compileSdk.get().toInt()
namespace = "ch.dissem.yaep.domain"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
// @OptIn(ExperimentalWasmDsl::class)
// wasmJs {
// moduleName = "yaep-commonUI"
// browser()
// binaries.executable()
// }
sourceSets {
val commonTest by getting {
commonMain {
dependencies {
implementation(libs.logging)
}
}
commonTest {
dependencies {
implementation(libs.kotlin.test)
implementation(libs.atrium)
@@ -41,3 +31,8 @@ kotlin {
}
}
}
android {
compileSdk = libs.versions.android.compileSdk.get().toInt()
namespace = "ch.dissem.yaep.domain"
}

View File

@@ -9,6 +9,7 @@ import ch.tutteli.atrium.api.fluent.en_GB.toBeGreaterThan
import ch.tutteli.atrium.api.fluent.en_GB.toBeLessThan
import ch.tutteli.atrium.api.fluent.en_GB.toEqual
import ch.tutteli.atrium.api.verbs.expect
import co.touchlab.kermit.Logger
import kotlin.test.Test
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.measureTime
@@ -17,7 +18,7 @@ class GameTest {
@Test
fun `ensure generated games are solvable`() {
val tries = 2000
val tries = 1000
var fastest = 500.milliseconds
var slowest = 0.milliseconds
var total = 0.milliseconds
@@ -29,10 +30,10 @@ class GameTest {
val time = measureTime {
game = generateGame()
}
println("Generated game #$i in ${time.inWholeMilliseconds}ms")
Logger.i { "Generated game #$i in ${time.inWholeMilliseconds}ms" }
val solvable = solve(game.grid, game.clues)
if (solvable != SOLVABLE) {
println("Puzzle:\n$game")
Logger.i { "Puzzle:\n$game" }
}
expect(solvable).toEqual(SOLVABLE)
expect(time).toBeLessThan(500.milliseconds)
@@ -52,13 +53,13 @@ class GameTest {
totalClues += game.clues.size
}
println("Slowest: $slowest")
println("Fastest: $fastest")
println("Average: ${total / tries}")
println("Clues:")
println("Most: $most")
println("Least: $least")
println("Average: ${totalClues / tries}")
Logger.i { "Slowest: $slowest" }
Logger.i { "Fastest: $fastest" }
Logger.i { "Average: ${total / tries}" }
Logger.i { "Clues:" }
Logger.i { "Most: $most" }
Logger.i { "Least: $least" }
Logger.i { "Average: ${totalClues / tries}" }
}
@Test
@@ -75,8 +76,8 @@ class GameTest {
feature(Collection<Clue>::size).toBeLessThan(30)
}
}
println("Clues: ${game.clues.size}")
println("Time: $time")
Logger.i{"Clues: ${game.clues.size}"}
Logger.i{"Time: $time"}
expect(solve(game.grid, game.clues)).toEqual(SOLVABLE)
expect(time).toBeLessThan(500.milliseconds)
}
@@ -130,7 +131,8 @@ class GameTest {
@Test
fun `ensure specific game is solvable`() {
val game = Game.parse("""
val game = Game.parse(
"""
👩🏿‍⚕️👨🏽‍🎤👩🏿‍⚕️ 👩🏾‍🚀🧑🏿‍🏫
🐜🐕 🐐 🐐
🍉🥭🍐🍇🍍
@@ -162,7 +164,8 @@ class GameTest {
* ROCK_STAR and UNITED_KINGDOM are in the same column
* ROCK_STAR is next to DOUGHNUT
* PINEAPPLE is between the neighbours TEACHER and GRAPES to both sides
""".trimIndent())
""".trimIndent()
)
expect(solve(game.grid, game.clues)).toEqual(SOLVABLE)
}

View File

@@ -1,21 +1,25 @@
[versions]
agp = "8.5.2"
agp = "8.3.2"
jdk = "11"
android-compileSdk = "34"
android-minSdk = "24"
android-targetSdk = "34"
androidx-activityCompose = "1.9.1"
androidx-compose = "1.6.8"
androidx-compose = "1.6.7"
compose-plugin = "1.6.11"
kotlin = "2.0.0"
kotlinVersion = "2.0.0"
coreKtx = "1.13.1"
atrium = "1.2.0"
[libraries]
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
androidx-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "androidx-compose" }
androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "androidx-compose" }
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
atrium = { module = "ch.tutteli.atrium:atrium-fluent", version = "1.2.0" }
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
atrium = { module = "ch.tutteli.atrium:atrium-fluent", version.ref = "atrium" }
atrium-js = { module = "ch.tutteli.atrium:atrium-fluent-js", version.ref = "atrium" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" }
logging = { module = "co.touchlab:kermit", version = "2.0.4" }
[plugins]
versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
@@ -25,4 +29,4 @@ kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
compose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" }
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }