forked from ePages-de/restdocs-api-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
executable file
·157 lines (131 loc) · 4.95 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import com.jfrog.bintray.gradle.BintrayExtension
import com.jfrog.bintray.gradle.BintrayExtension.GpgConfig
import com.jfrog.bintray.gradle.BintrayExtension.PackageConfig
import com.jfrog.bintray.gradle.BintrayExtension.VersionConfig
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 {
java
kotlin("jvm") version "1.3.41" apply false
id("pl.allegro.tech.build.axion-release") version "1.9.2"
jacoco
`maven-publish`
id("org.jmailen.kotlinter") version "1.25.2" apply false
id("com.github.kt3k.coveralls") version "2.8.2"
id("com.jfrog.bintray") version "1.8.4" 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.9.9" }
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
}
}
val sourcesJar by tasks.creating(Jar::class) {
classifier = "sources"
from(sourceSets["main"].allSource)
}
publishing {
publications {
(publications) {
register("mavenJava", MavenPublication::class) {
from(components["java"])
artifact(sourcesJar)
}
}
}
}
apply(plugin = "com.jfrog.bintray")
configure<BintrayExtension> {
user = project.findProperty("bintrayUser") as String? ?: System.getenv("BINTRAY_USER")
key = project.findProperty("bintrayApiKey") as String? ?: System.getenv("BINTRAY_API_KEY")
publish = true
setPublications("mavenJava")
pkg(closureOf<PackageConfig> {
repo = "maven"
name = "restdocs-api-spec"
userOrg = "epages"
version(closureOf<VersionConfig> {
gpg(closureOf<GpgConfig> {
sign = 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)
}