forked from ePages-de/restdocs-api-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
executable file
·125 lines (101 loc) · 3.67 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.kt3k.gradle.plugin.CoverallsPluginExtension
import pl.allegro.tech.build.axion.release.domain.TagNameSerializationConfig
import pl.allegro.tech.build.axion.release.domain.hooks.HooksConfig
plugins {
id("com.github.kt3k.coveralls") version "2.8.2"
id("io.github.gradle-nexus.publish-plugin") version "1.0.0"
id("org.jmailen.kotlinter") version "3.3.0" apply false
id("pl.allegro.tech.build.axion-release") version "1.9.2"
jacoco
java
kotlin("jvm") version "1.4.20" apply false
`maven-publish`
}
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 = "dev.marcosalmeida"
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 { "2.1.9.RELEASE" }
val springRestDocsVersion by extra { "2.0.4.RELEASE" }
val junitVersion by extra { "5.4.2" }
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
if (!isSampleProject()) {
tasks.withType<JacocoReport> {
dependsOn("test")
reports {
html.isEnabled = true
xml.isEnabled = true
}
}
}
}
//coverall multi module plugin configuration starts here
configure<CoverallsPluginExtension> {
sourceDirs = nonSampleProjects.flatMap { it.sourceSets["main"].allSource.srcDirs }.filter { it.exists() }.map { it.path }
jacocoReportPath = "$buildDir/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}
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("coveralls").dependsOn(jacocoRootReport)
}
nexusPublishing {
repositories {
sonatype ()
}
}