|
1 |
| -import internal.InternalComposeSupportPlugin |
2 |
| -import org.jetbrains.kotlin.gradle.dsl.KotlinCompile |
| 1 | +import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl |
3 | 2 | import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile
|
| 3 | +import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask |
4 | 4 |
|
5 |
| -group "com.example" |
6 |
| -version "1.0-SNAPSHOT" |
| 5 | +//group "com.example" |
| 6 | +//version "1.0-SNAPSHOT" |
| 7 | + |
| 8 | +fun Project.disableYarnLockMismatchReport() { |
| 9 | + plugins.withType<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin> { |
| 10 | + the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().apply { |
| 11 | + yarnLockMismatchReport = org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport.NONE |
| 12 | + } |
| 13 | + } |
| 14 | +} |
7 | 15 |
|
8 | 16 | allprojects {
|
9 | 17 | repositories {
|
10 | 18 | google()
|
11 | 19 | mavenCentral()
|
12 | 20 | maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
|
13 | 21 | maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/") // to test with kotlin dev builds
|
14 |
| - // mavenLocal() |
| 22 | + |
| 23 | + maven("https://packages.jetbrains.team/maven/p/kt/dev") |
| 24 | + maven("https://redirector.kotlinlang.org/maven/dev") |
| 25 | +// mavenLocal() |
15 | 26 | }
|
16 | 27 |
|
17 |
| - // Apply here for all subprojects instead of applying in each build.gradle.kts separately. |
18 |
| - // It applies the compiler plugin |
19 |
| - this.apply<InternalComposeSupportPlugin>() |
| 28 | + disableYarnLockMismatchReport() |
| 29 | +} |
20 | 30 |
|
21 |
| - afterEvaluate { |
22 |
| - val pluginOptionPrefix = "plugin:androidx.compose.compiler.plugins.kotlin:" |
23 |
| - val project = this |
24 |
| - val kotlinVersion = project.properties["kotlin.version"] as? String |
| 31 | +plugins { |
| 32 | + kotlin("multiplatform").version(libs.versions.kotlin).apply(false) |
| 33 | + alias(libs.plugins.compose.compiler).apply(false) |
| 34 | +} |
25 | 35 |
|
26 |
| - project.tasks.withType(KotlinCompile::class.java).configureEach { |
27 |
| - kotlinOptions.apply { |
28 |
| - freeCompilerArgs += |
29 |
| - listOf( |
30 |
| - "-P", |
31 |
| - "${pluginOptionPrefix}suppressKotlinVersionCompatibilityCheck=$kotlinVersion" |
32 |
| - ) |
| 36 | +subprojects { |
| 37 | + apply(plugin = "org.jetbrains.kotlin.multiplatform") |
33 | 38 |
|
34 |
| - } |
| 39 | + configure<org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension> { |
| 40 | + jvm("desktop") |
| 41 | + applyDefaultHierarchyTemplate() |
| 42 | + js(IR) { |
| 43 | +// browser() |
| 44 | + nodejs() // Commented to save a bit of CI time. Testing in a browser should be enough. |
35 | 45 | }
|
36 |
| - |
37 |
| - tasks.withType<KotlinJsCompile>().configureEach { |
38 |
| - kotlinOptions.freeCompilerArgs += listOf( |
39 |
| - "-Xklib-enable-signature-clash-checks=false", |
40 |
| - ) |
| 46 | + @OptIn(ExperimentalWasmDsl::class) |
| 47 | + wasmJs { |
| 48 | + d8 {} |
41 | 49 | }
|
42 | 50 |
|
43 |
| - tasks.withType<KotlinCompile<*>>().configureEach { |
44 |
| - kotlinOptions.freeCompilerArgs += "-Xpartial-linkage=disable" |
45 |
| - } |
46 |
| - } |
47 |
| - disableYarnLockMismatchReport() |
48 |
| -} |
| 51 | + iosArm64() |
| 52 | + iosSimulatorArm64() |
| 53 | + iosX64() |
| 54 | + macosX64() |
| 55 | + macosArm64() |
| 56 | + // We use linux agents on CI. So it doesn't run the tests, but it builds the klib anyway which is time consuming. |
| 57 | + // if (project.isMingwX64Enabled) mingwX64() |
| 58 | + linuxX64() |
49 | 59 |
|
50 |
| -plugins { |
51 |
| - kotlin("multiplatform") apply false |
52 |
| -} |
| 60 | + sourceSets { |
| 61 | + val commonMain by getting { |
| 62 | + val projectName = project.name |
| 63 | + dependencies { |
| 64 | + if (projectName != "common") { |
| 65 | + implementation(project(":common")) |
| 66 | + } |
53 | 67 |
|
54 |
| -fun Project.disableYarnLockMismatchReport() { |
55 |
| - plugins.withType<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin> { |
56 |
| - the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().apply { |
57 |
| - yarnLockMismatchReport = org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport.NONE |
| 68 | + if (projectName.endsWith("-main")) { |
| 69 | + implementation(project(":" + projectName.replace("-main", "-lib"))) |
| 70 | + } |
| 71 | + } |
| 72 | + } |
58 | 73 | }
|
| 74 | + |
| 75 | + targets |
| 76 | + .filter { it.name != "desktop" } // Exclude JVM target |
| 77 | + .forEach { target -> |
| 78 | + target.compilations.all { |
| 79 | + compileTaskProvider.configure{ |
| 80 | + compilerOptions { |
| 81 | + freeCompilerArgs.add("-Xpartial-linkage=disable") |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | + } |
59 | 86 | }
|
60 | 87 | }
|
0 commit comments