|
| 1 | +import com.vanniktech.maven.publish.JavadocJar |
| 2 | +import com.vanniktech.maven.publish.KotlinMultiplatform |
| 3 | +import com.vanniktech.maven.publish.MavenPublishBaseExtension |
| 4 | +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget |
| 5 | + |
| 6 | +plugins { |
| 7 | + kotlin("multiplatform") |
| 8 | + id("com.android.library") |
| 9 | + id("org.jetbrains.dokka") |
| 10 | + id("com.vanniktech.maven.publish.base") |
| 11 | +} |
| 12 | + |
| 13 | +kotlin { |
| 14 | + androidTarget { |
| 15 | + publishLibraryVariants("release") |
| 16 | + } |
| 17 | + jvm() |
| 18 | + js(IR) { |
| 19 | + browser() |
| 20 | + nodejs() |
| 21 | + } |
| 22 | + |
| 23 | + macosX64() |
| 24 | + macosArm64() |
| 25 | + iosX64() |
| 26 | + iosArm64() |
| 27 | + iosSimulatorArm64() |
| 28 | + watchosArm32() |
| 29 | + watchosArm64() |
| 30 | + watchosSimulatorArm64() |
| 31 | + watchosX64() |
| 32 | + tvosArm64() |
| 33 | + tvosSimulatorArm64() |
| 34 | + tvosX64() |
| 35 | + |
| 36 | + sourceSets { |
| 37 | + all { |
| 38 | + languageSettings.optIn("kotlin.RequiresOptIn") |
| 39 | + } |
| 40 | + matching { it.name.endsWith("Test") }.all { |
| 41 | + languageSettings { |
| 42 | + optIn("kotlin.RequiresOptIn") |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + val commonMain by sourceSets.getting { |
| 47 | + dependencies { |
| 48 | + api(libs.kotlinx.coroutines.core) |
| 49 | + api(projects.common) |
| 50 | + } |
| 51 | + } |
| 52 | + val commonTest by sourceSets.getting { |
| 53 | + dependencies { |
| 54 | + implementation(libs.kotlinx.coroutines.test) |
| 55 | + implementation(libs.diglol.encoding) |
| 56 | + implementation(kotlin("test")) |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + val commonJvmMain by sourceSets.creating { |
| 61 | + dependsOn(commonMain) |
| 62 | + } |
| 63 | + val commonJvmTest by sourceSets.creating { |
| 64 | + dependsOn(commonJvmMain) |
| 65 | + dependsOn(commonTest) |
| 66 | + } |
| 67 | + |
| 68 | + val jvmMain by sourceSets.getting { |
| 69 | + dependsOn(commonJvmMain) |
| 70 | + } |
| 71 | + val jvmTest by sourceSets.getting { |
| 72 | + dependsOn(jvmMain) |
| 73 | + dependsOn(commonJvmTest) |
| 74 | + } |
| 75 | + |
| 76 | + val androidMain by sourceSets.getting { |
| 77 | + dependsOn(commonJvmMain) |
| 78 | + } |
| 79 | + val androidUnitTest by sourceSets.getting { |
| 80 | + dependsOn(androidMain) |
| 81 | + dependsOn(commonJvmTest) |
| 82 | + } |
| 83 | + |
| 84 | + val jsMain by sourceSets.getting |
| 85 | + val jsTest by sourceSets.getting |
| 86 | + |
| 87 | + val darwinMain by sourceSets.creating { |
| 88 | + dependsOn(commonMain) |
| 89 | + } |
| 90 | + val darwinTest by sourceSets.creating { |
| 91 | + dependsOn(commonTest) |
| 92 | + } |
| 93 | + |
| 94 | + targets.withType<KotlinNativeTarget>().all { |
| 95 | + val main by compilations.getting |
| 96 | + val test by compilations.getting |
| 97 | + |
| 98 | + main.defaultSourceSet.dependsOn( |
| 99 | + when { |
| 100 | + konanTarget.family.isAppleFamily -> darwinMain |
| 101 | + else -> TODO("Not yet implemented") |
| 102 | + } |
| 103 | + ) |
| 104 | + |
| 105 | + test.defaultSourceSet.dependsOn( |
| 106 | + if (konanTarget.family.isAppleFamily) { |
| 107 | + darwinTest |
| 108 | + } else { |
| 109 | + commonTest |
| 110 | + } |
| 111 | + ) |
| 112 | + } |
| 113 | + } |
| 114 | +} |
| 115 | + |
| 116 | +android { |
| 117 | + namespace = "diglol.crypto.siphash" |
| 118 | + |
| 119 | + defaultConfig { |
| 120 | + consumerProguardFiles("proguard-rules.pro") |
| 121 | + } |
| 122 | +} |
| 123 | + |
| 124 | +dependencies { |
| 125 | + androidTestImplementation(libs.junit) |
| 126 | + androidTestImplementation(libs.androidx.test.runner) |
| 127 | +} |
| 128 | + |
| 129 | +configure<MavenPublishBaseExtension> { |
| 130 | + configure( |
| 131 | + KotlinMultiplatform( |
| 132 | + javadocJar = JavadocJar.Dokka("dokkaGfm") |
| 133 | + ) |
| 134 | + ) |
| 135 | +} |
0 commit comments