forked from hexagontk/hexagon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
102 lines (85 loc) · 3.27 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
import com.github.jk1.license.LicenseReportExtension
import com.github.jk1.license.render.CsvReportRenderer
import com.github.jk1.license.render.InventoryHtmlReportRenderer
import com.github.jk1.license.render.InventoryMarkdownReportRenderer
import com.github.jk1.license.render.ReportRenderer
/*
* Main build script, responsible for:
*
* 1. Publishing: upload binaries and templates to Maven Central
* 2. Releasing: tag source code in GitHub
* 3. Coverage report: aggregated coverage report for all modules
* 4. Handle Docker containers: take care of tasks depending on Docker and containers clean up
*
* Plugins that are not used in the root project (this one) are only applied by the modules that use
* them.
*/
plugins {
kotlin("jvm") version("1.8.21") apply(false)
id("idea")
id("eclipse")
id("project-report")
id("org.jetbrains.dokka") version("1.8.10")
id("com.github.jk1.dependency-license-report") version("2.2")
id("org.jetbrains.kotlinx.binary-compatibility-validator") version("0.13.1")
id("org.graalvm.buildtools.native") version("0.9.22") apply(false)
id("io.gitlab.arturbosch.detekt") version("1.22.0") apply(false)
id("me.champeau.jmh") version("0.7.1") apply(false)
}
apply(from = "gradle/certificates.gradle")
defaultTasks("build")
repositories {
mavenCentral()
}
task("setUp") {
group = "build setup"
description = "Set up project for development. Creates the Git pre push hook (run build task)."
doLast {
val dotfiles = "https://raw.githubusercontent.com/hexagonkt/.github/master"
exec { commandLine("curl $dotfiles/.gitignore -o .gitignore".split(" ")) }
exec { commandLine("curl $dotfiles/commit_template.txt -o .git/message".split(" ")) }
exec { commandLine("curl $dotfiles/.editorconfig -o .editorconfig".split(" ")) }
exec { commandLine("git config commit.template .git/message".split(" ")) }
val prePush = file(".git/hooks/pre-push")
prePush.writeText("""
#!/usr/bin/env sh
set -e
./gradlew
""".trimIndent() + "\n")
prePush.setExecutable(true)
}
}
task("release") {
group = "publishing"
description = "Tag the source code with the version number after publishing all artifacts."
dependsOn(project.getTasksByName("publish", true))
doLast {
val release = version.toString()
val actor = System.getenv("GITHUB_ACTOR")
project.exec { commandLine = listOf("git", "config", "--global", "user.name", actor) }
project.exec { commandLine = listOf("git", "tag", "-m", "Release $release", release) }
project.exec { commandLine = listOf("git", "push", "--tags") }
}
}
extensions.configure<LicenseReportExtension> {
projects = subprojects.toTypedArray()
renderers = arrayOf<ReportRenderer>(
CsvReportRenderer(),
InventoryHtmlReportRenderer(),
InventoryMarkdownReportRenderer(),
)
}
gradle.taskGraph.whenReady(closureOf<TaskExecutionGraph> {
if (logger.isInfoEnabled) {
allTasks.forEach { task ->
logger.info(task.toString())
task.dependsOn.forEach { logger.info(" - $it") }
}
}
})
apiValidation {
validationDisabled = true
}
subprojects {
apply(from = "$rootDir/gradle/detekt.gradle")
}