-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle.kts
107 lines (84 loc) · 2.74 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
plugins {
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlin.serialization) apply false
// Versioning
alias(libs.plugins.git.version)
// Documentation
alias(libs.plugins.dokka)
// Style checking
alias(libs.plugins.spotless)
}
// Derive version from Git tags
val gitVersion: groovy.lang.Closure<String> by extra
val versionFromGit = gitVersion()
allprojects {
apply(plugin = "com.diffplug.spotless")
group = "io.github.apl-cornell.${rootProject.name}"
version = if (versionFromGit == "unspecified") "0.0.0-SNAPSHOT" else versionFromGit
ext.set("rootPackage", (group as String).replace("-", ""))
/** Style */
spotless {
java {
target("src/**/*.java")
googleJavaFormat()
}
kotlinGradle {
ktlint()
}
}
pluginManager.withPlugin("kotlin") {
spotless {
kotlin {
val relativeBuildPath = project.layout.buildDirectory.asFile.get().relativeTo(project.projectDir)
targetExclude("$relativeBuildPath/**/*.kt")
ktlint()
}
}
}
}
/** Kotlin Conventions */
// TODO: move into buildSrc when this is fixed: https://youtrack.jetbrains.com/issue/KT-41142
subprojects {
pluginManager.withPlugin("kotlin") {
apply(plugin = "jacoco")
apply(plugin = "org.jetbrains.dokka")
/** Java Version */
configure<JavaPluginExtension> {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.allWarningsAsErrors = true
}
/** Dependencies */
dependencies {
// Logging
"implementation"(libs.kotlin.logging)
"testImplementation"(platform(libs.log4j.bom))
"testImplementation"(libs.log4j.core)
"testImplementation"(libs.log4j.slf4j2.impl)
}
/** Testing */
tasks.withType<Test>().configureEach {
useJUnitPlatform()
// Rerun tests when code examples change.
inputs.files(project.fileTree("tests"))
}
tasks.withType<JacocoReport>().configureEach {
reports {
xml.required.set(true)
html.required.set(true)
}
dependsOn(tasks.withType<Test>())
}
/** API Documentation */
tasks.withType<org.jetbrains.dokka.gradle.AbstractDokkaLeafTask>().configureEach {
dokkaSourceSets {
configureEach {
includes.from("Module.md")
}
}
}
}
}