2019-09-14 14:25:04 +00:00
|
|
|
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"
|
2020-04-22 23:34:55 +00:00
|
|
|
id "com.github.ben-manes.versions" version "0.28.0"
|
2020-05-14 22:44:56 +00:00
|
|
|
id "com.github.spotbugs" version "4.2.0"
|
|
|
|
id "org.openstreetmap.josm" version "0.7.0"
|
2019-10-30 15:56:27 +00:00
|
|
|
id "net.ltgt.errorprone" version "1.1.1"
|
2020-05-12 16:06:20 +00:00
|
|
|
id "com.diffplug.gradle.spotless" version "3.30.0"
|
2019-09-29 12:01:34 +00:00
|
|
|
//id 'de.aaschmid.cpd' version '2.0'
|
2019-09-14 14:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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)
|
2019-10-02 15:17:59 +00:00
|
|
|
// TODO remove this on errorprone update
|
|
|
|
if ((JavaVersion.current().majorVersion as Integer) > 11) {
|
|
|
|
check('Finally', CheckSeverity.OFF)
|
|
|
|
}
|
2019-09-14 14:25:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-17 15:32:24 +00:00
|
|
|
archivesBaseName = "mapwithai"
|
|
|
|
def gitlabGroup = "gokaart"
|
2019-10-17 17:31:59 +00:00
|
|
|
def gitlabRepositoryName = "JOSM_MapWithAI"
|
2019-10-17 15:32:24 +00:00
|
|
|
|
|
|
|
|
2019-09-14 14:25:04 +00:00
|
|
|
def versions = [
|
2020-04-22 23:34:55 +00:00
|
|
|
awaitility: "4.0.2",
|
2019-12-03 21:01:53 +00:00
|
|
|
errorprone: "2.3.4",
|
2019-10-15 19:50:39 +00:00
|
|
|
jacoco: "0.8.5",
|
2019-10-02 14:46:00 +00:00
|
|
|
jmockit: "1.46",
|
2020-04-22 23:34:55 +00:00
|
|
|
junit: "5.6.2",
|
2019-12-18 21:13:08 +00:00
|
|
|
pmd: "6.20.0",
|
2020-05-12 16:06:20 +00:00
|
|
|
spotbugs: "4.0.3",
|
2020-04-22 23:34:55 +00:00
|
|
|
wiremock: "2.26.3",
|
2019-10-30 15:56:27 +00:00
|
|
|
findsecbugs: "1.10.1",
|
2019-09-14 14:25:04 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
jcenter()
|
2019-09-26 21:09:42 +00:00
|
|
|
mavenCentral()
|
2019-09-14 14:25:04 +00:00
|
|
|
}
|
|
|
|
dependencies {
|
|
|
|
if (!JavaVersion.current().isJava9Compatible()) {
|
|
|
|
errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
|
|
|
|
}
|
2019-10-15 14:29:39 +00:00
|
|
|
spotbugsPlugins "com.h3xstream.findsecbugs:findsecbugs-plugin:${versions.findsecbugs}"
|
2019-09-14 14:25:04 +00:00
|
|
|
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}")
|
2019-09-26 21:09:42 +00:00
|
|
|
testCompile("org.jmockit:jmockit:${versions.jmockit}")
|
2019-09-14 14:25:04 +00:00
|
|
|
testImplementation("com.github.spotbugs:spotbugs-annotations:${versions.spotbugs}")
|
|
|
|
testImplementation("org.openstreetmap.josm:josm-unittest:"){changing=true}
|
2019-09-25 11:49:25 +00:00
|
|
|
testImplementation("com.github.tomakehurst:wiremock:${versions.wiremock}")
|
|
|
|
testImplementation("org.awaitility:awaitility:${versions.awaitility}")
|
2019-09-14 14:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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}")
|
2020-05-13 16:03:23 +00:00
|
|
|
if (!"${it.@conf}".contains("test")) {
|
|
|
|
project.dependencies.packIntoJar("${it.@org}:${it.@name}:${it.@rev}")
|
|
|
|
}
|
2019-09-14 14:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
test {
|
2019-09-26 21:09:42 +00:00
|
|
|
project.afterEvaluate {
|
|
|
|
jvmArgs("-javaagent:${classpath.find { it.name.contains("jmockit") }.absolutePath}")
|
|
|
|
}
|
2019-09-30 21:15:54 +00:00
|
|
|
useJUnitPlatform()
|
2019-10-23 22:28:28 +00:00
|
|
|
testLogging {
|
|
|
|
exceptionFormat "full"
|
2019-11-15 15:21:31 +00:00
|
|
|
events "skipped", "failed"
|
2019-10-23 22:28:28 +00:00
|
|
|
info {
|
|
|
|
showStandardStreams true
|
|
|
|
}
|
|
|
|
}
|
2019-09-26 21:09:42 +00:00
|
|
|
}
|
|
|
|
|
2019-09-14 14:25:04 +00:00
|
|
|
sourceSets {
|
|
|
|
test {
|
|
|
|
java {
|
|
|
|
srcDirs = ["test/unit"]
|
|
|
|
}
|
|
|
|
resources {
|
|
|
|
srcDirs = ["test/data"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tasks.processResources {
|
|
|
|
from("$projectDir/LICENSE")
|
|
|
|
from("$projectDir/README.md")
|
2019-09-21 15:00:56 +00:00
|
|
|
from("$projectDir/src/resources")
|
2019-11-21 20:50:03 +00:00
|
|
|
from("$projectDir/src/main/resources")
|
2019-09-14 14:25:04 +00:00
|
|
|
}
|
|
|
|
|
2019-11-14 23:47:13 +00:00
|
|
|
jacocoTestCoverageVerification {
|
|
|
|
violationRules {
|
|
|
|
rule {
|
|
|
|
limit {
|
2019-11-20 16:44:08 +00:00
|
|
|
minimum = 0.80
|
2019-11-14 23:47:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-21 17:48:50 +00:00
|
|
|
spotless {
|
|
|
|
java {
|
|
|
|
licenseHeader "// License: GPL. For details, see LICENSE file."
|
|
|
|
removeUnusedImports()
|
|
|
|
endWithNewline()
|
|
|
|
indentWithSpaces(4)
|
|
|
|
eclipse().configFile "config/josm_formatting.xml"
|
|
|
|
trimTrailingWhitespace()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-14 14:25:04 +00:00
|
|
|
josm {
|
2020-05-07 16:22:09 +00:00
|
|
|
debugPort = 7055
|
2019-11-26 18:44:21 +00:00
|
|
|
manifest {
|
2020-04-23 14:44:50 +00:00
|
|
|
oldVersionDownloadLink 16220, "v1.4.2", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.4.2/mapwithai.jar")
|
2020-04-03 16:20:51 +00:00
|
|
|
oldVersionDownloadLink 15820, "v1.3.7", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.3.7/mapwithai.jar")
|
2020-02-06 14:36:21 +00:00
|
|
|
oldVersionDownloadLink 15737, "v1.2.3", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.2.3/mapwithai.jar")
|
2020-01-23 14:46:22 +00:00
|
|
|
oldVersionDownloadLink 15609, "v1.1.8", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.1.8/mapwithai.jar")
|
|
|
|
oldVersionDownloadLink 15542, "v1.0.5", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.0.5/mapwithai.jar")
|
2020-01-16 23:35:51 +00:00
|
|
|
oldVersionDownloadLink 15233, "v0.2.10", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v0.2.10/mapwithai.jar")
|
2019-11-26 18:44:21 +00:00
|
|
|
}
|
2019-09-14 14:25:04 +00:00
|
|
|
i18n {
|
2019-10-17 15:32:24 +00:00
|
|
|
pathTransformer = getPathTransformer("gitlab.com/${gitlabGroup}/${gitlabRepositoryName}/blob")
|
2019-09-14 14:25:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2019-10-02 14:46:00 +00:00
|
|
|
incrementalAnalysis = true
|
2019-09-14 14:25:04 +00:00
|
|
|
ruleSets = []
|
|
|
|
ruleSetConfig = resources.text.fromFile("$projectDir/config/pmd/ruleset.xml")
|
|
|
|
sourceSets = [sourceSets.main]
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set up SpotBugs
|
|
|
|
spotbugs {
|
|
|
|
toolVersion = versions.spotbugs
|
|
|
|
ignoreFailures = true
|
|
|
|
}
|
2020-04-22 23:34:55 +00:00
|
|
|
spotbugsMain {
|
2019-09-14 14:25:04 +00:00
|
|
|
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 {
|
2019-10-17 15:32:24 +00:00
|
|
|
def pluginDownloadUrl = "https://${gitlabGroup}.gitlab.io/${gitlabRepositoryName}/snapshot/master/${archivesBaseName}.jar"
|
2019-09-14 14:25:04 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|