This repo shows a Gradle multi-project build structure that uses the Kotlin Multiplatform to build a JVM, JS, Desktop and Compose Web (wasm) applications.
# Mac OS
$ curl -s "https://get.sdkman.io" | bash
$ sdk i java 23.ea-open
$ sdk u java 23.ea-open
$ ./gradlew buildAndPublish
Run Modules
# Kotlin JVM
$ ./gradlew :common:run
$ ./gradlew :backend:jvm:run
$ docker run \
-it \
--rm \
--pull always \
--workdir /app \
--publish 8080:8080 \
--publish 8081:8081 \
--name kotlin-mpp-playground \
--mount type=bind,source=$(pwd),destination=/app,readonly \
openjdk:23-slim /bin/bash -c "printenv && nohup jwebserver -b 0.0.0.0 -p 8081 -d / & backend/jvm/build/libs/jvm-app"
$ ./gradlew :backend:jvm:jibDockerBuild
$ docker run -it --rm --name jvm-app -p 8080:8080 -p 9898:9898 sureshg/jvm
# Kotlin JS
$ ./gradlew :web:jsBrowserProductionRun -t
$ ./gradlew kotlinUpgradeYarnLock
# Kotlin Native
$ ./gradlew :backend:native:macOsUniversalBinary
$ ./gradlew :backend:native:jibDockerBuild
$ docker run -it --rm --name native-app sureshg/native
# Kobweb
$ kobweb run -p compose/web
$ ./gradlew :compose:web:kobwebStart -t
$ ./gradlew :compose:web:kobwebStop
# Compose Desktop
$ ./gradlew :compose:desktop:runDistributable
$ ./gradlew :compose:desktop:packageDistributionForCurrentOS
$ ./gradlew :compose:desktop:suggestModules
# Publishing
$ ./gradlew publishAllPublicationsToLocalRepository
# Benchmark
$ ./gradlew :benchmark:benchmark
# Dependencies
$ ./gradlew :backend:jvm:listResolvedArtifacts
$ ./gradlew createModuleGraph
$ ./gradlew generateChangelog
# Clean
$ ./gradlew cleanAll
# Gradle Best Practices
$ ./gradlew -p gradle/build-logic :common-plugins:bestPracticesBaseline
$ ./gradlew checkBuildLogicBestPractices
# GitHub Actions lint
$ actionlint
- π Kotlin Multiplatform Package Search
- π¨ Compose Multiplatform Template
- π Compose Lint Rules
%%{
init: {
'theme': 'neutral'
}
}%%
graph LR
subgraph backend
jvm
native
end
subgraph compose
desktop
web
end
subgraph dep-mgmt
bom
catalog
end
subgraph meta
compiler
ksp
end
subgraph compiler
compiler
plugin
end
subgraph ksp
ksp
processor
end
plugin --> common
benchmark --> common
web --> common
desktop --> common
client --> common
native --> common
processor --> common
jvm --> common
jvm --> web