|
| 1 | +import com.vanniktech.maven.publish.SonatypeHost |
| 2 | +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion |
| 3 | +import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl |
| 4 | + |
| 5 | +plugins { |
| 6 | + kotlin("multiplatform") |
| 7 | + alias(libs.plugins.androidLibrary) |
| 8 | + alias(libs.plugins.jetbrainsCompose) |
| 9 | + alias(libs.plugins.composeCompiler) |
| 10 | + alias(libs.plugins.dokka) |
| 11 | + alias(libs.plugins.mavenPublish) |
| 12 | +} |
| 13 | + |
| 14 | +android { |
| 15 | + namespace = "com.mikepenz.markdown.code" |
| 16 | + compileSdk = libs.versions.compileSdk.get().toInt() |
| 17 | + |
| 18 | + defaultConfig { |
| 19 | + minSdk = libs.versions.minSdk.get().toInt() |
| 20 | + targetSdk = libs.versions.targetSdk.get().toInt() |
| 21 | + } |
| 22 | + |
| 23 | + buildTypes { |
| 24 | + getByName("release") { |
| 25 | + isMinifyEnabled = false |
| 26 | + proguardFiles( |
| 27 | + getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" |
| 28 | + ) |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + compileOptions { |
| 33 | + sourceCompatibility = JavaVersion.VERSION_11 |
| 34 | + targetCompatibility = JavaVersion.VERSION_11 |
| 35 | + } |
| 36 | + |
| 37 | + tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { |
| 38 | + kotlinOptions.jvmTarget = "11" |
| 39 | + |
| 40 | + kotlinOptions { |
| 41 | + if (project.findProperty("composeCompilerReports") == "true") { |
| 42 | + freeCompilerArgs += listOf( |
| 43 | + "-P", |
| 44 | + "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=${project.buildDir.absolutePath}/compose_compiler" |
| 45 | + ) |
| 46 | + } |
| 47 | + if (project.findProperty("composeCompilerMetrics") == "true") { |
| 48 | + freeCompilerArgs += listOf( |
| 49 | + "-P", |
| 50 | + "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=${project.buildDir.absolutePath}/compose_compiler" |
| 51 | + ) |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +kotlin { |
| 58 | + applyDefaultHierarchyTemplate() |
| 59 | + |
| 60 | + targets.all { |
| 61 | + compilations.all { |
| 62 | + compilerOptions.configure { |
| 63 | + languageVersion.set(KotlinVersion.KOTLIN_1_9) |
| 64 | + apiVersion.set(KotlinVersion.KOTLIN_1_9) |
| 65 | + } |
| 66 | + } |
| 67 | + } |
| 68 | + androidTarget { |
| 69 | + publishLibraryVariants("release") |
| 70 | + } |
| 71 | + jvm { |
| 72 | + compilations { |
| 73 | + all { |
| 74 | + kotlinOptions.jvmTarget = "11" |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + testRuns["test"].executionTask.configure { |
| 79 | + useJUnit { |
| 80 | + excludeCategories("org.intellij.markdown.ParserPerformanceTest") |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | + @OptIn(ExperimentalWasmDsl::class) |
| 85 | + wasmJs { |
| 86 | + browser() |
| 87 | + } |
| 88 | + js(IR) { |
| 89 | + nodejs() |
| 90 | + } |
| 91 | + macosX64() |
| 92 | + macosArm64() |
| 93 | + iosX64() |
| 94 | + iosArm64() |
| 95 | + iosSimulatorArm64() |
| 96 | + |
| 97 | + sourceSets { |
| 98 | + val commonMain by getting |
| 99 | + val commonTest by getting { |
| 100 | + dependencies { |
| 101 | + implementation(kotlin("test")) |
| 102 | + } |
| 103 | + } |
| 104 | + val fileBasedTest by creating { |
| 105 | + dependsOn(commonTest) |
| 106 | + } |
| 107 | + val jvmTest by getting { |
| 108 | + dependsOn(fileBasedTest) |
| 109 | + } |
| 110 | + val jsTest by getting { |
| 111 | + dependsOn(fileBasedTest) |
| 112 | + } |
| 113 | + val nativeMain by getting { |
| 114 | + dependsOn(commonMain) |
| 115 | + } |
| 116 | + val nativeTest by getting { |
| 117 | + dependsOn(fileBasedTest) |
| 118 | + } |
| 119 | + val nativeSourceSets = listOf( |
| 120 | + "macosX64", |
| 121 | + "macosArm64", |
| 122 | + "ios", |
| 123 | + "iosSimulatorArm64" |
| 124 | + ).map { "${it}Main" } |
| 125 | + for (set in nativeSourceSets) { |
| 126 | + getByName(set).dependsOn(nativeMain) |
| 127 | + } |
| 128 | + val nativeTestSourceSets = listOf( |
| 129 | + "macosX64", |
| 130 | + "macosArm64" |
| 131 | + ).map { "${it}Test" } |
| 132 | + for (set in nativeTestSourceSets) { |
| 133 | + getByName(set).dependsOn(nativeTest) |
| 134 | + getByName(set).dependsOn(fileBasedTest) |
| 135 | + } |
| 136 | + } |
| 137 | +} |
| 138 | + |
| 139 | +dependencies { |
| 140 | + commonMainApi(projects.multiplatformMarkdownRenderer) |
| 141 | + commonMainCompileOnly(compose.runtime) |
| 142 | + commonMainCompileOnly(compose.ui) |
| 143 | + commonMainCompileOnly(compose.foundation) |
| 144 | + |
| 145 | + commonMainApi(libs.highlights) |
| 146 | +} |
| 147 | + |
| 148 | +tasks.dokkaHtml.configure { |
| 149 | + dokkaSourceSets { |
| 150 | + configureEach { |
| 151 | + noAndroidSdkLink.set(false) |
| 152 | + } |
| 153 | + } |
| 154 | +} |
| 155 | + |
| 156 | +tasks.create<Jar>("javadocJar") { |
| 157 | + dependsOn("dokkaJavadoc") |
| 158 | + archiveClassifier.set("javadoc") |
| 159 | + from("${layout.buildDirectory}/javadoc") |
| 160 | +} |
| 161 | + |
| 162 | +mavenPublishing { |
| 163 | + publishToMavenCentral(SonatypeHost.S01) |
| 164 | + signAllPublications() |
| 165 | +} |
| 166 | + |
| 167 | +publishing { |
| 168 | + repositories { |
| 169 | + maven { |
| 170 | + name = "installLocally" |
| 171 | + setUrl("${rootProject.layout.buildDirectory}/localMaven") |
| 172 | + } |
| 173 | + } |
| 174 | +} |
0 commit comments