set up convention plugins
- tidy up build scripts to use convention plugins - use centralised repo definition - tidy up some of the build config
This commit is contained in:
parent
34b69a7d1f
commit
93e113fa69
14 changed files with 498 additions and 141 deletions
|
@ -0,0 +1,45 @@
|
|||
package buildsrc.conventions.lang
|
||||
|
||||
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
|
||||
|
||||
|
||||
/**
|
||||
* Base configuration for all Kotlin/Multiplatform conventions.
|
||||
*
|
||||
* This plugin does not enable any Kotlin target. To enable a target in a subproject, prefer applying specific Kotlin
|
||||
* target convention plugins.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id("buildsrc.conventions.base")
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(11)
|
||||
|
||||
targets.configureEach {
|
||||
compilations.configureEach {
|
||||
kotlinOptions {
|
||||
// nothin' yet
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// configure all Kotlin/JVM Tests to use JUnit
|
||||
targets.withType<KotlinJvmTarget>().configureEach {
|
||||
testRuns.configureEach {
|
||||
executionTask.configure {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.configureEach {
|
||||
languageSettings {
|
||||
// languageVersion =
|
||||
// apiVersion =
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package buildsrc.conventions.lang
|
||||
|
||||
/** conventions for a Kotlin/JS subproject */
|
||||
|
||||
plugins {
|
||||
id("buildsrc.conventions.lang.kotlin-multiplatform-base")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
targets {
|
||||
js(IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
relocateKotlinJsStore()
|
|
@ -0,0 +1,11 @@
|
|||
package buildsrc.conventions.lang
|
||||
|
||||
plugins {
|
||||
id("buildsrc.conventions.lang.kotlin-multiplatform-base")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package buildsrc.conventions.lang
|
||||
|
||||
/** conventions for a Kotlin/Native subproject */
|
||||
|
||||
plugins {
|
||||
id("buildsrc.conventions.lang.kotlin-multiplatform-base")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
||||
// Native targets all extend commonMain and commonTest.
|
||||
//
|
||||
// Some targets (ios, tvos, watchos) are shortcuts provided by the Kotlin DSL, that
|
||||
// provide additional targets, except for 'simulators' which must be defined manually.
|
||||
// https://kotlinlang.org/docs/multiplatform-share-on-platforms.html#use-target-shortcuts
|
||||
//
|
||||
// common/
|
||||
// └── native/
|
||||
// ├── linuxX64
|
||||
// ├── mingwX64
|
||||
// ├── macosX64
|
||||
// ├── macosArm64
|
||||
// ├── ios/ (shortcut)
|
||||
// │ ├── iosArm64
|
||||
// │ ├── iosX64
|
||||
// │ └── iosSimulatorArm64
|
||||
// ├── tvos/ (shortcut)
|
||||
// │ ├── tvosArm64
|
||||
// │ ├── tvosX64
|
||||
// │ └── tvosSimulatorArm64Main
|
||||
// └── watchos/ (shortcut)
|
||||
// ├── watchosArm32
|
||||
// ├── watchosArm64
|
||||
// ├── watchosX64
|
||||
// └── watchosSimulatorArm64Main
|
||||
|
||||
targets {
|
||||
linuxX64()
|
||||
|
||||
mingwX64()
|
||||
|
||||
macosX64()
|
||||
macosArm64()
|
||||
|
||||
// https://kotlinlang.org/docs/multiplatform-share-on-platforms.html#use-target-shortcuts
|
||||
ios() // iosArm64, iosX64
|
||||
watchos() // watchosArm32, watchosArm64, watchosX64
|
||||
tvos() // tvosArm64, tvosX64
|
||||
|
||||
iosSimulatorArm64()
|
||||
tvosSimulatorArm64()
|
||||
watchosSimulatorArm64()
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
sourceSets {
|
||||
val commonMain by getting {}
|
||||
val commonTest by getting {}
|
||||
|
||||
val nativeMain by creating { dependsOn(commonMain) }
|
||||
val nativeTest by creating { dependsOn(commonTest) }
|
||||
|
||||
// Linux
|
||||
val linuxX64Main by getting { dependsOn(nativeMain) }
|
||||
val linuxX64Test by getting { dependsOn(nativeTest) }
|
||||
|
||||
// Windows - MinGW
|
||||
val mingwX64Main by getting { dependsOn(nativeMain) }
|
||||
val mingwX64Test by getting { dependsOn(nativeTest) }
|
||||
|
||||
// Apple - macOS
|
||||
val macosArm64Main by getting { dependsOn(nativeMain) }
|
||||
val macosArm64Test by getting { dependsOn(nativeTest) }
|
||||
|
||||
val macosX64Main by getting { dependsOn(nativeMain) }
|
||||
val macosX64Test by getting { dependsOn(nativeTest) }
|
||||
|
||||
// Apple - iOS
|
||||
val iosMain by getting { dependsOn(nativeMain) }
|
||||
val iosTest by getting { dependsOn(nativeTest) }
|
||||
|
||||
// val iosSimulatorArm64Main by getting { dependsOn(iosMain) }
|
||||
// val iosSimulatorArm64Test by getting { dependsOn(iosTest) }
|
||||
|
||||
// // Apple - tvOS
|
||||
// val tvosMain by getting { dependsOn(nativeMain) }
|
||||
// val tvosTest by getting { dependsOn(nativeTest) }
|
||||
//
|
||||
// val tvosSimulatorArm64Main by getting { dependsOn(tvosMain) }
|
||||
// val tvosSimulatorArm64Test by getting { dependsOn(tvosTest) }
|
||||
//
|
||||
// // Apple - watchOS
|
||||
// val watchosMain by getting { dependsOn(nativeMain) }
|
||||
// val watchosTest by getting { dependsOn(nativeTest) }
|
||||
//
|
||||
// val watchosSimulatorArm64Main by getting { dependsOn(watchosMain) }
|
||||
// val watchosSimulatorArm64Test by getting { dependsOn(watchosTest) }
|
||||
|
||||
// val iosArm32Main by getting { dependsOn(desktopMain) }
|
||||
// val iosArm32Test by getting { dependsOn(nativeTest) }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package buildsrc.conventions.lang
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
|
||||
|
||||
/**
|
||||
* `kotlin-js` and `kotlin-multiplatform` plugins adds a directory in the root-dir for the Yarn
|
||||
* lockfile. That's a bit annoying. It's a little neater if it's in the Gradle dir, next to the
|
||||
* version catalog.
|
||||
*/
|
||||
internal fun Project.relocateKotlinJsStore() {
|
||||
afterEvaluate {
|
||||
rootProject.extensions.configure<YarnRootExtension> {
|
||||
lockFileDirectory = project.rootDir.resolve("gradle/kotlin-js-store")
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue