It is template for multiplatform project which you can use for simple start of your own library
Go to file
InsanusMokrassar 1d2cf6025d
Merge pull request #10 from InsanusMokrassar/renovate/kotlin.serialization
Update dependency org.jetbrains.kotlinx:kotlinx-serialization-json to v1.7.3
2024-09-26 08:00:17 +06:00
.github/workflows Update build.yml 2023-11-02 19:23:14 +06:00
.templates update templates 2024-01-17 19:35:06 +06:00
gradle Update dependency org.jetbrains.kotlinx:kotlinx-serialization-json to v1.7.3 2024-09-19 17:02:44 +00:00
lib update dependencies 2024-01-17 19:15:48 +06:00
.gitignore add .kotlin in .gitignore 2024-08-14 16:31:34 +06:00
build.gradle updates and migration onto toml 2022-01-29 21:47:34 +06:00
defaultAndroidSettings.gradle update template 2024-08-14 16:23:54 +06:00
extensions.gradle add mppJsProject 2021-03-07 21:22:27 +06:00
gradle.properties updates and migration onto toml 2022-01-29 21:47:34 +06:00
gradlew init 2020-12-02 21:50:52 +06:00
gradlew.bat init 2020-12-02 21:50:52 +06:00
LICENSE Initial commit 2020-12-02 19:34:24 +06:00
mppAndroidProject.gradle Update mppAndroidProject.gradle 2023-11-02 19:25:34 +06:00
mppJavaProject.gradle Update mppJavaProject.gradle 2023-11-02 19:20:45 +06:00
mppJsProject.gradle update template 2024-08-14 16:23:54 +06:00
mppProjectWithSerialization.gradle update template 2024-08-14 16:23:54 +06:00
README.md update android part 2022-11-21 21:21:05 +06:00
renovate.json Add renovate.json 2024-09-06 10:37:23 +00:00
settings.gradle Update settings.gradle 2023-11-02 19:22:12 +06:00

How to use

That is a template for Kotlin Multiplatform Projects. How to use it:

  • Create your repository from this template
  • Add local.properties file in case you plan to use Android target (you must set up location of SDK, it will not be tracked by git and it is correct behaviour). In the snippet below you may see approximate content of local.properties file:
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=/your/path/to/android/sdk
  • Replace in a whole project project_group by your group
  • Replace in a whole project project_name by your ROOT project name
  • Update your subproject packages. It is not critical, but recommended especially in case you plan to publish your library

Subprojects

In this template there is only one subproject with name lib. You are always able to rename it, but remember that in this case you must rename it in settings.gradle file.

JVM sources in Android target

By default JVM code is not included in Android target. In case you wish to include JVM sources in Android build, use next method in the sourceSets section of your build.gradle:

kotlin {
    sourceSets {
        // Some other code
        androidMain {
            // Some other code (like dependencies)
            dependsOn jvmMain
        }
    }
}

In case when you need to be sure that JVM sources are not included in Android part, just remove line with dependsOn jvmMain

Types of projects

mppProjectWithSerialization

This type of preset have JVM, JS and Android targets and available using apply from: "$mppProjectWithSerializationPresetPath". Template for project with this preset looks like next snippet:

plugins {
    id "org.jetbrains.kotlin.multiplatform"
    id "org.jetbrains.kotlin.plugin.serialization"
    id "com.android.library"
}

apply from: "$mppProjectWithSerializationPresetPath"

// The code below is optional

kotlin {
    sourceSets {
        commonMain {
            dependencies {
                // common dependencies
            }
        }
        commonTest {
            dependencies {
                // common test dependencies
            }
        }
        jvmMain {
            dependencies {
                // jvm dependencies
            }
        }
        jvmTest {
            dependencies {
                // jvm test dependencies
            }
        }
        jsMain {
            dependencies {
                // js dependencies
            }
        }
        jsTest {
            dependencies {
                // js test dependencies
            }
        }
        androidMain {
            dependencies {
                // android dependencies
            }
        }
        androidTest {
            dependencies {
                // android test dependencies
            }
        }
    }
}

mppJavaProject

This type of preset have only JVM target and available using apply from: "$mppJavaProjectPresetPath". Template for project with this preset looks like next snippet:

plugins {
    id "org.jetbrains.kotlin.multiplatform"
}

apply from: "$mppJavaProjectPresetPath"

// The code below is optional

kotlin {
    sourceSets {
        commonMain {
            dependencies {
                // common dependencies
            }
        }
        commonTest {
            dependencies {
                // common test dependencies
            }
        }
        jvmMain {
            dependencies {
                // jvm dependencies
            }
        }
        jvmTest {
            dependencies {
                // jvm test dependencies
            }
        }
    }
}

mppJsProject

This type of preset have only JS target and available using apply from: "mppJsProjectPresetPath". Template for project with this preset looks like next snippet:

plugins {
    id "org.jetbrains.kotlin.multiplatform"
}

apply from: "$mppJsProjectPresetPath"

// The code below is optional

kotlin {
    sourceSets {
        commonMain {
            dependencies {
                // common dependencies
            }
        }
        commonTest {
            dependencies {
                // common test dependencies
            }
        }
        jsMain {
            dependencies {
                // jvm dependencies
            }
        }
        jsTest {
            dependencies {
                // jvm test dependencies
            }
        }
    }
}

mppAndroidProject

This type of preset have only Android target and available using apply from: "$mppAndroidProjectPresetPath". Template for project with this preset looks like next snippet:

plugins {
    id "org.jetbrains.kotlin.multiplatform"
    id "com.android.library"
}

apply from: "$mppAndroidProjectPresetPath"

// The code below is optional

kotlin {
    sourceSets {
        commonMain {
            dependencies {
                // common dependencies
            }
        }
        commonTest {
            dependencies {
                // common test dependencies
            }
        }
        androidMain {
            dependencies {
                // android dependencies
            }
        }
        androidTest {
            dependencies {
                // android test dependencies
            }
        }
    }
}