1+ /*
2+ * Copyright 2026 Nikolai Kotchetkov.
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ * http://www.apache.org/licenses/LICENSE-2.0
7+ * Unless required by applicable law or agreed to in writing, software
8+ * distributed under the License is distributed on an "AS IS" BASIS,
9+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+ * See the License for the specific language governing permissions and
11+ * limitations under the License.
12+ */
13+
14+ @file:Suppress(" unused" )
15+ @file:OptIn(ExperimentalWasmDsl ::class )
16+
17+ import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
18+ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
19+
20+ plugins {
21+ alias(libs.plugins.kotlin.multiplatform)
22+ alias(libs.plugins.android.kotlin.multiplatform.library)
23+ alias(libs.plugins.kotlin.dokka)
24+ id(" maven-publish" )
25+ id(" signing" )
26+ }
27+
28+ val versionName: String by project.extra
29+ val androidMinSdkVersion: Int by project.extra
30+ val androidTargetSdkVersion: Int by project.extra
31+ val androidCompileSdkVersion: Int by project.extra
32+
33+ group = rootProject.group
34+ version = rootProject.version
35+
36+ println (" == Project version: $versionName ==" )
37+
38+ kotlin {
39+ jvmToolchain(17 )
40+
41+ jvm()
42+ android {
43+ namespace = " com.motorro.commonstatemachine.commonflow"
44+ compileSdk = androidCompileSdkVersion
45+ minSdk = androidMinSdkVersion
46+
47+ withHostTest {
48+ isIncludeAndroidResources = true
49+ }
50+
51+ compilerOptions {
52+ jvmTarget.set(JvmTarget .JVM_17 )
53+ }
54+ }
55+
56+ js(IR ) {
57+ binaries.library()
58+ useCommonJs()
59+ browser {
60+ testTask(Action {
61+ useMocha {
62+ timeout = " 10s"
63+ }
64+ })
65+ }
66+ }
67+
68+ wasmJs {
69+ binaries.library()
70+ useCommonJs()
71+ browser {
72+ testTask(Action {
73+ useMocha {
74+ timeout = " 10s"
75+ }
76+ })
77+ }
78+ }
79+
80+ listOf (
81+ iosX64(),
82+ iosArm64(),
83+ iosSimulatorArm64()
84+ ).forEach {
85+ it.binaries.framework {
86+ baseName = " commonflow"
87+ isStatic = true
88+ }
89+ }
90+
91+ sourceSets {
92+ commonMain.dependencies {
93+ api(project(" :commonstatemachine" ))
94+ }
95+ }
96+ }
97+ val javadocJar by tasks.registering(Jar ::class ) {
98+ dependsOn(tasks.dokkaGenerate)
99+ group = " documentation"
100+ archiveClassifier.set(" javadoc" )
101+ from(tasks.dokkaGenerate)
102+ }
103+
104+ val libId = " commonflow"
105+ val libName = " commonflow"
106+ val libDesc = " Common flow for modularized state machines"
107+ val projectUrl: String by project.extra
108+ val projectScm: String by project.extra
109+ val ossrhUsername: String? by rootProject.extra
110+ val ossrhPassword: String? by rootProject.extra
111+ val developerId: String by project.extra
112+ val developerName: String by project.extra
113+ val developerEmail: String by project.extra
114+ val signingKey: String? by rootProject.extra
115+ val signingPassword: String? by rootProject.extra
116+
117+ publishing {
118+ publications.withType<MavenPublication > {
119+ artifact(javadocJar)
120+ pom {
121+ name.set(libName)
122+ description.set(libDesc)
123+ url.set(projectUrl)
124+ licenses {
125+ license {
126+ name.set(" Apache-2.0" )
127+ url.set(" https://apache.org/licenses/LICENSE-2.0" )
128+ }
129+ }
130+ developers {
131+ developer {
132+ id.set(developerId)
133+ name.set(developerName)
134+ email.set(developerEmail)
135+ }
136+ }
137+ scm {
138+ connection.set(projectScm)
139+ developerConnection.set(projectScm)
140+ url.set(projectUrl)
141+ }
142+ }
143+ }
144+ }
145+
146+ signing {
147+ useInMemoryPgpKeys(signingKey, signingPassword)
148+ sign(publishing.publications)
149+ }
150+
151+ val signingTasks = tasks.withType<Sign >()
152+ tasks.withType<AbstractPublishToMaven >().configureEach {
153+ dependsOn(signingTasks)
154+ }
0 commit comments