kmp-readiness

Introduction: Gradle Plugin that determines if modules are Kotlin Multiplatform (KMP) ready. "KMP Ready" means that the code is Kotlin Multiplatform compatible.
More: Author   ReportBugs   
Tags:

LICENSE Latest Snapshot CI

Decisioning Logic

Positive Signals ✅

Only Kotlin .kt Source Files

Using Kotlin JVM Plugin

Uses the Kotlin Multiplatform Plugin

  • NOTE: We could check the configuration in the future to see if it has multiple targets if deemed important.

Negative Signals ❌

Are there any java imports in the source files?

Imports starting with java., etc.

kmpReady Gradle Task

Could be applied to a specific module or the root so that all modules are scanned.

Run the kmpReady task and get a result like this:

┌─────────────────────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Module                          │ KMP Ready Result                                                                                                      │
├─────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ :samples:android_app            │ Not KMP Ready                                                                                                         │
│                                 │ ---                                                                                                                   │
│                                 │ ✅ HasOnlyMultiplatformCompatibleDependencies                                                                          │
│                                 │ ✅ HasOnlyKotlinFiles                                                                                                  │
│                                 │ ❌ IsAndroidApplication                                                                                                │
│                                 │ ❌ DoesNotHaveKotlinJvmOrMultiplatformPlugin                                                                           │
│                                 │ Applied Plugins                                                                                                       │
│                                 │  * com.android.build.gradle.AppPlugin                                                                                 │
│                                 │  * com.android.build.gradle.api.AndroidBasePlugin                                                                     │
│                                 │  * com.android.build.gradle.internal.plugins.AppPlugin                                                                │
│                                 │  * com.android.build.gradle.internal.plugins.VersionCheckPlugin                                                       │
│                                 │  * com.dropbox.gradle.plugins.dependencyguard.DependencyGuardPlugin                                                   │
│                                 │  * org.gradle.kotlin.dsl.provider.plugins.KotlinScriptBasePlugin                                                      │
│                                 │                                                                                                                       │
│                                 │                                                                                                                       │
├─────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ :samples:android_lib            │ Not KMP Ready                                                                                                         │
│                                 │ ---                                                                                                                   │
│                                 │ ✅ HasOnlyMultiplatformCompatibleDependencies                                                                          │
│                                 │ ✅ HasOnlyKotlinFiles                                                                                                  │
│                                 │ ❌ IsAndroidLibrary                                                                                                    │
│                                 │ ❌ UsesJavaBaseImports                                                                                                 │
│                                 │ Java Base Library Usages                                                                                              │
│                                 │  * import java.util.Date                                                                                              │
│                                 │    /Users/samedwards/src/kmp-readiness/samples/android_lib/src/main/java/kmp4free/samples/android.lib/AndroidLib.kt:3 │
│                                 │ ❌ DoesNotHaveKotlinJvmOrMultiplatformPlugin                                                                           │
│                                 │ Applied Plugins                                                                                                       │
│                                 │  * com.android.build.gradle.LibraryPlugin                                                                             │
│                                 │  * com.android.build.gradle.api.AndroidBasePlugin                                                                     │
│                                 │  * com.android.build.gradle.internal.plugins.LibraryPlugin                                                            │
│                                 │  * com.android.build.gradle.internal.plugins.VersionCheckPlugin                                                       │
│                                 │  * org.gradle.kotlin.dsl.provider.plugins.KotlinScriptBasePlugin                                                      │
│                                 │  * org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper                                                      │
│                                 │                                                                                                                       │
│                                 │                                                                                                                       │
├─────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ :samples:jvm                    │ Not KMP Ready                                                                                                         │
│                                 │ ---                                                                                                                   │
│                                 │ ✅ HasOnlyKotlinFiles                                                                                                  │
│                                 │ ✅ KotlinPluginEnabled                                                                                                 │
│                                 │ ❌ IncompatibleDependencies                                                                                            │
│                                 │ * com.squareup.okhttp3:okhttp:4.9.3                                                                                   │
│                                 │ ❌ UsesJavaBaseImports                                                                                                 │
│                                 │ Java Base Library Usages                                                                                              │
│                                 │  * import java.util.Arrays                                                                                            │
│                                 │    /Users/samedwards/src/kmp-readiness/samples/jvm/src/main/java/kmp4free/samples/JvmLib.kt:3                         │
│                                 │  * val instant: java.time.Instant? = null                                                                             │
│                                 │    /Users/samedwards/src/kmp-readiness/samples/jvm/src/main/java/kmp4free/samples/JvmLib.kt:9                         │
│                                 │                                                                                                                       │
│                                 │                                                                                                                       │
├─────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ :samples:jvm_kmp4free           │ Not KMP Ready                                                                                                         │
│                                 │ ---                                                                                                                   │
│                                 │ ✅ HasOnlyMultiplatformCompatibleDependencies                                                                          │
│                                 │ ✅ KotlinPluginEnabled                                                                                                 │
│                                 │ ❌ HasJavaFiles                                                                                                        │
│                                 │  * /Users/samedwards/src/kmp-readiness/samples/jvm_kmp4free/src/main/java/kmp4free/samples/ThisIsAJavaClass.java      │
│                                 │                                                                                                                       │
│                                 │                                                                                                                       │
├─────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ :samples:multiplatform          │ KMP Ready                                                                                                             │
│                                 │ ---                                                                                                                   │
│                                 │ ✅ HasOnlyMultiplatformCompatibleDependencies                                                                          │
│                                 │ ✅ HasOnlyKotlinFiles                                                                                                  │
│                                 │ ✅ MultiplatformPluginAlreadyEnabled                                                                                   │
│                                 │                                                                                                                       │
│                                 │                                                                                                                       │
├─────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ :samples:multiplatform_kmp4free │ KMP Ready                                                                                                             │
│                                 │ ---                                                                                                                   │
│                                 │ ✅ HasOnlyMultiplatformCompatibleDependencies                                                                          │
│                                 │ ✅ HasOnlyKotlinFiles                                                                                                  │
│                                 │ ✅ KotlinPluginEnabled                                                                                                 │
│                                 │                                                                                                                       │
│                                 │                                                                                                                       │
└─────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Info/Debug Logging

Just pass use the info flag like ./gradlew kmpReady --info when you run the Gradle task and all the information collected that is used for decisioning is printed. Warning: This can be a TON of info on a large project.

Plugin Installation

Add the Snapshot Repo in your project's settings.gradle.kts

pluginManagement {
    repositories {
        // ...
        maven { url = "https://s01.oss.sonatype.org/content/repositories/snapshots/" }
    }
}

Add the Plugin on your project's build.gradle

plugins {
    id("com.handstandsam.kmp-ready") version "0.1.0-SNAPSHOT"
}
Apps
About Me
GitHub: Trinea
Facebook: Dev Tools