Using Gradle Metadata for a Kotlin multiplatform project
Data2viz is a Kotlin multimodule/multiplatform library. That means a lot of dependencies and artifacts. Let’s see how Gradle Metadata simplifies the dependencies management.
Before Gradle Metadata :
Android project
dependencies {
...
api "io.data2viz.d2v:scale-jvm:$data2viz_version"
api "io.data2viz.d2v:viz-android:$data2viz_version"
}
Kotlin/JS project
dependencies {
...
api "io.data2viz.d2v:scale-js:$data2viz_version"
api "io.data2viz.d2v:viz-js:$data2viz_version"
}
After Gradle Metadata, for all platforms:
dependencies {
...
api "io.data2viz.d2v:scale:$data2viz_version"
api "io.data2viz.d2v:viz:$data2viz_version"
}
Ktor vs Axios for Kotlin/JS remote calls
For the vast majority of Kotlin/JS applications, you need to do remote calls. You can perform your calls from Kotlin/JS using the fetch API, but using a third party library simplifies the code. I describe in this post the pros and cons of two natural solutions.
Should you use Ktor-client and Axios for your Kotlin/JS calls?
Well, it depends if you care about the distribution size of your app.
Introducing Kotlinx.html-plugin
We love Kotlin, we love DSLs, and when we have to develop a web application, we naturally want to use Kotlinx.html. It proposes a nice DSL to generate HTML fragments on the server using Kotlin/JVM or the browser with Kotlin/JS.