Skip to content

Commit

Permalink
doc: update the multiplatform installation guide
Browse files Browse the repository at this point in the history
Instead of registering the KSP plugin for each target, we ask the user to configure it for the common one.
  • Loading branch information
nesk committed Sep 11, 2024
1 parent da0bf89 commit 2c1a7af
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions documentation/topics/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@ project structure.
<step>
Add KSP to your plugin list; make sure to <a href="https://github.com/google/ksp/releases">use the appropriate
version</a>, depending on the Kotlin version you're using.
<br/>
<code-block lang="kotlin">
plugins {
kotlin("jvm") version "2.0.10"
id("com.google.devtools.ksp") version "2.0.10-1.0.24"
kotlin("jvm") version "2.0.20"
id("com.google.devtools.ksp") version "2.0.20-1.0.25"
}
</code-block>
</step>

<step>
Add the dependencies and register the compiler plugin through KSP.
<br/>
<code-block lang="kotlin">
dependencies {
implementation("dev.nesk.akkurate:akkurate-core:%version%")
Expand All @@ -40,37 +38,42 @@ dependencies {
<step>
Add KSP to your plugin list; make sure to <a href="https://github.com/google/ksp/releases">use the appropriate
version</a>, depending on the Kotlin version you're using.
<br/>
<code-block lang="kotlin">
plugins {
kotlin("multiplatform") version "2.0.10"
id("com.google.devtools.ksp") version "2.0.10-1.0.24"
kotlin("multiplatform") version "2.0.20"
id("com.google.devtools.ksp") version "2.0.20-1.0.25"
}
</code-block>
</step>

<step>
Add the dependencies to the appropriate targets (change them to your liking).
<br/>
Register the compiler plugin for the common target:
<code-block lang="kotlin">
sourceSets {
jvmMain.dependencies {
implementation("dev.nesk.akkurate:akkurate-core:%version%")
}
jsMain.dependencies {
implementation("dev.nesk.akkurate:akkurate-core:%version%")
dependencies {
add("kspCommonMainMetadata", "dev.nesk.akkurate:akkurate-ksp-plugin:%version%")
}
tasks {
withType&lt;KotlinCompilationTask&lt;*&gt;&gt;().configureEach {
if (name != "kspCommonMainKotlinMetadata") {
dependsOn("kspCommonMainKotlinMetadata")
}
}
}
</code-block>
</step>

<step>
Register the compiler plugin for the same targets.
<br/>
Configure the <code>commonMain</code> source set:
<code-block lang="kotlin">
dependencies {
add("kspJvm", "dev.nesk.akkurate:akkurate-ksp-plugin:%version%")
add("kspJs", "dev.nesk.akkurate:akkurate-ksp-plugin:%version%")
sourceSets {
commonMain {
dependencies {
// Add %product% dependencies
implementation("dev.nesk.akkurate:akkurate-core:%version%")
}
// Include the code generated by the KSP plugin
kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin")
}
}
</code-block>
</step>
Expand Down

0 comments on commit 2c1a7af

Please sign in to comment.