-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild.gradle.kts
92 lines (76 loc) · 2.6 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
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.firebase.crashlytics) apply false
alias(libs.plugins.google.services) apply false
alias(libs.plugins.kotlin.allopen) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.ktlint) apply false
jacoco
java
idea
}
idea {
module {
isDownloadJavadoc = true
isDownloadSources = true
}
}
allprojects {
// Verbose output for usage of deprecated APIs
tasks.withType<JavaCompile> {
options.compilerArgs = mutableListOf("-Xlint:deprecation")
}
// Prevent wildcard dependencies
// Code in groovy below
// https://gist.github.com/JakeWharton/2066f5e4f08fbaaa68fd
// modified Wharton's code for kts
afterEvaluate() {
project.configurations.all {
resolutionStrategy.eachDependency {
if (requested.version!!.contains("+")) {
throw GradleException("Wildcard dependency forbidden: ${requested.group}:" +
"${requested.name}:${requested.version}")
}
}
}
}
// Apply sample.gradle with project ext values
apply(rootProject.file("distribution/keys/sample.gradle"))
}
evaluationDependsOnChildren()
val initialCleanup by tasks.registering {
val cleanTasks = getProjectTask(rootProject, "clean")
val uninstallTasks = getProjectTask(rootProject, "uninstallAll")
dependsOn(cleanTasks)
dependsOn(uninstallTasks)
}
val testing by tasks.registering {
val appProject = subprojects.find { project -> "app" == project.name }
val unitTestTasks = getProjectTask(appProject!!, "testDevDebugUnitTest")
val integrationTestTasks = getProjectTask(appProject, "jacocoTestReport")
dependsOn(unitTestTasks)
dependsOn(integrationTestTasks)
integrationTestTasks.forEach { task -> task.mustRunAfter(unitTestTasks) }
}
val release by tasks.registering {
val appProject = subprojects.find { project -> "app" == project.name }
val appTasks = getProjectTask(appProject!!, "assemble")
dependsOn(appTasks)
}
release {
mustRunAfter(testing)
}
fun getProjectTask(project: Project, taskName: String): MutableSet<Task> {
val tasks = project.getTasksByName(taskName, true)
if (tasks.isEmpty()) {
throw IllegalArgumentException("Task $taskName not found")
}
return tasks
}
val continuousIntegration by tasks.registering {
dependsOn(initialCleanup)
dependsOn(testing)
dependsOn(release)
}