-
Notifications
You must be signed in to change notification settings - Fork 443
/
build.gradle.kts
88 lines (73 loc) · 2.86 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
import com.android.build.api.dsl.LibraryExtension
import com.android.build.gradle.BaseExtension
import com.android.build.gradle.BasePlugin
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
}
allprojects {
version = findProperty("VERSION_NAME").toString()
group = findProperty("GROUP").toString()
}
subprojects {
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = JavaVersion.VERSION_17.toString()
targetCompatibility = JavaVersion.VERSION_17.toString()
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
}
plugins.withType<BasePlugin>().configureEach {
extensions.configure<BaseExtension> {
compileSdkVersion(libs.versions.android.compile.sdk.get().toInt())
buildToolsVersion(libs.versions.android.build.tools.get())
ndkVersion = libs.versions.android.ndk.get()
defaultConfig {
minSdk = libs.versions.android.min.sdk.get().toInt()
targetSdk = libs.versions.android.target.sdk.get().toInt()
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}
extensions.findByType<LibraryExtension>()?.apply {
lint {
targetSdk = libs.versions.android.target.sdk.get().toInt()
}
}
}
plugins.withType<MavenPublishPlugin>().configureEach {
extensions.configure<PublishingExtension> {
repositories {
val repositoryUrl = if (isReleaseBuild) {
requireNotNull(property("RELEASE_REPOSITORY_URL")?.toString())
} else {
requireNotNull(property("SNAPSHOT_REPOSITORY_URL")?.toString())
}
maven {
url = uri(repositoryUrl)
credentials {
username = findStringPropertyOrDefault("NEXUS_USERNAME")
password = findStringPropertyOrDefault("NEXUS_PASSWORD")
}
}
}
}
}
plugins.withType<SigningPlugin>().configureEach {
extensions.configure<SigningExtension> {
isRequired = isReleaseBuild
}
}
}
val clean by tasks.registering(type = Delete::class) {
delete(rootProject.layout.buildDirectory)
}
private val Project.isReleaseBuild get() = !version.toString().endsWith("SNAPSHOT")
private fun Project.findStringPropertyOrDefault(propertyName: String, default: String? = "") =
findProperty(propertyName)?.toString() ?: default