-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
114 lines (106 loc) · 3.89 KB
/
build.gradle.kts
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
/*
* Copyright (C) 2023 Meowool <https://github.com/meowool/mmkv-ktx/graphs/contributors>
*
* This file is part of the MMKV-KTX project <https://github.com/meowool/mmkv-ktx>.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.android.build.api.dsl.ApplicationDefaultConfig
import com.android.build.api.dsl.CommonExtension
import com.android.build.gradle.BasePlugin
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.MavenPublishPlugin
import com.vanniktech.maven.publish.SonatypeHost
val isCi = providers.environmentVariable("CI").isPresent
val isSnapshot = isCi && providers.environmentVariable("RELEASE").orNull != "true"
plugins {
alias(libs.plugins.detekt)
alias(libs.plugins.android.library) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.maven.publish) apply false
}
detekt {
buildUponDefaultConfig = true
parallel = !isCi
config.setFrom(layout.projectDirectory.file("detekt.yml"))
}
allprojects {
group = "com.meowool"
version = rootProject.layout.projectDirectory
.file("version.txt").asFile
.readText()
.trim()
.plus(if (isSnapshot) "-SNAPSHOT" else "")
project.configureAndroid()
project.configurePublish()
}
fun Project.configureAndroid() = plugins.withType<BasePlugin> {
(extensions["android"] as CommonExtension<*, *, *, *, *, *>).apply {
compileSdk = 34
testOptions.unitTests.isIncludeAndroidResources = true
defaultConfig {
minSdk = 23
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
if (this is ApplicationDefaultConfig) targetSdk = 34
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}
}
fun Project.configurePublish() = plugins.withType<MavenPublishPlugin> {
extensions.configure<MavenPublishBaseExtension> {
publishToMavenCentral(SonatypeHost.S01, automaticRelease = true)
signAllPublications()
coordinates(
groupId = project.group.toString(),
artifactId = "mmkv" + if (name != "runtime") "-$name" else "",
version = project.version.toString(),
)
pom {
name.set("MMKV-KTX")
description.set("A strong Kotlin-flavored MMKV extension library.")
inceptionYear.set("2023")
url.set("https://github.com/meowool/mmkv-ktx")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
// Tencent MMKV is licensed under the BSD 3-Clause License
license {
name.set("The BSD 3-Clause License")
url.set("https://opensource.org/licenses/BSD-3-Clause")
distribution.set("https://opensource.org/licenses/BSD-3-Clause")
}
}
developers {
developer {
id.set("chachako")
name.set("Cha")
url.set("https://github.com/chachako/")
}
}
scm {
url.set("https://github.com/meowool/mmkv-ktx")
connection.set("scm:git:git://github.com/meowool/mmkv-ktx.git")
developerConnection.set("scm:git:ssh://git@github.com/meowool/mmkv-ktx.git")
}
}
}
}