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.compose)
24+ alias(libs.plugins.composeMultiplatform)
25+ alias(libs.plugins.kotlin.dokka)
26+ id(" maven-publish" )
27+ id(" signing" )
28+ }
29+
30+ val versionName: String by project.extra
31+ val androidMinSdkVersion: Int by project.extra
32+ val androidTargetSdkVersion: Int by project.extra
33+ val androidCompileSdkVersion: Int by project.extra
34+
35+ group = rootProject.group
36+ version = rootProject.version
37+
38+ println (" == Project version: $versionName ==" )
39+
40+ kotlin {
41+ jvmToolchain(17 )
42+
43+ jvm()
44+ android {
45+ namespace = " com.motorro.commonstatemachine.commonflow.viewmodel"
46+ compileSdk = androidCompileSdkVersion
47+ minSdk = androidMinSdkVersion
48+
49+ withHostTest {
50+ isIncludeAndroidResources = true
51+ }
52+
53+ compilerOptions {
54+ jvmTarget.set(JvmTarget .JVM_17 )
55+ }
56+ }
57+
58+ js(IR ) {
59+ binaries.library()
60+ useCommonJs()
61+ browser {
62+ testTask(Action {
63+ useMocha {
64+ timeout = " 10s"
65+ }
66+ })
67+ }
68+ }
69+
70+ wasmJs {
71+ binaries.library()
72+ useCommonJs()
73+ browser {
74+ testTask(Action {
75+ useMocha {
76+ timeout = " 10s"
77+ }
78+ })
79+ }
80+ }
81+
82+ listOf (
83+ iosX64(),
84+ iosArm64(),
85+ iosSimulatorArm64()
86+ ).forEach {
87+ it.binaries.framework {
88+ baseName = " commonflow-viewmodel"
89+ isStatic = true
90+ }
91+ }
92+
93+ sourceSets {
94+ commonMain.dependencies {
95+ api(project(" :commonstatemachine" ))
96+ api(project(" :coroutines" ))
97+ api(project(" :commonflow:compose" ))
98+ api(libs.composeMultiplatform.viewmodel)
99+ implementation(libs.composeMultiplatform.lifecycle)
100+ }
101+ commonTest.dependencies {
102+ implementation(libs.test.kotlin)
103+ implementation(libs.test.kotlin.coroutines)
104+ }
105+ androidMain.dependencies {
106+ api(libs.androidx.appcompat)
107+ implementation(libs.androidx.activity)
108+ implementation(libs.androidx.fragment)
109+ implementation(libs.compose.activity)
110+ }
111+ }
112+ }
113+ val javadocJar by tasks.registering(Jar ::class ) {
114+ dependsOn(tasks.dokkaGenerate)
115+ group = " documentation"
116+ archiveClassifier.set(" javadoc" )
117+ from(tasks.dokkaGenerate)
118+ }
119+
120+ val libId = " commonflow-viewmodel"
121+ val libName = " commonflow-viewmodel"
122+ val libDesc = " Common view components to wrap standard flow"
123+ val projectUrl: String by project.extra
124+ val projectScm: String by project.extra
125+ val ossrhUsername: String? by rootProject.extra
126+ val ossrhPassword: String? by rootProject.extra
127+ val developerId: String by project.extra
128+ val developerName: String by project.extra
129+ val developerEmail: String by project.extra
130+ val signingKey: String? by rootProject.extra
131+ val signingPassword: String? by rootProject.extra
132+
133+ publishing {
134+ publications.withType<MavenPublication > {
135+ artifact(javadocJar)
136+ pom {
137+ name.set(libName)
138+ description.set(libDesc)
139+ url.set(projectUrl)
140+ licenses {
141+ license {
142+ name.set(" Apache-2.0" )
143+ url.set(" https://apache.org/licenses/LICENSE-2.0" )
144+ }
145+ }
146+ developers {
147+ developer {
148+ id.set(developerId)
149+ name.set(developerName)
150+ email.set(developerEmail)
151+ }
152+ }
153+ scm {
154+ connection.set(projectScm)
155+ developerConnection.set(projectScm)
156+ url.set(projectUrl)
157+ }
158+ }
159+ }
160+ }
161+
162+ signing {
163+ useInMemoryPgpKeys(signingKey, signingPassword)
164+ sign(publishing.publications)
165+ }
166+
167+ val signingTasks = tasks.withType<Sign >()
168+ tasks.withType<AbstractPublishToMaven >().configureEach {
169+ dependsOn(signingTasks)
170+ }
0 commit comments