Creating a multiplatform project without an IDE

We can manually configure the project with Gradle by performing the following steps:

  1. Create a Gradle project.
  2. Add the Kotlin Gradle plugin to the build script build.gradle file:classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version".
  3. Apply the kotlin-platform-common plugin to the common module.
  4. Add the kotlin-stdlib-common dependency to the common module.
  5. Apply the  kotlin-platform-jvm plugin for the JVM platform, and the kotlin-platform-js plugin for the JS platform.

The complete build.gradle file for a common module with Kotlin 1.2-Beta2 is as follows:

    buildscript {
      ext.kotlin_version = '1.2-Beta2'

      repositories {
        maven { url 'http://dl.bintray.com/kotlin/kotlin-eap-1.2' } ...

Get Kotlin Blueprints 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.