Phase 1 work
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
plugins {
|
||||
// AGP must apply BEFORE recipe.kotlin.multiplatform — the latter calls androidTarget(),
|
||||
// which requires the Android Gradle Plugin to already be on the project. Gradle applies
|
||||
// plugin IDs in declaration order, so com.android.library is listed first.
|
||||
alias(libs.plugins.androidLibrary)
|
||||
id("recipe.kotlin.multiplatform")
|
||||
id("recipe.quality")
|
||||
alias(libs.plugins.androidLibrary)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@@ -25,12 +28,18 @@ kotlin {
|
||||
|
||||
android {
|
||||
namespace = "dev.ulfrx.recipe.shared"
|
||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||
compileSdk =
|
||||
libs.versions.android.compileSdk
|
||||
.get()
|
||||
.toInt()
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
minSdk =
|
||||
libs.versions.android.minSdk
|
||||
.get()
|
||||
.toInt()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package dev.ulfrx.recipe
|
||||
|
||||
import android.os.Build
|
||||
|
||||
class AndroidPlatform : Platform {
|
||||
public class AndroidPlatform : Platform {
|
||||
override val name: String = "Android ${Build.VERSION.SDK_INT}"
|
||||
}
|
||||
|
||||
actual fun getPlatform(): Platform = AndroidPlatform()
|
||||
public actual fun getPlatform(): Platform = AndroidPlatform()
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
package dev.ulfrx.recipe
|
||||
|
||||
const val SERVER_PORT = 8080
|
||||
public const val SERVER_PORT: Int = 8080
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package dev.ulfrx.recipe
|
||||
|
||||
class Greeting {
|
||||
public class Greeting {
|
||||
private val platform = getPlatform()
|
||||
|
||||
fun greet(): String {
|
||||
return "Hello, ${platform.name}!"
|
||||
}
|
||||
}
|
||||
public fun greet(): String = "Hello, ${platform.name}!"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.ulfrx.recipe
|
||||
|
||||
interface Platform {
|
||||
val name: String
|
||||
public interface Platform {
|
||||
public val name: String
|
||||
}
|
||||
|
||||
expect fun getPlatform(): Platform
|
||||
public expect fun getPlatform(): Platform
|
||||
|
||||
@@ -4,9 +4,8 @@ import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class SharedCommonTest {
|
||||
|
||||
@Test
|
||||
fun example() {
|
||||
assertEquals(3, 1 + 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package dev.ulfrx.recipe
|
||||
|
||||
import platform.UIKit.UIDevice
|
||||
|
||||
class IOSPlatform : Platform {
|
||||
public class IOSPlatform : Platform {
|
||||
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
|
||||
}
|
||||
|
||||
actual fun getPlatform(): Platform = IOSPlatform()
|
||||
public actual fun getPlatform(): Platform = IOSPlatform()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.ulfrx.recipe
|
||||
|
||||
class JVMPlatform : Platform {
|
||||
public class JVMPlatform : Platform {
|
||||
override val name: String = "Java ${System.getProperty("java.version")}"
|
||||
}
|
||||
|
||||
actual fun getPlatform(): Platform = JVMPlatform()
|
||||
public actual fun getPlatform(): Platform = JVMPlatform()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.ulfrx.recipe
|
||||
|
||||
class WasmPlatform : Platform {
|
||||
public class WasmPlatform : Platform {
|
||||
override val name: String = "Web with Kotlin/Wasm"
|
||||
}
|
||||
|
||||
actual fun getPlatform(): Platform = WasmPlatform()
|
||||
public actual fun getPlatform(): Platform = WasmPlatform()
|
||||
|
||||
Reference in New Issue
Block a user