-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
312 lines (281 loc) · 9.01 KB
/
build.gradle
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
import groovy.xml.XmlParser
plugins {
id "com.diffplug.spotless" version "6.25.0"
id "com.github.ben-manes.versions" version "0.51.0"
id "com.github.spotbugs" version "6.0.8"
// id "de.aaschmid.cpd" version "3.3"
id "eclipse"
id "jacoco"
id "java"
id "java-test-fixtures" /* Used for publishing test fixtures package */
id "maven-publish"
id "net.ltgt.errorprone" version "3.1.0"
id "org.openstreetmap.josm" version "0.8.2"
id "org.sonarqube" version "4.4.1.3373"
id "pmd"
}
archivesBaseName = "mapwithai"
def gitlabGroup = "gokaart"
def gitlabRepositoryName = "JOSM_MapWithAI"
repositories {
mavenCentral()
maven {
url "https://josm.openstreetmap.de/nexus/content/repositories/releases/"
}
}
def versions = [
awaitility: "4.2.0",
equalsverifier: "3.15.8",
errorprone: "2.26.0",
findsecbugs: "1.13.0",
jacoco: "0.8.10",
jmockit: "1.49.a",
josm: properties.get("plugin.compile.version"),
junit: "5.10.2",
pmd: "6.20.0",
spotbugs: "4.8.3",
wiremock: "2.35.0",
]
dependencies {
spotbugsPlugins "com.h3xstream.findsecbugs:findsecbugs-plugin:${versions.findsecbugs}"
errorprone("com.google.errorprone:error_prone_core:${versions.errorprone}")
testFixturesImplementation("org.junit.jupiter:junit-jupiter-api:${versions.junit}")
testFixturesRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${versions.junit}")
testFixturesImplementation("org.junit.vintage:junit-vintage-engine:${versions.junit}")
testFixturesImplementation("org.junit.jupiter:junit-jupiter-params:${versions.junit}")
testFixturesImplementation("org.jmockit:jmockit:${versions.jmockit}")
testFixturesImplementation("com.github.spotbugs:spotbugs-annotations:${versions.spotbugs}")
testFixturesImplementation("org.openstreetmap.josm:josm:${versions.josm}")
testFixturesImplementation("org.openstreetmap.josm:josm-unittest:"){changing=true}
testFixturesImplementation("com.github.tomakehurst:wiremock-jre8:${versions.wiremock}")
testFixturesImplementation("org.awaitility:awaitility:${versions.awaitility}")
testImplementation("nl.jqno.equalsverifier:equalsverifier:${versions.equalsverifier}")
}
configurations {
testImplementation.extendsFrom testFixturesImplementation
testRuntimeOnly.extendsFrom testFixturesRuntimeOnly
intTestRuntimeOnly.extendsFrom testRuntimeOnly
intTestImplementation.extendsFrom testImplementation
}
int getJavaVersion() {
// We want to use whatever Java version CI has as default
def ci = project.hasProperty("isCI") or project.hasProperty("CI") or System.getenv("CI") != null
// But we want to override if someone set a specific Java version
def javaVersion = System.getenv("JAVA_VERSION")?.isInteger() ? Integer.valueOf(System.getenv("JAVA_VERSION")) : null
if (javaVersion != null) {
return javaVersion
}
if (ci) {
return Integer.valueOf(JavaVersion.current().getMajorVersion())
}
return 17
}
logger.lifecycle("Using Java " + getJavaVersion())
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(getJavaVersion()))
}
}
// Set up Errorprone
tasks.withType(JavaCompile).configureEach {
options.errorprone {
error(
"ClassCanBeStatic",
"DefaultCharset",
"ReferenceEquality",
"WildcardImport"
)
warn(
"ConstantField",
"FieldCanBeFinal",
"LambdaFunctionalInterface",
"MethodCanBeStatic",
"MultiVariableDeclaration",
"PrivateConstructorForUtilityClass",
"RemoveUnusedImports",
"UngroupedOverloads"
)
}
}
rootProject.tasks.named("jar") {
duplicatesStrategy = 'include'
}
sourceSets {
test {
java {
srcDirs = ["src/test/unit"]
}
resources {
srcDirs = ["src/test/resources"]
}
}
testFixtures {
java {
srcDirs = ["src/test/unit"]
setIncludes(new HashSet(['org/openstreetmap/josm/plugins/mapwithai/testutils/**/*.java']))
}
resources {
srcDirs = ["src/test/resources"]
}
}
intTest {
compileClasspath += sourceSets.main.output
compileClasspath += sourceSets.test.output
runtimeClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.test.output
java {
srcDirs = ["src/test/integration"]
}
resources {
srcDirs = ["src/test/resources"]
}
}
}
test {
project.afterEvaluate {
jvmArgs("-javaagent:${classpath.find { it.name.contains("jmockit") }.absolutePath}")
jvmArgs("-Djunit.jupiter.extensions.autodetection.enabled=true")
jvmArgs("-Djava.awt.headless=true")
}
useJUnitPlatform()
ignoreFailures
testLogging {
exceptionFormat "full"
events "skipped", "failed"
info {
showStandardStreams true
}
}
}
task integrationTest(type: Test) {
description = "Run integration tests"
group = "verification"
testClassesDirs = sourceSets.intTest.output.classesDirs
classpath = sourceSets.intTest.runtimeClasspath
shouldRunAfter test
// Ignore failures -- servers may or may not be down
ignoreFailures = true
}
check.dependsOn integrationTest
tasks.processResources {
// Note: src/${source_set}/resources is automatically copied
// processResources uses the `main` source set.
// https://docs.gradle.org/current/userguide/building_java_projects.html#sec:java_resources
from("$projectDir/LICENSE")
from("$projectDir/README.md")
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.80
}
}
}
}
spotless {
java {
eclipse().configFile "config/josm_formatting.xml"
endWithNewline()
importOrder('javax', 'java', 'org', 'com', '')
indentWithSpaces(4)
licenseHeader "// License: GPL. For details, see LICENSE file."
ratchetFrom("origin/master")
removeUnusedImports()
trimTrailingWhitespace()
}
}
josm {
debugPort = 7055
manifest {
setMinJavaVersion 17
oldVersionDownloadLink 18218, "v1.9.20", new URL("https://github.com/JOSM/MapWithAI/releases/download/v1.9.20/mapwithai.jar")
oldVersionDownloadLink 17903, "v1.8.7", new URL("https://github.com/JOSM/MapWithAI/releases/download/v1.8.7/mapwithai.jar")
oldVersionDownloadLink 17084, "v1.7.1.6", new URL("https://github.com/JOSM/MapWithAI/releases/download/v1.7.1.6/mapwithai.jar")
oldVersionDownloadLink 16645, "v1.6.8", new URL("https://github.com/JOSM/MapWithAI/releases/download/v1.6.8/mapwithai.jar")
oldVersionDownloadLink 16284, "v1.5.10", new URL("https://github.com/JOSM/MapWithAI/releases/download/v1.5.10/mapwithai.jar")
oldVersionDownloadLink 16220, "v1.4.7", new URL("https://github.com/JOSM/MapWithAI/releases/download/v1.4.7/mapwithai.jar")
oldVersionDownloadLink 15820, "v1.3.11", new URL("https://github.com/JOSM/MapWithAI/releases/download/v1.3.11/mapwithai.jar")
oldVersionDownloadLink 15737, "v1.2.7", new URL("https://github.com/JOSM/MapWithAI/releases/download/v1.2.7/mapwithai.jar")
oldVersionDownloadLink 15609, "v1.1.12", new URL("https://github.com/JOSM/MapWithAI/releases/download/v1.1.12/mapwithai.jar")
oldVersionDownloadLink 15542, "v1.0.9", new URL("https://github.com/JOSM/MapWithAI/releases/download/v1.0.9/mapwithai.jar")
oldVersionDownloadLink 15233, "v0.2.14", new URL("https://github.com/JOSM/MapWithAI/releases/download/v0.2.14/mapwithai.jar")
}
i18n {
pathTransformer = getPathTransformer(project.projectDir, "gitlab.com/${gitlabGroup}/${gitlabRepositoryName}/blob")
}
}
tasks.withType(JavaCompile) {
options.compilerArgs += [
"-Xlint:all",
"-Xlint:-serial",
]
}
// Set up JaCoCo
jacoco {
toolVersion = "${versions.jacoco}"
}
jacocoTestReport {
dependsOn test
reports {
xml.required.set(true)
html.required.set(true)
}
}
check.dependsOn jacocoTestReport
// Set up PMD
pmd {
toolVersion = versions.pmd
ignoreFailures true
incrementalAnalysis = true
ruleSets = []
ruleSetConfig = resources.text.fromFile("$projectDir/config/pmd/ruleset.xml")
sourceSets = [sourceSets.main]
}
// Set up SpotBugs
spotbugs {
toolVersion = versions.spotbugs
ignoreFailures = true
}
spotbugsMain {
reports {
xml.required.set(false)
html.required.set(true)
}
}
publishing {
publications {
maven(MavenPublication) {
groupId = "org.openstreetmap.josm.plugins"
artifactId = archivesBaseName
version = project.version
from components.java
}
}
}
def ciJobToken = System.getenv("CI_JOB_TOKEN")
def projectId = System.getenv("CI_PROJECT_ID")
if (ciJobToken != null && projectId!= null) {
publishing.repositories.maven {
url = "https://gitlab.com/api/v4/projects/$projectId/packages/maven"
name = "gitlab"
credentials(HttpHeaderCredentials.class) {
name = "Job-Token"
value = ciJobToken
}
authentication {
create("auth", HttpHeaderAuthentication.class)
}
}
}
sonarqube {
properties {
property "sonar.organization", "mapwithai"
property "sonar.projectKey", "mapwithai"
property "sonar.forceAuthentication", "true"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.projectDescription", properties.get("plugin.description")
property "sonar.projectVersion", project.version
property "sonar.sources", ["src"]
}
}