forked from fastluca/JRis
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
131 lines (115 loc) · 3.54 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import org.jetbrains.dokka.gradle.DokkaTaskPartial
import java.net.URI
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath(libs.plugin.kotlin)
}
}
plugins {
kotlin("jvm") version libs.versions.kotlin.get()
id("kris-collect-sarif")
alias(libs.plugins.sonarqube)
alias(libs.plugins.dokka)
alias(libs.plugins.nexusPublish)
alias(libs.plugins.binaryCompatValidator)
`maven-publish`
jacoco
}
kotlin {
jvmToolchain(libs.versions.java.get().toInt())
}
jacoco {
toolVersion = libs.versions.jacoco.get()
}
sonarqube {
properties {
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.projectKey", "ursjoss_${project.name}")
property("sonar.organization", "ursjoss-github")
}
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
val ossrhUsername = providers.environmentVariable("OSSRH_USERNAME")
val ossrhPassword = providers.environmentVariable("OSSRH_PASSWORD")
if (ossrhUsername.isPresent && ossrhPassword.isPresent) {
username.set(ossrhUsername.get())
password.set(ossrhPassword.get())
}
}
}
}
val kotlinSrcSet = "/src/main/kotlin"
dokka {
dokkaSourceSets.main {
sourceLink {
localDirectory.set(file("$projectDir/$kotlinSrcSet"))
remoteUrl.set(URI.create(projectRelativeSourceLink()).toURL().toURI())
remoteLineSuffix.set("#L")
}
}
}
dependencies {
dokka(project(":kris-core:"))
dokka(project(":kris-io"))
}
tasks {
val deleteOutFolderTask by registering(Delete::class) {
delete("out")
}
named("clean") {
delete(rootProject.layout.buildDirectory.get())
dependsOn(deleteOutFolderTask)
}
}
subprojects.forEach { subProject ->
if (subProject.name in setOf("kris-core", "kris-io")) {
apply {
plugin("org.sonarqube")
plugin("jacoco")
}
sonarqube {
properties {
property(
"sonar.kotlin.detekt.reportPaths",
subProject.layout.buildDirectory.get().asFile.resolve("reports/detekt/detekt.xml")
)
property(
"sonar.coverage.jacoco.xmlReportPaths",
subProject.layout.buildDirectory.get().asFile.resolve("reports/jacoco/test/jacocoTestReport.xml")
)
}
}
}
subProject.tasks {
withType<Test> {
useJUnitPlatform {
includeEngines("junit-jupiter", "kotest")
}
}
withType<DokkaTaskPartial>().configureEach {
dokkaSourceSets {
configureEach {
includes.from("module.md")
}
}
}
}
}
// see https://github.com/detekt/detekt/issues/6198
configurations.matching { it.name == "detekt" }.all {
resolutionStrategy.eachDependency {
if (requested.group == "org.jetbrains.kotlin") {
useVersion(libs.versions.detektKotlinVersion.get())
}
}
}
fun Project.projectRelativeSourceLink(branch: String = "main", srcSet: String = kotlinSrcSet) =
"https://github.com/ursjoss/KRis/blob/$branch/${projectDir.relativeTo(rootDir)}/$srcSet"
fun String.mayHaveTestCoverage(): Boolean = startsWith("kris")