/
build.gradle.kts
208 lines (178 loc) · 5.96 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
import com.jfrog.bintray.gradle.BintrayExtension
import net.ltgt.gradle.errorprone.ErrorProneToolChain
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
`maven-publish`
java
jacoco
checkstyle
pmd
id("info.solidsoft.pitest") version "1.5.1"
id("com.jfrog.bintray") version "1.6"
id("net.ltgt.errorprone-base") version "0.0.13"
id("com.github.spotbugs") version "4.2.4"
}
repositories {
jcenter()
}
dependencies {
implementation("com.esotericsoftware:kryo:4.0.1")
implementation("com.google.protobuf:protobuf-java:3.5.0")
implementation("io.reactivex:rxjava:1.3.4")
implementation("org.jetbrains:annotations:15.0")
errorprone("com.google.errorprone:error_prone_core:2.1.2")
testImplementation("junit:junit:4.12")
testImplementation("nl.jqno.equalsverifier:equalsverifier:2.3.3")
}
fun linkGitHub(resource: String = "") = "https://github.com/${project.name}/${project.name}$resource"
val archivesBaseNameProperty = "archivesBaseName"
project.setProperty(archivesBaseNameProperty, project.name.toLowerCase())
val archivesBaseName = { "${project.property(archivesBaseNameProperty)}" }
group = project.name.toLowerCase()
version = "2.1.0"
description = "A small distributed event library for the JVM"
val testSourceSet = sourceSets["test"]!!
sourceSets.create("pitest") {
java {
srcDirs(testSourceSet.java.srcDirs)
exclude("rxbroadcast/integration/**")
}
compileClasspath += files(testSourceSet.compileClasspath)
runtimeClasspath += compileClasspath
}
tasks.withType<JavaCompile> {
options.compilerArgs.addAll(arrayOf("-Xlint:all", "-Xdiags:verbose", "-Werror"))
sourceCompatibility = "${JavaVersion.VERSION_1_8}"
targetCompatibility = "${JavaVersion.VERSION_1_8}"
}
tasks.withType<Javadoc> {
options.optionFiles(file("config/javadoc.opts"))
}
tasks.withType<Test> {
exclude("rxbroadcast/integration/**")
testLogging {
exceptionFormat = TestExceptionFormat.FULL
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
showStandardStreams = true
}
}
task("errorProne") {
tasks.withType<JavaCompile>().all {
toolChain = ErrorProneToolChain(configurations.getByName("errorprone"))
}
dependsOn.add(tasks.withType<JavaCompile>())
}
task<Jar>("testJar") {
archiveClassifier.set("tests")
group = "verification"
description = "Assembles a jar archive containing the test classes."
afterEvaluate {
val sourceSets = convention.getPlugin(JavaPluginConvention::class).sourceSets
val files = configurations.testCompileClasspath.get().files.map(fun (file: File): Any = when {
file.isDirectory -> file
else -> zipTree(file)
})
from(sourceSets.findByName("main")!!.output + sourceSets.findByName("test")!!.output)
from(files) {
exclude("META-INF/**")
}
}
}
pitest {
excludedMethods.set(setOf("toString", "newThread", "hashCode"))
detectInlinedCode.set(true)
timestampedReports.set(false)
mutationThreshold.set(80)
mutators.set(setOf("ALL"))
testSourceSets.set(setOf(sourceSets["pitest"]))
verbose.set((System.getenv("CI") ?: "false").toBoolean())
}
task<Jar>("sourcesJar") {
archiveClassifier.set("sources")
afterEvaluate {
val sourceSets = convention.getPlugin(JavaPluginConvention::class).sourceSets
from(sourceSets.findByName("main")!!.allSource)
}
}
task<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
afterEvaluate {
from(tasks.findByName("javadoc"))
}
}
pmd {
toolVersion = "6.21.0"
ruleSets = emptyList()
ruleSetFiles("config/pmd/rules.xml")
}
spotbugs {
toolVersion.set("4.0.3")
setEffort("max")
tasks.spotbugsMain {
reports.create("html") {
isEnabled = true
setStylesheet("fancy-hist.xsl")
}
}
tasks.spotbugsTest {
reports.create("html") {
isEnabled = true
setStylesheet("fancy-hist.xsl")
}
}
}
checkstyle {
toolVersion = "8.2"
}
jacoco {
toolVersion = "0.7.9"
}
publishing {
publications {
create(project.name.toLowerCase(), MavenPublication::class.java) {
from(components.findByName("java"))
artifactId = archivesBaseName()
artifact(tasks.getByName("javadocJar"))
artifact(tasks.getByName("sourcesJar"))
pom {
withXml {
asNode().apply {
appendNode("name", project.name)
appendNode("description", project.description)
appendNode("url", "http://${project.name.toLowerCase()}.website")
appendNode("packaging", "jar")
appendNode("licenses").appendNode("license").apply {
appendNode("name", "ISC")
appendNode("url", linkGitHub("/raw/master/LICENSE.md"))
}
appendNode("scm").apply {
appendNode("url", linkGitHub())
}
appendNode("issueManagement").apply {
appendNode("system", "GitHub Issues")
appendNode("url", linkGitHub("/issues"))
}
}
}
}
}
}
}
configure<BintrayExtension> {
user = System.getenv("BINTRAY_USER")
key = System.getenv("BINTRAY_API_KEY")
setPublications(project.name.toLowerCase())
publish = true
pkg = PackageConfig().apply {
repo = "maven"
name = project.name
vcsUrl = linkGitHub()
setLicenses("ISC")
version = VersionConfig().apply {
name = project.version.toString()
desc = project.description
}
}
}