-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbuild.gradle.kts
119 lines (94 loc) · 4.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
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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
// NOTE: Only pre-include plugins (apply false) required by the modules android, common
// and desktop within this block to keep them excluded from the root module.
// If the plugin can't be resolved add a custom resolution strategy to `settings.gradle.kts`.
plugins {
// Running `./gradlew dependencyUpdates` looks for the latest libs that are available
id("com.github.ben-manes.versions") version "0.48.0"
id("org.owasp.dependencycheck") version "8.0.2" apply false
// generates licence report
id("com.jaredsburrows.license") version "0.8.90" apply false
id("com.android.application") version "8.1.0" apply false
id("com.android.library") version "8.1.0" apply false
kotlin("multiplatform") version "1.9.10" apply false
kotlin("plugin.serialization") version "1.8.10" apply false
id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin") version "2.0.1" apply false
id("io.realm.kotlin") version "1.7.1" apply false
// TODO: Update to latest version : https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-compatibility-and-versioning.html#kotlin-compatibility
id("org.jetbrains.kotlin.android") version "1.9.10" apply false
id("org.jetbrains.compose") version "1.5.3" apply false
id("com.codingfeline.buildkonfig") version "0.13.3" apply false
id("io.gitlab.arturbosch.detekt") version "1.22.0"
id("de.gematik.ti.erp.gradleplugins.TechnicalRequirementsPlugin")
id("org.jetbrains.kotlin.jvm") version "1.9.0" apply false
}
val ktlintMain: Configuration by configurations.creating
val ktlintRules: Configuration by configurations.creating
dependencies {
ktlintMain("com.pinterest:ktlint:0.46.1") {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.SHADOWED))
}
}
ktlintRules("de.gematik.ti.erp.app:rules:1.0")
}
val sourcesKt = listOf(
"app/android/src/**/de/gematik/**/*.kt",
"app/features/src/**/de/gematik/**/*.kt",
"app/demo-mode/src/**/de/gematik/**/*.kt",
"common/src/**/de/gematik/**/*.kt",
"desktop/src/**/de/gematik/**/*.kt",
"rules/src/**/de/gematik/**/*.kt",
"smartcard-wrapper/src/**/de/gematik/**/*.kt",
"plugins/*/src/**/*.kt"
)
detekt {
autoCorrect = false
source =
fileTree(rootDir) {
include(sourcesKt)
}.filter { it.extension != "kts" }
.map { it.parentFile }
.let {
files(*it.toTypedArray())
}
parallel = true
config = files("config/detekt/detekt.yml")
baseline = file("config/detekt/baseline.xml")
buildUponDefaultConfig = false
allRules = false
disableDefaultRuleSets = false
debug = false
ignoreFailures = false
}
fun ktlintCreating(format: Boolean, sources: List<String>, disableLicenceRule: Boolean) =
tasks.creating(JavaExec::class) {
description = "Fix Kotlin code style deviations."
classpath = ktlintMain + ktlintRules
mainClass.set("com.pinterest.ktlint.Main")
args = mutableListOf<String>().apply {
if (format) add("-F")
addAll(sources)
if (disableLicenceRule) add("--disabled_rules=custom:licence-header")
}
// required for java > 16; see https://github.com/pinterest/ktlint/issues/1195
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
}
val ktlint by ktlintCreating(format = false, sources = sourcesKt, disableLicenceRule = false)
val ktlintFormat by ktlintCreating(format = true, sources = sourcesKt, disableLicenceRule = false)
tasks.register("clean", Delete::class) {
rootProject.allprojects.forEach {
delete(it.buildDir)
}
}
fun isUnstable(version: String): Boolean =
version.contains("alpha", ignoreCase = true) ||
version.contains("rc", ignoreCase = true) ||
version.contains("beta", ignoreCase = true)
tasks.withType<DependencyUpdatesTask> {
outputFormatter = "txt,html"
rejectVersionIf {
// allows unstable to unstable updates but not stable to unstable
isUnstable(candidate.version) && !isUnstable(currentVersion)
}
}