forked from AndroidIDEOfficial/AndroidIDE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
executable file
·93 lines (77 loc) · 3.14 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
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
import com.android.build.gradle.BaseExtension
import com.itsaky.androidide.plugins.AndroidIDEPlugin
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
id("build-logic.root-project")
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin) apply false
}
buildscript { dependencies { classpath("com.google.android.gms:oss-licenses-plugin:0.10.6")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10")
} }
val Project.projectVersionCode by lazy {
val version = rootProject.version.toString()
val regex = Regex("^v\\d+\\.?\\d+\\.?\\d+")
return@lazy regex.find(version)?.value?.substring(1)?.replace(".", "")?.toInt()?.also {
logger.warn("Version code is '$it' (from version ${rootProject.version}).")
}
?: throw IllegalStateException(
"Invalid version string '$version'. Version names must be SEMVER with 'v' prefix"
)
}
fun Project.configureBaseExtension() {
extensions.findByType(BaseExtension::class)?.run {
compileSdkVersion(BuildConfig.compileSdk)
buildToolsVersion = BuildConfig.buildTools
defaultConfig {
minSdk = BuildConfig.minSdk
targetSdk = BuildConfig.targetSdk
versionCode = projectVersionCode
versionName = rootProject.version.toString()
}
compileOptions {
sourceCompatibility = BuildConfig.javaVersion
targetCompatibility = BuildConfig.javaVersion
}
buildTypes.getByName("debug") { isMinifyEnabled = false }
buildTypes.getByName("release") {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
testOptions { unitTests.isIncludeAndroidResources = true }
buildFeatures.viewBinding = true
}
}
subprojects {
apply { plugin(AndroidIDEPlugin::class.java) }
version = rootProject.version
plugins.withId("com.android.application") { configureBaseExtension() }
plugins.withId("com.android.library") { configureBaseExtension() }
plugins.withId("java-library") {
configure<JavaPluginExtension> {
sourceCompatibility = BuildConfig.javaVersion
targetCompatibility = BuildConfig.javaVersion
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = BuildConfig.javaVersion.toString()
}
}
tasks.register<Delete>("clean") { delete(rootProject.buildDir) }