-
-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
66 lines (58 loc) · 2.46 KB
/
build.gradle.kts
File metadata and controls
66 lines (58 loc) · 2.46 KB
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
import org.gradle.internal.jvm.Jvm
import org.jlleitschuh.gradle.ktlint.KtlintExtension
import kotlin.system.exitProcess
plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.gradle.maven.publish.plugin) apply false
alias(libs.plugins.ktlint.gradle.plugin) apply false
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
dependencies {
// classpath(libs.gradle)
classpath(libs.kotlin.gradle.plugin)
// classpath(libs.kotlin.android.extensions)
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
// can't be obtained inside 'subprojects'
val ktlintVersion: String = libs.versions.ktlint.get()
// Here we extract per-module "best practices" settings to a single top-level evaluation
subprojects {
apply(plugin = "org.jlleitschuh.gradle.ktlint")
configure<KtlintExtension> {
version.set(ktlintVersion)
}
}
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}
ext {
val jvmVersion = Jvm.current().javaVersion?.majorVersion
val minSdk = libs.versions.compileSdk.get()
if (jvmVersion != "17" && jvmVersion != "21" && jvmVersion != "25") {
println("\n\n\n")
println("**************************************************************************************************************")
println("\n\n\n")
println("ERROR: Anki-Android-Backend builds with JVM version 17, 21 and 25.")
println(" Incompatible major version detected: '$jvmVersion'")
if (jvmVersion.parseIntOrDefault(defaultValue = 0) > 25) {
println("\n\n\n")
println(" If you receive this error because you want to use a newer JDK, we may accept PRs to support new versions.")
println(" Edit the main build file, find this message in the file, and add support for the new version.")
println(" Please make sure the `build.sh` and `check-droid.sh` targets work on an emulator with our minSdk (currently $minSdk).")
}
println("\n\n\n")
println("**************************************************************************************************************")
println("\n\n\n")
exitProcess(1)
}
}
private fun String?.parseIntOrDefault(defaultValue: Int): Int = this?.toIntOrNull() ?: defaultValue