forked from Suwayomi/Suwayomi-JUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
163 lines (151 loc) · 5.87 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
import Config.migrationCode
import Config.serverCode
import Config.tachideskVersion
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type
@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.aboutLibraries) apply false
alias(libs.plugins.versions)
}
buildscript {
dependencies {
// Waiting on https://github.com/Guardsquare/proguard/issues/225
classpath(libs.proguard)
}
}
allprojects {
group = "ca.gosyer"
version = "1.3.0"
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<org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile> {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + listOf(
"-Xjvm-default=compatibility",
)
}
}
tasks.withType<org.jmailen.gradle.kotlinter.tasks.LintTask> {
source(files("src"))
exclude("ca/gosyer/*/build")
}
tasks.withType<org.jmailen.gradle.kotlinter.tasks.FormatTask> {
source(files("src"))
exclude("ca/gosyer/*/build")
}
plugins.withType<com.android.build.gradle.BasePlugin> {
configure<com.android.build.gradle.BaseExtension> {
compileSdkVersion(31)
defaultConfig {
minSdk = 21
targetSdk = 31
/*versionCode(Config.versionCode)
versionName(Config.versionName)
ndk {
version = Config.ndk
}*/
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility(Config.androidJvmTarget)
targetCompatibility(Config.androidJvmTarget)
}
sourceSets {
named("main") {
val altManifest = file("src/androidMain/AndroidManifest.xml")
if (altManifest.exists()) {
manifest.srcFile(altManifest.path)
}
}
}
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)
buildConfigField(Type.STRING, "VERSION", project.version.toString())
buildConfigField(Type.INT, "MIGRATION_CODE", migrationCode.toString())
buildConfigField(Type.BOOLEAN, "DEBUG", project.hasProperty("debugApp").toString())
buildConfigField(Type.BOOLEAN, "IS_PREVIEW", project.hasProperty("preview").toString())
buildConfigField(Type.INT, "PREVIEW_BUILD", project.properties["preview"]?.toString()?.trim('"') ?: 0.toString())
// Tachidesk
buildConfigField(Type.STRING, "TACHIDESK_SP_VERSION", tachideskVersion)
buildConfigField(Type.INT, "SERVER_CODE", serverCode.toString())
}
}
}
plugins.withType<org.jmailen.gradle.kotlinter.KotlinterPlugin> {
configure<org.jmailen.gradle.kotlinter.KotlinterExtension> {
experimentalRules = true
disabledRules = arrayOf("experimental:argument-list-wrapping", "experimental:trailing-comma")
}
}
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<JacocoPlugin> {
configure<JacocoPluginExtension> {
toolVersion = "0.8.7"
}
}
plugins.withType<org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper> {
configure<org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension> {
afterEvaluate {
if (!Config.androidDev) {
sourceSets.addSrcDir("desktopMain", "src/jvmMain/kotlin")
sourceSets.addSrcDir("desktopTest", "src/jvmTest/kotlin")
}
sourceSets.addSrcDir("androidMain", "src/jvmMain/kotlin")
sourceSets.addSrcDir("androidTest", "src/jvmTest/kotlin")
}
}
}
}
fun NamedDomainObjectContainer<org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet>.addSrcDir(configuration: String, srcDir: String) {
filter { it.name.contains(configuration) }
.forEach {
it.kotlin.srcDir(srcDir)
}
}
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()
}