Racci
12/11/2022, 3:50 AMAdam S
12/11/2022, 3:47 PMAdam S
12/11/2022, 3:48 PMRacci
12/12/2022, 12:30 AMAdam S
12/12/2022, 6:57 PMAdam S
12/12/2022, 7:12 PM:my-project-core
- the core project, with all the variants, and Paperweight specific code if you like, but no Paperweight plugin
• :my-project-papermc-variant-a
- some variant of the core - apply the Paperweight plugin in here
• :my-project-papermc-variant-b
etc
to help out with that you could create a buildSrc convention plugin, and in that just register all the Kotlin and Paperweight targets and their links - nothing complicated.
//$projectRoot/buildSrc/src/main/kotlin/kotlin-multiplatform-paperweight.gradle.kts
plugins {
kotlin("multiplatform") // version must be set by a dependency in $projectRoot/buildSrc/build.gradle.kts
}
kotlin {
// set up targets...
jvm()
// create source sets for the 'core' and 'variants' each variant
sourceSets {
val commonMain by getting {}
val paperweightMain by creating { dependsOn(commonMain) }
val paperweightVariantA by creating { dependsOn(paperweight) }
val paperweightVariantB by creating { dependsOn(paperweight) }
val paperweightVariantC by creating { dependsOn(paperweight) }
}
}
Then you could apply kotlin-multiplatform-paperweight
to each subproject, and Gradle would generate the Kotlin DSL accessors, so you could easily add dependencies on each project.
// $projectRoot/my-project-papermc-variant-a/build.gradle.kts
plugins {
`kotlin-multiplatform-paperweight`
}
// apply any variant-specific Paperweight Gradle config
// ...
kotlin {
// can set up extra targets if necessary, but jvm() is provided by the convention
sourceSets {
paperweightVariantA { // can use the Kotlin DSL generated accessor
dependencies {
implementation(projects(":my-project-core"))
}
}
}
}
Adam S
12/12/2022, 7:15 PMRacci
12/13/2022, 12:04 AM