-
Notifications
You must be signed in to change notification settings - Fork 103
/
build.gradle.kts
executable file
·127 lines (103 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import pl.allegro.tech.build.axion.release.domain.TagNameSerializationConfig
import pl.allegro.tech.build.axion.release.domain.hooks.HooksConfig
plugins {
`maven-publish`
id("io.github.gradle-nexus.publish-plugin") version "1.0.0"
id("org.jmailen.kotlinter") version "3.3.0" apply false
id("org.sonarqube") version "4.0.0.2929"
id("pl.allegro.tech.build.axion-release") version "1.9.2"
jacoco
java
kotlin("jvm") version "1.7.22" apply false
}
repositories {
mavenCentral()
}
scmVersion {
tag(closureOf<TagNameSerializationConfig> {
prefix = ""
})
hooks(closureOf<HooksConfig> {
pre("fileUpdate", mapOf(
"file" to "README.md",
"pattern" to "{v,p -> /('$'v)/}",
"replacement" to """{v, p -> "'$'v"}]))"""))
pre("commit")
})
}
val scmVer = scmVersion.version
fun Project.isSampleProject() = this.name.contains("sample")
val nonSampleProjects = subprojects.filterNot { it.isSampleProject() }
allprojects {
group = "com.epages"
version = scmVer
if (!isSampleProject()) {
apply(plugin = "java")
apply(plugin = "kotlin")
apply(plugin = "jacoco")
apply(plugin = "maven-publish")
apply(plugin = "org.jmailen.kotlinter")
}
}
subprojects {
val jacksonVersion by extra { "2.12.2" }
val springBootVersion by extra { "3.0.2" }
val springRestDocsVersion by extra { "3.0.0" }
val junitVersion by extra { "5.4.2" }
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
if (!isSampleProject()) {
tasks.withType<JacocoReport> {
dependsOn("test")
reports {
html.isEnabled = true
xml.isEnabled = true
}
}
}
}
tasks {
val jacocoMerge by creating(JacocoMerge::class) {
executionData = files(nonSampleProjects.map { File(it.buildDir, "/jacoco/test.exec") })
doFirst {
executionData = files(executionData.filter { it.exists() })
}
}
val jacocoTestReport = this.getByName("jacocoTestReport")
jacocoTestReport.dependsOn(nonSampleProjects.map { it.tasks["jacocoTestReport"] })
jacocoMerge.dependsOn(jacocoTestReport)
val jacocoRootReport by creating(JacocoReport::class) {
description = "Generates an aggregate report from all subprojects"
group = "Coverage reports"
dependsOn(jacocoMerge)
sourceDirectories.setFrom(files(nonSampleProjects.flatMap { it.sourceSets["main"].allSource.srcDirs.filter { it.exists() && !it.path.endsWith("restdocs-api-spec-postman-generator/src/main/java") } } ))
classDirectories.setFrom(files(nonSampleProjects.flatMap { it.sourceSets["main"].output }.filter { !it.path.endsWith("restdocs-api-spec-postman-generator/build/classes/java/main") } ))
executionData(jacocoMerge.destinationFile)
reports {
html.isEnabled = true
xml.isEnabled = true
}
}
getByName("sonar").dependsOn(jacocoRootReport)
}
nexusPublishing {
repositories {
sonatype ()
}
}
sonar {
properties {
property("sonar.projectKey", "ePages-de_restdocs-api-spec")
property("sonar.organization", "epages-de")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.exclusions", "**/samples/**")
}
}