-
Notifications
You must be signed in to change notification settings - Fork 18
/
build.gradle.kts
90 lines (80 loc) · 3.11 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
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektPlugin
import io.gitlab.arturbosch.detekt.report.ReportMergeTask
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.DokkaBaseConfiguration
plugins {
id("documented")
id("code-quality")
}
// generate API documentation for website
tasks.dokkaHtmlMultiModule.configure {
// add API docs to directory used for website generation
outputDirectory.set(
project.rootDir.resolve("docs").resolve("api").resolve("codyze")
)
// path to Dokka assets
val dokkaAssetsBaseDirectory =
project.rootDir.resolve("docs").resolve("assets").resolve("dokka")
// configure custom assets
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
// use custom stylesheets without external content
customStyleSheets =
listOf(
dokkaAssetsBaseDirectory.resolve("style.css"),
dokkaAssetsBaseDirectory.resolve("jetbrains-mono.css"),
)
}
// copy over font files
dokkaAssetsBaseDirectory
.resolve("JetBrainsMono")
.copyRecursively(
target = file(outputDirectory).resolve("styles").resolve("JetBrainsMono"),
overwrite = true,
)
dokkaAssetsBaseDirectory
.resolve("inter")
.copyRecursively(
target = file(outputDirectory).resolve("styles").resolve("inter"),
overwrite = true,
)
}
// adapted from https://blog.mrhaki.com/2021/03/gradle-goodness-create-properties-file.html
val projectProps by tasks.registering(WriteProperties::class) {
description = "Write project properties in a file."
// Set output file to build/project.properties
destinationFile = layout.buildDirectory.file("codyze.properties")
// Default encoding is ISO-8559-1, here we change it.
encoding = "UTF-8"
// Optionally we can specify the header comment.
comment = "Version of subprojects and name of project"
// Add project name as property
property("project.name", project.name)
// Add version of each subproject as separate properties
for (subproject in subprojects) {
property("${subproject.name}.version", subproject.version)
}
}
// configure detekt to combine the results of all submodules into a single sarif file -> for GitHub code scanning
val detektReportMergeSarif by tasks.registering(ReportMergeTask::class) {
output.set(rootProject.layout.buildDirectory.file("reports/detekt/detekt.sarif"))
}
subprojects {
plugins.withType<DetektPlugin> {
tasks.withType<Detekt> detekt@{ // Sadly it has to be eager.
finalizedBy(detektReportMergeSarif)
detektReportMergeSarif.configure {
input.from(this@detekt.sarifReportFile)
}
}
}
}
/*
* Optional and experimental features
*/
// this code block also exists in `settings.gradle.kts`
val enablePluginSupport: Boolean by extra {
val enablePluginSupport: String? by project
enablePluginSupport.toBoolean()
}
project.logger.lifecycle("Plugin feature is ${if (enablePluginSupport) "enabled" else "disabled"}")