-
Notifications
You must be signed in to change notification settings - Fork 26
/
build.gradle.kts
167 lines (156 loc) · 6.47 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
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
163
164
165
166
167
import Config.migrationCode
import Config.serverCode
import Config.tachideskVersion
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type
import org.jetbrains.compose.ComposeExtension
import org.jetbrains.compose.ComposePlugin
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.compose) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.buildconfig) apply false
alias(libs.plugins.buildkonfig) apply false
alias(libs.plugins.moko.gradle) apply false
alias(libs.plugins.kotlinter) apply false
alias(libs.plugins.ktorfit) apply false
alias(libs.plugins.aboutLibraries) apply false
alias(libs.plugins.apollo) apply false
alias(libs.plugins.versions)
//id("com.louiscad.complete-kotlin") version "1.1.0"
}
allprojects {
group = "ca.gosyer"
version = "1.3.3"
dependencies {
modules {
module("androidx.lifecycle:lifecycle-viewmodel-ktx") {
replacedBy("androidx.lifecycle:lifecycle-viewmodel")
}
}
}
}
tasks.withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> {
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
}
subprojects {
tasks.withType<KotlinJvmCompile> {
kotlinOptions {
if (name.contains("android", true)) {
jvmTarget = Config.androidJvmTarget.toString()
}
freeCompilerArgs += listOf("-Xexpect-actual-classes")
if (project.hasProperty("generateComposeCompilerMetrics")) {
freeCompilerArgs = freeCompilerArgs + listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" +
project.layout.buildDirectory.dir("compose_metrics").get().asFile.absolutePath,
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" +
project.layout.buildDirectory.dir("compose_metrics").get().asFile.absolutePath
)
}
}
}
tasks.withType<org.jmailen.gradle.kotlinter.tasks.LintTask> {
source(files("src"))
exclude("ca/gosyer/jui/*/build")
}
tasks.withType<org.jmailen.gradle.kotlinter.tasks.FormatTask> {
source(files("src"))
exclude("ca/gosyer/jui/*/build")
}
plugins.withType<com.android.build.gradle.BasePlugin> {
configure<com.android.build.gradle.BaseExtension> {
compileSdkVersion(34)
defaultConfig {
minSdk = 21
targetSdk = 31
/*versionCode(Config.versionCode)
versionName(Config.versionName)
ndk {
version = Config.ndk
}*/
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility(Config.androidJvmTarget)
targetCompatibility(Config.androidJvmTarget)
}
dependencies {
add("coreLibraryDesugaring", libs.desugarJdkLibs)
}
buildFeatures.apply {
aidl = false
renderScript = false
shaders = false
}
}
}
plugins.withType<com.codingfeline.buildkonfig.gradle.BuildKonfigPlugin> {
configure<com.codingfeline.buildkonfig.gradle.BuildKonfigExtension> {
defaultConfigs {
buildConfigField(Type.STRING, "NAME", rootProject.name, const = true)
buildConfigField(Type.STRING, "VERSION", project.version.toString(), const = true)
buildConfigField(Type.INT, "MIGRATION_CODE", migrationCode.toString(), const = true)
buildConfigField(Type.BOOLEAN, "DEBUG", project.hasProperty("debugApp").toString(), const = true)
plugins.withType<com.android.build.gradle.BasePlugin> {
buildConfigField(Type.BOOLEAN, "DEBUG", gradle.startParameter.taskRequests.toString().contains("Debug").toString(), const = true)
}
buildConfigField(Type.BOOLEAN, "IS_PREVIEW", project.hasProperty("preview").toString(), const = true)
buildConfigField(Type.INT, "PREVIEW_BUILD", project.properties["preview"]?.toString()?.trim('"') ?: 0.toString(), const = true)
// Tachidesk
buildConfigField(Type.STRING, "TACHIDESK_SP_VERSION", tachideskVersion, const = true)
buildConfigField(Type.INT, "SERVER_CODE", serverCode.toString(), const = true)
}
}
}
plugins.withType<com.google.devtools.ksp.gradle.KspGradleSubplugin> {
configure<com.google.devtools.ksp.gradle.KspExtension> {
arg("me.tatarka.inject.generateCompanionExtensions", "true")
if (project.hasProperty("debugApp")) {
arg("me.tatarka.inject.dumpGraph", "true")
}
}
}
plugins.withType<de.jensklingenberg.ktorfit.gradle.KtorfitGradlePlugin> {
configure<de.jensklingenberg.ktorfit.gradle.KtorfitGradleConfiguration> {
logging = project.hasProperty("debugApp")
}
}
plugins.withType<JacocoPlugin> {
configure<JacocoPluginExtension> {
toolVersion = "0.8.10"
}
}
plugins.withType<ComposePlugin> {
configure<ComposeExtension> {
// kotlinCompilerPlugin.set(libs.versions.composeCompiler.get())
}
}
afterEvaluate {
extensions.findByType<KotlinMultiplatformExtension>()?.let { ext ->
ext.sourceSets.removeAll { sourceSet ->
setOf(
"androidAndroidTestRelease",
"androidTestFixtures",
"androidTestFixturesDebug",
"androidTestFixturesRelease",
).contains(sourceSet.name)
}
}
}
}
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.contains(it, true) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}