forked from junit-pioneer/junit-pioneer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
214 lines (187 loc) · 7.39 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
209
210
211
212
213
214
plugins {
java
jacoco
checkstyle
`maven-publish`
id("com.diffplug.gradle.spotless") version "3.27.1"
id("org.shipkit.java") version "2.2.5"
id("at.zierler.yamlvalidator") version "1.5.0"
id("org.sonarqube") version "2.8"
}
group = "org.junit-pioneer"
description = "JUnit 5 Extension Pack"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}
// assign empty user name and password, so Gradle does not fail due to
// missing properties when eagerly configuring the Maven credentials
val mavenUserName: String? by project
val mavenPassword: String? by project
val isReleaseVersion = !version.toString().endsWith("-SNAPSHOT")
val travisApiToken: String? by project
repositories {
mavenCentral()
maven {
name = "MavenSnapshot"
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
}
dependencies {
implementation(group = "org.junit.jupiter", name = "junit-jupiter-api", version = "5.4.2")
implementation(group = "org.junit.jupiter", name = "junit-jupiter-params", version = "5.4.2")
testImplementation(group = "org.junit.jupiter", name = "junit-jupiter-engine", version = "5.4.2")
testImplementation(group = "org.junit.platform", name = "junit-platform-launcher", version = "1.4.2")
testImplementation(group = "org.junit.platform", name = "junit-platform-testkit", version = "1.4.2")
testImplementation(group = "org.assertj", name = "assertj-core", version = "3.15.0")
testImplementation(group = "org.mockito", name = "mockito-core", version = "3.3.3")
testImplementation(group = "com.google.jimfs", name = "jimfs", version = "1.1")
testRuntimeOnly(group = "org.apache.logging.log4j", name = "log4j-core", version = "2.12.1")
testRuntimeOnly(group = "org.apache.logging.log4j", name = "log4j-jul", version = "2.12.1")
}
spotless {
val headerFile = file(".infra/spotless/eclipse-public-license-2.0.java")
java {
licenseHeaderFile(headerFile, "(package|import) ")
importOrderFile(file(".infra/eclipse/junit-eclipse.importorder"))
eclipse().configFile(".infra/eclipse/junit-eclipse-formatter-settings.xml")
trimTrailingWhitespace()
endWithNewline()
removeUnusedImports()
}
format("groovy") {
target("**/*.groovy")
indentWithTabs()
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile(headerFile, "package ")
replaceRegex("class-level Javadoc indentation fix", """^\*""", " *")
replaceRegex("nested Javadoc indentation fix", "\t\\*", "\t *")
}
}
checkstyle {
toolVersion = "7.8.2"
configDirectory.set(rootProject.file(".infra/checkstyle"))
}
yamlValidator {
searchPaths = listOf("docs")
isSearchRecursive = true
}
sonarqube {
// If you want to use this logcally a sonarLogin has to be provide, either via Username and Password
// or via token, https://docs.sonarqube.org/latest/analysis/analysis-parameters/
properties {
// Default properties if somebody wants to execute it locally
property("sonar.projectKey", "junit-pioneer_junit-pioneer") // needs to be changed
property("sonar.organization", "junit-pioneer-xp") // needs to be changed
property("sonar.host.url", "https://sonarcloud.io")
}
}
tasks {
test {
testLogging {
setExceptionFormat("full")
}
useJUnitPlatform()
filter {
includeTestsMatching("*Tests")
}
systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")
// `EnvironmentVariableExtension` uses reflection to change environment variables;
// this prevents the corresponding warning (and keeps working on Java 8)
// IF YOU ADD MORE OPTIONS; CONSIDER REPLACING `-XX:+IgnoreUnrecognizedVMOptions WITH A CONDITIONAL
jvmArgs(
"-XX:+IgnoreUnrecognizedVMOptions",
"--add-opens=java.base/java.util=ALL-UNNAMED")
}
javadoc {
// of all the javadoc checks (accessibility, html, missing, reference, syntax; see
// https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javadoc.html#BEJEFABE)
// disable the warning for missing comments and tags because they spam the output
// (it does often not make sense to comment every tag; e.g. the @return tag on annotations)
(options as CoreJavadocOptions).addStringOption("Xdoclint:accessibility,html,syntax,reference", "-quiet")
shouldRunAfter(test)
}
jacocoTestReport {
reports {
xml.isEnabled = true
xml.destination = file("${buildDir}/reports/jacoco/report.xml")
}
}
check {
// to find Javadoc errors early, let "javadoc" task run during "check"
dependsOn(javadoc, validateYaml)
}
// the manifest needs to declare the future module name
jar {
manifest {
attributes(
"Automatic-Module-Name" to "org.junitpioneer"
)
}
}
withType<Jar>().configureEach {
from(projectDir) {
include("LICENSE.md")
into("META-INF")
}
}
}
publishing {
publications {
create<MavenPublication>("complete") {
from(components["java"])
artifact(tasks.sourcesJar.get())
artifact(tasks.javadocJar.get())
pom {
name.set("JUnit Pioneer")
description.set("JUnit 5 Extension Pack")
url.set("https://github.com/junit-pioneer/junit-pioneer")
scm {
url.set("https://github.com/junit-pioneer/junit-pioneer")
connection.set("scm:git:git://github.com:junit-pioneer/junit-pioneer.git")
}
issueManagement {
url.set("https://github.com/junit-pioneer/junit-pioneer/issues")
system.set("GitHub")
}
licenses {
license {
name.set("Eclipse Public License v2.0")
url.set("http://www.eclipse.org/legal/epl-v20.html")
}
}
organization {
name.set("JUnit Pioneer")
url.set("https://github.com/junit-pioneer")
}
developers {
developer {
id.set("nipa")
name.set("Nicolai Parlog")
email.set("nipa@codefx.org")
organization.set("CodeFX")
organizationUrl.set("http://codefx.org")
timezone.set("1")
}
}
}
}
}
repositories {
maven {
val stagingRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
url = if (isReleaseVersion) stagingRepoUrl else snapshotRepoUrl
credentials {
username = mavenUserName
password = mavenPassword
}
}
}
}
tasks.register<org.junitpioneer.gradle.TriggerTravisTask>("triggerSiteBuild") {
travisProject = "junit-pioneer/junit-pioneer.github.io"
branch = "grandmaster"
apiToken = travisApiToken
message = "Triggered by successful JUnit Pioneer build for %COMMIT"
}