-
Notifications
You must be signed in to change notification settings - Fork 100
/
build.gradle.kts
120 lines (103 loc) · 3.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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
}
dependencies {
classpath(libs.gradlePlugin)
classpath(libs.kotlinPlugin)
classpath(libs.hiltPlugin)
classpath(libs.jacoco)
classpath(libs.kotlinSerialization)
}
}
plugins {
id("org.jlleitschuh.gradle.ktlint").version("11.5.1")
id("org.sonarqube").version("3.5.0.2730")
id("com.github.ben-manes.versions").version("0.46.0")
}
sonarqube {
properties {
val branch = System.getenv("GIT_BRANCH")
val targetBranch = System.getenv("GIT_BRANCH_DEST")
val pullRequestId = System.getenv("PULL_REQUEST")
property("sonar.projectKey", "dhis2_dhis2-android-capture-app")
property("sonar.organization", "dhis2")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.projectName", "android capture app")
if (pullRequestId == null) {
property("sonar.branch.name", branch)
} else {
property("sonar.pullrequest.base", targetBranch)
property("sonar.pullrequest.branch", branch)
property("sonar.pullrequest.key", pullRequestId)
}
}
}
val isNonStable: (String) -> Boolean = { version ->
val stableKeyword =
listOf("RELEASE", "FINAL", "GA").any { it -> version.toUpperCase().contains(it) }
val regex = """^[0-9,.v-]+(-r)?$""".toRegex()
!stableKeyword && !(version matches regex)
}
allprojects {
configurations.all {
resolutionStrategy {
cacheDynamicVersionsFor(0, TimeUnit.SECONDS)
eachDependency {
if (requested.group == "org.jacoco")
useVersion("0.8.10")
}
}
}
repositories {
google()
mavenCentral()
maven {
url = uri("https://maven.google.com")
}
maven { url = uri("https://jitpack.io") }
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
maven {
url = uri("https://api.mapbox.com/downloads/v2/releases/maven")
authentication {
create<BasicAuthentication>("basic")
}
val mapboxDownloadsToken = System.getenv("MAPBOX_DOWNLOADS_TOKEN")
?: project.properties["MAPBOX_DOWNLOADS_TOKEN"] ?: ""
credentials {
// This should always be `mapbox` (not your username).
username = "mapbox"
password = mapboxDownloadsToken as String
}
}
}
apply(plugin = "org.jlleitschuh.gradle.ktlint")
gradle.projectsEvaluated {
tasks.withType<JavaCompile> {
options.compilerArgs.addAll(
listOf(
"-Xmaxerrs",
"1000"
)
)
}
}
ktlint {
version.set("0.50.0")
debug.set(true)
verbose.set(true)
android.set(true)
outputToConsole.set(true)
enableExperimentalRules.set(true)
filter {
excludes.add("**/*.kts")
exclude { element -> element.file.path.contains("androidTest") }
exclude { element -> element.file.path.contains("dhis2-android-sdk") }
}
}
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}