victor.kropp.name multiplatform projects with @kropp ... toulouse 2018... · kotlin/native...
TRANSCRIPT
![Page 1: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/1.jpg)
Multiplatform projects with
Victor Kropp@kropp
victor.kropp.name
![Page 2: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/2.jpg)
![Page 3: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/3.jpg)
![Page 4: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/4.jpg)
![Page 5: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/5.jpg)
![Page 6: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/6.jpg)
![Page 7: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/7.jpg)
![Page 8: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/8.jpg)
![Page 9: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/9.jpg)
![Page 10: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/10.jpg)
![Page 11: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/11.jpg)
![Page 13: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/13.jpg)
https://twitter.com/timbray/status/822470746773409794
![Page 14: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/14.jpg)
Modern applications
![Page 15: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/15.jpg)
![Page 16: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/16.jpg)
CC++C#Objective-CSwift
Java
Objective-CSwift
JavaPythonRuby
JavaScriptTypeScript
![Page 17: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/17.jpg)
compiled vs. interpreted
![Page 18: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/18.jpg)
compiled vs. interpreted
static vs. dynamic typing
![Page 19: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/19.jpg)
compiled vs. interpreted
static vs. dynamic typing
manual vs. automatic memory management
![Page 20: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/20.jpg)
CC++C#Objective-CSwift
Java
Objective-CSwift
JavaPythonRuby
JavaScriptTypeScript
![Page 21: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/21.jpg)
CC++C#Objective-CSwift
Java
Objective-CSwift
JavaPythonRuby
JavaScriptTypeScript
![Page 22: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/22.jpg)
![Page 23: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/23.jpg)
![Page 24: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/24.jpg)
Kotlin
Kotlin
Kotlin
Kotlin
Kotlin
![Page 25: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/25.jpg)
Kotlin/Native
Kotlin/JVM
Kotlin/Native
Kotlin/JVM
Kotlin/JS
![Page 26: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/26.jpg)
Using the same languageacross all platforms
All team members speak the same language
![Page 27: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/27.jpg)
Using the same languageacross all platforms
All team members speak the same language
Simplified full-stack development
![Page 28: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/28.jpg)
Using the same languageacross all platforms
All team members speak the same language
Simplified full-stack development
Single team works on apps for all platforms
![Page 29: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/29.jpg)
Code sharing
![Page 30: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/30.jpg)
Code sharing
Share data structures
![Page 31: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/31.jpg)
Code sharing
Share data structures
Share business logic
![Page 32: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/32.jpg)
Code sharing
Share data structures
Share business logic
Share tests!
![Page 33: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/33.jpg)
Multiplatformprojectsin Kotlin
![Page 34: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/34.jpg)
Still experimental
![Page 35: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/35.jpg)
![Page 36: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/36.jpg)
Common code
fun validate(day: Int, month: Int, year: Int): Boolean {
}
![Page 37: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/37.jpg)
Common code
fun validate(day: Int, month: Int, year: Int): Boolean {
return month in 1..12
}
![Page 38: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/38.jpg)
Common code
fun validate(day: Int, month: Int, year: Int): Boolean {
return Date(year, month, day).isValid()
}
![Page 39: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/39.jpg)
Common code
fun validate(day: Int, month: Int, year: Int): Boolean {
return Date(year, month, day).isValid()
}
class Date(day: Int, month: Int, year: Int) {
fun isValid(): Boolean = ...
}
![Page 40: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/40.jpg)
Common code
class Date(day: Int, month: Int, year: Int) {
fun isValid(): Boolean = ...
}
![Page 41: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/41.jpg)
Interfaces
interface Date {
fun isValid(): Boolean
}
![Page 42: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/42.jpg)
Interfaces
interface Date {
fun isValid(): Boolean
}
class DateJvm : Date { override fun isValid() = true }
class DateJs : Date { override fun isValid() = true }
class DateNative : Date { override fun isValid() = true }
![Page 43: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/43.jpg)
Interfaces
interface Date {
fun isValid(): Boolean
}
object DateFactory {
fun createDate(day: Int, month: Int, year: Int) = ...
}
![Page 44: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/44.jpg)
expect
expect class Date(day: Int, month: Int, year: Int) {
fun isValid(): Boolean
}
![Page 45: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/45.jpg)
expect limitations
expect class Date(val day: Int, month: Int, year: Int) {
fun isValid(): Boolean
}
![Page 46: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/46.jpg)
expect limitations
expect class Date(val day: Int, month: Int, year: Int) {
fun isValid(): Boolean
}
![Page 47: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/47.jpg)
expect limitations
expect class Date(day: Int, month: Int, year: Int) {
val day: Int
val month: Int
val year: Int
fun isValid(): Boolean
}
![Page 48: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/48.jpg)
expect limitations
expect class Date(day: Int, month: Int, year: Int) {
private val day: Int
private val month: Int
private val year: Int
fun isValid(): Boolean
}
![Page 49: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/49.jpg)
expect limitations
expect class Date(day: Int, month: Int, year: Int) {
fun isValid(): Boolean {
return true
}
}
![Page 50: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/50.jpg)
expect limitations
expect class Date(day: Int, month: Int, year: Int) {
fun isValid(): Boolean {
return true
}
}
![Page 51: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/51.jpg)
expect limitations
expect class Date(day: Int, month: Int, year: Int) {
}
fun Date.isValid(): Boolean {
return true
}
![Page 52: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/52.jpg)
actual
actual class Date
actual constructor(private val day: Int, private val month: Int, private val year: Int) {
actual fun isValid() = ...
}
![Page 53: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/53.jpg)
actual
actual class Date
actual constructor(private val day: Int, private val month: Int, private val year: Int) {
actual fun isValid() = true
}
![Page 54: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/54.jpg)
All targets
actual class Date // JVM
actual class Date // JS
actual class Date // Native
![Page 55: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/55.jpg)
No overhead
![Page 56: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/56.jpg)
Existing actual class
expect class LocalDate {
fun lengthOfYear(): Int
}
![Page 57: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/57.jpg)
typealias
expect class LocalDate {
fun lengthOfYear(): Int
}
// JVM
actual typealias LocalDate = java.time.LocalDate
![Page 58: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/58.jpg)
Test typealias
expect annotation class Test
actual typealias Test = org.junit.Test
![Page 59: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/59.jpg)
Code structure
![Page 60: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/60.jpg)
build.gradle
apply plugin: 'kotlin-multiplatform'
![Page 61: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/61.jpg)
build.gradle
apply plugin: 'kotlin-multiplatform'
kotlin {
targets {
}
}
![Page 62: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/62.jpg)
build.gradle
apply plugin: 'kotlin-multiplatform'
kotlin {
targets {
fromPreset(presets.jvm, 'jvm')
}
}
![Page 63: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/63.jpg)
build.gradle
apply plugin: 'kotlin-multiplatform'
kotlin {
targets {
fromPreset(presets.jvm, 'jvm')
fromPreset(presets.js, 'js')
}
}
![Page 64: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/64.jpg)
build.gradle
apply plugin: 'kotlin-multiplatform'
kotlin {
targets {
fromPreset(presets.jvm, 'jvm')
fromPreset(presets.js, 'js')
fromPreset(presets.linuxX64, 'linux')
}
}
![Page 65: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/65.jpg)
build.gradle
apply plugin: 'kotlin-multiplatform'
kotlin {
targets {
fromPreset(presets.jvm)
fromPreset(presets.js)
fromPreset(presets.linuxX64, 'linux')
}
}
![Page 66: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/66.jpg)
build.gradle
apply plugin: 'kotlin-multiplatform'
kotlin {
targets {...}
sourceSets {
}
}
![Page 67: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/67.jpg)
build.gradle
apply plugin: 'kotlin-multiplatform'
kotlin {
targets {...}
sourceSets {
commonMain { }
commonTest { }
}
}
![Page 68: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/68.jpg)
build.gradle sourceSets {
commonMain { }
commonTest { }
jvmMain { }
jvmTest { }
jsMain { }
jsTest { }
linuxMain { }
linuxTest { }
}
![Page 69: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/69.jpg)
Project structure
![Page 70: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/70.jpg)
Testing
![Page 71: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/71.jpg)
![Page 72: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/72.jpg)
$ ./gradlew :shared:linuxTest> Configure project :frontend> Configure project :shared> Task :shared:linuxTest[==========] Running 1 tests from 1 test cases.[----------] Global test environment set-up.[----------] 1 tests from DateTest[ RUN ] DateTest.validateBirthday[ OK ] DateTest.validateBirthday (0 ms)[----------] 1 tests from DateTest (0 ms total)
[----------] Global test environment tear-down[==========] 1 tests from 1 test cases ran. (0 ms total)[ PASSED ] 1 tests.
BUILD SUCCESSFUL in 14s3 actionable tasks: 3 executed
![Page 73: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/73.jpg)
build.gradle
commonMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
}
}
commonTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test-common'
implementation 'org.jetbrains.kotlin:kotlin-test-annotations-common'
}
}
![Page 74: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/74.jpg)
build.gradle
jvmMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
}
}
jvmTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test'
implementation 'org.jetbrains.kotlin:kotlin-test-junit'
}
}
![Page 75: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/75.jpg)
build.gradle
jsMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-js'
}
}
jsTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test'
implementation 'org.jetbrains.kotlin:kotlin-test-js'
}
}
![Page 76: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/76.jpg)
Project dependencies
dependencies {
implementation project(':shared')
}
![Page 77: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/77.jpg)
Multiplatform libraries
![Page 78: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/78.jpg)
kotlin.test
![Page 79: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/79.jpg)
kotlin.test
kotlinx.coroutines
![Page 80: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/80.jpg)
kotlin.test
kotlinx.coroutines
kotlinx.serialization
![Page 81: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/81.jpg)
Write your own library!
![Page 82: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/82.jpg)
Publishing
build.gradle apply plugin: 'maven-publish'
Console $ ./gradlew publishToMavenLocal
![Page 83: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/83.jpg)
Use it
![Page 84: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/84.jpg)
Date/JVMactual class Date {
actual fun isValid(): Boolean {
}
}
![Page 85: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/85.jpg)
Date/JVMactual class Date actual constructor(day: Int, month: Int,year:Int){
actual fun isValid(): Boolean {
}
}
![Page 86: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/86.jpg)
Date/JVMactual class Date actual constructor(private val day: Int, private val month: Int, private val year: Int) {
actual fun isValid(): Boolean {
}
}
![Page 87: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/87.jpg)
Date/JVMactual class Date actual constructor(private val day: Int, private val month: Int, private val year: Int) {
actual fun isValid() = try {
val calendar = Calendar.getInstance()
calendar.isLenient = false
calendar.set(year, month - 1, day)
calendar.time
true
} catch (e: Exception) {
false
}
}
![Page 88: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/88.jpg)
Date/JSactual class Date actual constructor(private val day: Int, private val month: Int, private val year: Int) {
actual fun isValid() = moment(year, month, day).isValid()
}
![Page 89: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/89.jpg)
Date/JSactual class Date actual constructor(private val day: Int, private val month: Int, private val year: Int) {
actual fun isValid() = moment(year, month, day).isValid()
}
external interface Moment {
fun isValid(): Boolean
}
fun moment(day: Int, month: Int, year: Int): Moment = definedExternally
![Page 90: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/90.jpg)
There is a bug still…
![Page 91: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/91.jpg)
Bug
fun validate(day: Int, month: Int, year: Int): Boolean {
return Date(year, month, day).isValid()
}
expect class Date(year: Int, month: Int, day: Int) {
fun isValid(): Boolean
}
![Page 92: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/92.jpg)
Fixing a bug
fun validate(day: Int, month: Int, year: Int): Boolean {
return Date(day, month, year).isValid()
}
expect class Date(year: Int, month: Int, day: Int) {
fun isValid(): Boolean
}
![Page 93: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/93.jpg)
Fixing a bug
fun validate(day: Int, month: Int, year: Int): Boolean {
return Date(day, month, year).isValid()
}
expect class Date(day: Int, month: Int, year: Int) {
fun isValid(): Boolean
}
![Page 94: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/94.jpg)
inline classes
inline class Day(val value: Int)
inline class Month(val value: Int)
inline class Year(val value: Int)
![Page 95: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/95.jpg)
inline classes
fun validate(day: Day, month: Month, year: Year): Boolean {
return Date(day, month, year).isValid()
}
expect class Date(day: Day, month: Month, year: Year) {
fun isValid(): Boolean
}
inline class Day(val value: Int)
inline class Month(val value: Int)
inline class Year(val value: Int)
![Page 96: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/96.jpg)
Compile-time type checks
@Test fun validateBirthday() {
assertFalse(validate(Day(3), Month(31), Year(1986)))
assertTrue(validate(Month(31), Day(3), Year(1986)))
} Type mismatchRequired: DayFound: Month
![Page 97: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/97.jpg)
Recap
Write once, reuse everywhere
![Page 98: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/98.jpg)
Recap
Write once, reuse everywhere
Integrate with platform-specific libraries
![Page 99: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/99.jpg)
Recap
Write once, reuse everywhere
Integrate with platform-specific libraries
Use all language features on all platforms
![Page 100: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/100.jpg)
![Page 101: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/101.jpg)
![Page 103: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/103.jpg)
Sample code
github.com/kropp/kotlin-multiplatform-sample
![Page 104: victor.kropp.name Multiplatform projects with @kropp ... Toulouse 2018... · Kotlin/Native Kotlin/JVM Kotlin/JS. Using the same language across all platforms All team members speak](https://reader034.vdocuments.mx/reader034/viewer/2022042622/5f8c6380f77b1a02b07e975c/html5/thumbnails/104.jpg)
Links
Multiplatform projects documentation kotl.in/multiplatform Configuration samples github.com/h0tk3y/k-new-mpp-samples
Code from this presentationgithub.com/kropp/kotlin-multiplatform-sample