-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
82 lines (74 loc) · 2.46 KB
/
build.gradle
File metadata and controls
82 lines (74 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.ktlint)
alias(libs.plugins.gradleVersions)
alias(libs.plugins.detekt)
}
ext {
// Current version of the library
libraryVersion = "0.0.16"
}
subprojects {
// KTLint (Kotlin code style enforcer)
apply(plugin: libs.plugins.ktlint.get().pluginId)
ktlint {
outputToConsole = true
}
// Detekt (Kotlin static analyser)
apply(plugin: libs.plugins.detekt.get().pluginId)
detekt {
allRules = true // Include all rules
buildUponDefaultConfig = true // preconfigure defaults (see the rule set file below for explanations)
// point to your custom config defining rules to run, overwriting default behavior
config.setFrom("${project.rootDir}/config/detekt/detekt-config.yaml")
}
tasks.named("detekt").configure {
// Manually add our custom lib/java source dir here
source = files(
"src/main/java",
"src/test/java",
"java"
)
jvmTarget = libs.versions.jvmTarget.get()
reports {
html.required.set(true)
xml.required.set(false)
txt.required.set(false)
}
}
afterEvaluate {
// Make sure detekt is executed with all the other linters for all modules
check.dependsOn "detekt"
}
tasks.register('checkCode') {
group = "Verification"
description = "Run detekt and ktlint."
dependsOn "detekt", "ktlintCheck"
}
}
tasks.register('clean', Delete) {
group = "Build"
description = "Delete the build directory. Useful if you need to make a clean build."
delete rootProject.layout.buildDirectory
}
// Don't show non stable updates for current stable versions
def isNonStable = { String version ->
def stableKeyword = ["RELEASE", "FINAL", "GA"].any { keyword -> version.toUpperCase().contains(keyword) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
dependencyUpdates {
checkForGradleUpdate = true
resolutionStrategy {
componentSelection {
all {
if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
reject("Release candidate")
}
}
}
}
}