Creating a shared module

At the core of Kotlin multiplatform is shared code. To start building our project, we'll begin by creating a new Gradle module that will contain our shared Kotlin code:

  1. First, we'll create a new, empty Gradle project within IntelliJ. When we're finished, we should have a project structure that looks similar to the following:
  root     .gradle/      .idea/     gradle/     build.gradle     gradlew      gradlew.bat     settings.gradle
  1. We now want to update build.gradle so that we can define classpath dependencies, which will be needed by other modules. The resulting build.gradle file should look something like this:
buildscript {    ext {        kotlin_version = '1.3.31'    }    repositories {        google()        jcenter()        mavenCentral()    }    dependencies {        classpath ...

Get Mastering Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.