-
Notifications
You must be signed in to change notification settings - Fork 77
/
build.gradle.kts
105 lines (90 loc) · 2.9 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
import dependencies.Versions
import extensions.applyDefaults
import org.gradle.api.JavaVersion.VERSION_11
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
import org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED
import org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED
import org.gradle.api.tasks.testing.logging.TestLogEvent.STANDARD_OUT
import org.gradle.api.tasks.testing.logging.TestLogEvent.STARTED
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import plugins.BuildPlugins
import tasks.BuildTasks
val javaVersion: JavaVersion by extra { VERSION_11 }
buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id("jacoco")
}
plugins.apply(BuildPlugins.GIT_HOOKS)
plugins.apply(BuildPlugins.DETEKT)
plugins.apply(BuildPlugins.UPDATE_DEPENDENCIES)
plugins.apply(BuildPlugins.KTLINT)
plugins.apply(BuildTasks.STATIC_CHECK)
plugins.apply(BuildTasks.TEST_ALL)
allprojects {
repositories.applyDefaults()
}
subprojects {
plugins.apply(BuildPlugins.SPOTLESS)
plugins.apply(BuildPlugins.DETEKT)
plugins.apply(BuildPlugins.KTLINT)
plugins.apply(BuildPlugins.DOKKA)
apply {
from("$rootDir/versions.gradle.kts")
}
tasks {
withType<JavaCompile> {
options.isIncremental = true
allprojects {
options.compilerArgs.addAll(
arrayOf(
"-Xlint:-unchecked",
"-Xlint:deprecation",
"-Xdiags:verbose"
)
)
}
}
withType<KotlinCompile> {
kotlinOptions {
jvmTarget = javaVersion.toString()
// https://youtrack.jetbrains.com/issue/KT-24946
kotlinOptions.freeCompilerArgs = listOf(
"-progressive",
"-Xskip-runtime-version-check",
"-Xdisable-default-scripting-plugin"
)
kotlinOptions.allWarningsAsErrors = shouldTreatCompilerWarningsAsErrors()
}
}
withType<Test> {
testLogging {
// set options for log level LIFECYCLE
events = setOf(FAILED, STARTED, PASSED, SKIPPED, STANDARD_OUT)
exceptionFormat = FULL
showExceptions = true
showCauses = true
showStackTraces = true
}
maxParallelForks =
(Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
}
}
}
jacoco {
toolVersion = Versions.jacoco
}
tasks {
register("clean", Delete::class) {
delete = setOf(rootProject.buildDir)
}
}
fun shouldTreatCompilerWarningsAsErrors(): Boolean {
return project.findProperty("warningsAsErrors") == "true"
}