-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
162 lines (138 loc) · 4.32 KB
/
build.gradle.kts
File metadata and controls
162 lines (138 loc) · 4.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import com.android.build.api.dsl.LibraryExtension
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.io.FileInputStream
import java.util.Properties
plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlin.android).apply(false)
alias(libs.plugins.compose).apply(false)
alias(libs.plugins.composeCompiler).apply(false)
alias(libs.plugins.android.application).apply(false)
alias(libs.plugins.android.library).apply(false)
alias(libs.plugins.mavenPublish)
}
rootProject.projectDir.resolve("local.properties").let {
if (it.exists()) {
Properties().apply {
load(FileInputStream(it))
}.forEach { (k,v)-> rootProject.ext.set(k.toString(), v) }
System.getenv().forEach { (k,v) ->
rootProject.ext.set(k, v)
}
}
}
kotlin {
jvm()
explicitApi()
}
val _jvmTarget = findProperty("jvmTarget").toString()
subprojects {
group = findProperty("group") as String
version = findProperty("version") as String
if (!name.startsWith("compottie")) {
return@subprojects
}
plugins.apply("org.jetbrains.kotlin.multiplatform")
plugins.apply("com.vanniktech.maven.publish")
plugins.apply("android-library")
androidLibrarySetup()
multiplatformSetup()
publicationSetup()
}
fun Project.publicationSetup() {
mavenPublishing {
publishToMavenCentral()
signAllPublications()
// coordinates(group.toString(), name, version.toString())
pom {
name.set("Compottie")
description.set("Compose Multiplatform Lottie animation library")
url.set("https://github.com/alexzhirkevich/compottie")
licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("alexzhirkevich")
name.set("Alexander Zhirkevich")
email.set("[email protected]")
}
}
scm {
url.set("https://github.com/alexzhirkevich/compottie")
connection.set("scm:git:git://github.com/alexzhirkevich/compottie.git")
developerConnection.set("scm:git:git://github.com/alexzhirkevich/compottie.git")
}
}
}
}
@OptIn(ExperimentalKotlinGradlePluginApi::class)
fun Project.multiplatformSetup() {
project.kotlin {
applyDefaultHierarchyTemplate {
common {
group("jvmNative") {
withAndroidTarget()
withJvm()
withIos()
withMacos()
}
group("java"){
withJvm()
withAndroidTarget()
}
group("skiko") {
withJvm()
withIos()
withMacos()
withJs()
withWasmJs()
}
group("desktopNative") {
withJvm()
withIos()
withMacos()
}
}
}
jvm("desktop") {
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(_jvmTarget))
}
}
androidTarget {
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(_jvmTarget))
}
publishLibraryVariants("release")
}
iosArm64()
iosSimulatorArm64()
iosX64()
macosArm64()
macosX64()
js(IR) {
browser()
}
wasmJs() {
browser()
}
}
}
fun Project.androidLibrarySetup() {
extensions.configure<LibraryExtension> {
namespace = group.toString() + path.replace("-", "").split(":").joinToString(".")
compileSdk = (findProperty("android.compileSdk") as String).toInt()
defaultConfig {
minSdk = (findProperty("android.minSdk") as String).toInt()
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
}