-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
216 lines (195 loc) · 5.98 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
import com.github.spotbugs.SpotBugsTask
import net.ltgt.gradle.errorprone.CheckSeverity
import org.openstreetmap.josm.gradle.plugin.task.GeneratePluginList
import java.nio.file.Files
import java.nio.file.Paths
plugins {
id "java"
id "eclipse"
id "jacoco"
id "maven-publish"
id "pmd"
id "com.github.ben-manes.versions" version "0.27.0"
id "com.github.spotbugs" version "3.0.0"
id "org.openstreetmap.josm" version "0.6.5"
id "net.ltgt.errorprone" version "1.1.1"
//id 'de.aaschmid.cpd' version '2.0'
}
// Set up Errorprone
tasks.withType(JavaCompile).configureEach {
options.errorprone {
check("DefaultCharset", CheckSeverity.ERROR)
check("StringEquality", CheckSeverity.ERROR)
check("ConstantField", CheckSeverity.WARN)
check("FieldCanBeFinal", CheckSeverity.WARN)
check("LambdaFunctionalInterface", CheckSeverity.WARN)
check("MethodCanBeStatic", CheckSeverity.WARN)
check("MultiVariableDeclaration", CheckSeverity.WARN)
check("PrivateConstructorForUtilityClass", CheckSeverity.WARN)
check("UngroupedOverloads", CheckSeverity.WARN)
check("WildcardImport", CheckSeverity.WARN)
// TODO remove this on errorprone update
if ((JavaVersion.current().majorVersion as Integer) > 11) {
check('Finally', CheckSeverity.OFF)
}
}
}
archivesBaseName = "highwayNameModification"
def gitlabGroup = "gokaart"
def gitlabRepositoryName = "JOSM_highwayNameModification"
def versions = [
awaitility: "4.0.1",
errorprone: "2.3.4",
jacoco: "0.8.5",
jmockit: "1.46",
junit: "5.5.2",
pmd: "6.20.0",
spotbugs: "4.0.0-beta4",
wiremock: "2.25.1",
findsecbugs: "1.10.1",
]
repositories {
jcenter()
mavenCentral()
}
dependencies {
if (!JavaVersion.current().isJava9Compatible()) {
errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
}
spotbugsPlugins "com.h3xstream.findsecbugs:findsecbugs-plugin:${versions.findsecbugs}"
errorprone("com.google.errorprone:error_prone_core:${versions.errorprone}")
testImplementation("org.junit.jupiter:junit-jupiter-api:${versions.junit}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${versions.junit}")
testImplementation("org.junit.vintage:junit-vintage-engine:${versions.junit}")
testCompile("org.jmockit:jmockit:${versions.jmockit}")
testImplementation("com.github.spotbugs:spotbugs-annotations:${versions.spotbugs}")
testImplementation("org.openstreetmap.josm:josm-unittest:"){changing=true}
testImplementation("com.github.tomakehurst:wiremock:${versions.wiremock}")
testImplementation("org.awaitility:awaitility:${versions.awaitility}")
}
// Add dependencies from ivy.xml
def ivyModule = new XmlParser().parse(new File("$projectDir/ivy.xml"))
logger.info("Dependencies from ivy.xml (added to configuration `packIntoJar`):")
ivyModule.dependencies.dependency.each {
logger.info(" * ${it.@org}:${it.@name}:${it.@rev}")
project.dependencies.packIntoJar("${it.@org}:${it.@name}:${it.@rev}")
}
test {
project.afterEvaluate {
jvmArgs("-javaagent:${classpath.find { it.name.contains("jmockit") }.absolutePath}")
}
useJUnitPlatform()
testLogging {
exceptionFormat "full"
events "skipped", "failed"
info {
showStandardStreams true
}
}
}
sourceSets {
test {
java {
srcDirs = ["test/unit"]
}
resources {
srcDirs = ["test/data"]
}
}
}
tasks.processResources {
from("$projectDir/LICENSE")
from("$projectDir/README.md")
from("$projectDir/src/resources")
from("$projectDir/src/main/resources")
}
josm {
manifest {
oldVersionDownloadLink 15038, "v0.0.9,", new URL("https://gokaart.gitlab.io/JOSM_highwayNameModification/dist/v0.0.9/highwayNameModification.jar")
}
i18n {
pathTransformer = getPathTransformer("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.enabled = true
html.enabled = 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
sourceSets = [sourceSets.main]
}
tasks.withType(SpotBugsTask) {
reports {
xml.enabled = false
html.enabled = true
}
}
task generateSnapshotUpdateSite(type: GeneratePluginList) {
dependsOn(tasks.processResources)
outputFile = new File(project.buildDir, "snapshot-update-site")
versionSuffix = {a -> ""}
doFirst {
def pluginDownloadUrl = "https://${gitlabGroup}.gitlab.io/${gitlabRepositoryName}/snapshot/master/${archivesBaseName}.jar"
it.iconBase64Provider = {
def file = new File(sourceSets.main.resources.srcDirs[0], it)
if (file.exists()) {
def contentType = file.name.endsWith(".svg") ? "svg+xml" : "png"
return "data:image/" + contentType + ";base64," + Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get(file.toURI())));
}
}
it.addPlugin("$archivesBaseName-dev.jar", project.josm.manifest.createJosmPluginJarManifest(), new URL(pluginDownloadUrl))
}
}
project.afterEvaluate {
publishing {
publications {
plugin(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)
}
}
}