2022-03-01 23:21:14 +00:00
|
|
|
import groovy.xml.XmlParser
|
2019-09-14 14:25:04 +00:00
|
|
|
|
|
|
|
plugins {
|
2022-05-31 22:12:00 +00:00
|
|
|
id "com.diffplug.spotless" version "6.6.1"
|
2022-03-01 23:21:14 +00:00
|
|
|
id "com.github.ben-manes.versions" version "0.42.0"
|
2022-05-31 22:12:00 +00:00
|
|
|
id "com.github.spotbugs" version "5.0.7"
|
2021-09-30 17:50:59 +00:00
|
|
|
// id "de.aaschmid.cpd" version "3.3"
|
2019-09-14 14:25:04 +00:00
|
|
|
id "eclipse"
|
|
|
|
id "jacoco"
|
2021-09-30 17:50:59 +00:00
|
|
|
id "java"
|
2022-01-12 17:31:10 +00:00
|
|
|
id "java-test-fixtures" /* Used for publishing test fixtures package */
|
2019-09-14 14:25:04 +00:00
|
|
|
id "maven-publish"
|
2021-09-07 14:30:42 +00:00
|
|
|
id "net.ltgt.errorprone" version "2.0.2"
|
2022-07-06 18:06:24 +00:00
|
|
|
id "org.openstreetmap.josm" version "0.8.2"
|
2021-09-07 14:30:42 +00:00
|
|
|
id "org.sonarqube" version "3.3"
|
2021-09-30 17:50:59 +00:00
|
|
|
id "pmd"
|
2019-09-14 14:25:04 +00:00
|
|
|
}
|
|
|
|
|
2022-03-01 23:21:14 +00:00
|
|
|
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 8
|
|
|
|
}
|
|
|
|
|
|
|
|
logger.lifecycle("Using Java " + getJavaVersion())
|
|
|
|
|
|
|
|
java {
|
|
|
|
toolchain {
|
|
|
|
languageVersion.set(JavaLanguageVersion.of(getJavaVersion()))
|
|
|
|
}
|
|
|
|
}
|
2020-06-01 14:57:01 +00:00
|
|
|
|
2019-09-14 14:25:04 +00:00
|
|
|
// Set up Errorprone
|
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
|
|
options.errorprone {
|
2022-07-06 18:06:24 +00:00
|
|
|
error(
|
|
|
|
"ClassCanBeStatic",
|
|
|
|
"DefaultCharset",
|
|
|
|
"ReferenceEquality",
|
|
|
|
"WildcardImport"
|
|
|
|
)
|
|
|
|
warn(
|
|
|
|
"ConstantField",
|
|
|
|
"FieldCanBeFinal",
|
|
|
|
"LambdaFunctionalInterface",
|
|
|
|
"MethodCanBeStatic",
|
|
|
|
"MultiVariableDeclaration",
|
|
|
|
"PrivateConstructorForUtilityClass",
|
|
|
|
"RemoveUnusedImports",
|
|
|
|
"UngroupedOverloads"
|
|
|
|
)
|
2019-09-14 14:25:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-07 22:26:46 +00:00
|
|
|
rootProject.tasks.named("jar") {
|
|
|
|
duplicatesStrategy = 'include'
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2020-05-29 17:16:48 +00:00
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
2022-03-02 18:25:55 +00:00
|
|
|
maven {
|
|
|
|
url "https://josm.openstreetmap.de/nexus/content/repositories/releases/"
|
|
|
|
}
|
2020-05-29 17:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
test {
|
|
|
|
java {
|
2022-01-12 17:31:10 +00:00
|
|
|
srcDirs = ["src/test/unit"]
|
2020-05-29 17:16:48 +00:00
|
|
|
}
|
|
|
|
resources {
|
2022-01-12 17:31:10 +00:00
|
|
|
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"]
|
2020-05-29 17:16:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
intTest {
|
2020-06-01 19:22:32 +00:00
|
|
|
compileClasspath += sourceSets.main.output
|
|
|
|
compileClasspath += sourceSets.test.output
|
|
|
|
runtimeClasspath += sourceSets.main.output
|
|
|
|
runtimeClasspath += sourceSets.test.output
|
2020-05-29 17:16:48 +00:00
|
|
|
java {
|
2022-01-12 17:31:10 +00:00
|
|
|
srcDirs = ["src/test/integration"]
|
2020-05-29 17:16:48 +00:00
|
|
|
}
|
|
|
|
resources {
|
2022-01-12 17:31:10 +00:00
|
|
|
srcDirs = ["src/test/resources"]
|
2020-05-29 17:16:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-17 15:32:24 +00:00
|
|
|
|
2019-09-14 14:25:04 +00:00
|
|
|
def versions = [
|
2022-03-10 15:51:32 +00:00
|
|
|
awaitility: "4.2.0",
|
2022-05-31 22:12:00 +00:00
|
|
|
equalsverifier: "3.10",
|
2022-03-01 23:21:14 +00:00
|
|
|
// Errorprone 2.11 requires Java 11+
|
2022-05-31 22:12:00 +00:00
|
|
|
errorprone: (JavaVersion.toVersion(getJavaVersion()) >= JavaVersion.VERSION_11) ? "2.14.0" : "2.10.0",
|
|
|
|
findsecbugs: "1.12.0",
|
2022-01-12 17:31:10 +00:00
|
|
|
jacoco: "0.8.7",
|
2022-03-02 18:25:55 +00:00
|
|
|
jmockit: "1.49.a",
|
2022-05-31 22:12:00 +00:00
|
|
|
josm: properties.get("plugin.compile.version"),
|
2021-12-02 20:52:26 +00:00
|
|
|
junit: "5.8.2",
|
2019-12-18 21:13:08 +00:00
|
|
|
pmd: "6.20.0",
|
2022-05-12 18:51:42 +00:00
|
|
|
spotbugs: "4.7.0",
|
|
|
|
wiremock: "2.33.2",
|
2019-09-14 14:25:04 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
dependencies {
|
2022-03-01 23:21:14 +00:00
|
|
|
if (!JavaVersion.toVersion(getJavaVersion()).isJava9Compatible()) {
|
2019-09-14 14:25:04 +00:00
|
|
|
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}")
|
|
|
|
|
2022-01-12 17:31:10 +00:00
|
|
|
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}")
|
2022-05-31 22:12:00 +00:00
|
|
|
testImplementation("nl.jqno.equalsverifier:equalsverifier:${versions.equalsverifier}")
|
2019-09-14 14:25:04 +00:00
|
|
|
}
|
|
|
|
|
2020-05-29 17:16:48 +00:00
|
|
|
configurations {
|
2022-01-12 17:31:10 +00:00
|
|
|
testImplementation.extendsFrom testFixturesImplementation
|
|
|
|
testRuntimeOnly.extendsFrom testFixturesRuntimeOnly
|
2020-05-29 17:16:48 +00:00
|
|
|
intTestRuntimeOnly.extendsFrom testRuntimeOnly
|
2020-06-01 19:22:32 +00:00
|
|
|
intTestImplementation.extendsFrom testImplementation
|
2020-05-29 17:16:48 +00:00
|
|
|
}
|
|
|
|
|
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}")
|
2020-08-05 20:17:45 +00:00
|
|
|
jvmArgs("-Djunit.jupiter.extensions.autodetection.enabled=true")
|
2020-09-18 13:46:59 +00:00
|
|
|
jvmArgs("-Djava.awt.headless=true")
|
2019-09-26 21:09:42 +00:00
|
|
|
}
|
2019-09-30 21:15:54 +00:00
|
|
|
useJUnitPlatform()
|
2020-05-29 17:16:48 +00:00
|
|
|
ignoreFailures
|
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
|
|
|
}
|
|
|
|
|
2020-05-29 17:16:48 +00:00
|
|
|
task integrationTest(type: Test) {
|
|
|
|
description = "Run integration tests"
|
|
|
|
group = "verification"
|
|
|
|
|
|
|
|
testClassesDirs = sourceSets.intTest.output.classesDirs
|
|
|
|
classpath = sourceSets.intTest.runtimeClasspath
|
|
|
|
shouldRunAfter test
|
2020-06-01 22:35:49 +00:00
|
|
|
// Ignore failures -- servers may or may not be down
|
|
|
|
ignoreFailures = true
|
2019-09-14 14:25:04 +00:00
|
|
|
}
|
2020-05-29 17:16:48 +00:00
|
|
|
|
|
|
|
check.dependsOn integrationTest
|
|
|
|
|
2019-09-14 14:25:04 +00:00
|
|
|
tasks.processResources {
|
2021-05-19 14:56:08 +00:00
|
|
|
// 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
|
2019-09-14 14:25:04 +00:00
|
|
|
from("$projectDir/LICENSE")
|
|
|
|
from("$projectDir/README.md")
|
|
|
|
}
|
|
|
|
|
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 {
|
2021-09-30 17:50:59 +00:00
|
|
|
eclipse().configFile "config/josm_formatting.xml"
|
|
|
|
endWithNewline()
|
|
|
|
importOrder('javax', 'java', 'org', 'com', '')
|
|
|
|
indentWithSpaces(4)
|
2020-04-21 17:48:50 +00:00
|
|
|
licenseHeader "// License: GPL. For details, see LICENSE file."
|
2021-09-07 14:22:55 +00:00
|
|
|
ratchetFrom("origin/master")
|
2020-04-21 17:48:50 +00:00
|
|
|
removeUnusedImports()
|
|
|
|
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 {
|
2021-11-11 14:26:35 +00:00
|
|
|
oldVersionDownloadLink 17903, "v1.8.7", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.8.7/mapwithai.jar")
|
2021-05-26 16:42:02 +00:00
|
|
|
oldVersionDownloadLink 17084, "v1.7.1.6", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.7.1.6/mapwithai.jar")
|
|
|
|
oldVersionDownloadLink 16645, "v1.6.8", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.6.8/mapwithai.jar")
|
|
|
|
oldVersionDownloadLink 16284, "v1.5.10", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.5.10/mapwithai.jar")
|
|
|
|
oldVersionDownloadLink 16220, "v1.4.7", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.4.7/mapwithai.jar")
|
|
|
|
oldVersionDownloadLink 15820, "v1.3.11", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.3.11/mapwithai.jar")
|
|
|
|
oldVersionDownloadLink 15737, "v1.2.7", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.2.7/mapwithai.jar")
|
|
|
|
oldVersionDownloadLink 15609, "v1.1.12", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.1.12/mapwithai.jar")
|
|
|
|
oldVersionDownloadLink 15542, "v1.0.9", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.0.9/mapwithai.jar")
|
|
|
|
oldVersionDownloadLink 15233, "v0.2.14", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v0.2.14/mapwithai.jar")
|
2019-11-26 18:44:21 +00:00
|
|
|
}
|
2019-09-14 14:25:04 +00:00
|
|
|
i18n {
|
2020-11-12 22:15:39 +00:00
|
|
|
pathTransformer = getPathTransformer(project.projectDir, "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 {
|
2022-03-01 23:21:14 +00:00
|
|
|
xml.required.set(true)
|
|
|
|
html.required.set(true)
|
2019-09-14 14:25:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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 {
|
2022-03-01 23:21:14 +00:00
|
|
|
xml.required.set(false)
|
|
|
|
html.required.set(true)
|
2019-09-14 14:25:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-01 23:21:14 +00:00
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
maven(MavenPublication) {
|
|
|
|
groupId = "org.openstreetmap.josm.plugins"
|
|
|
|
artifactId = archivesBaseName
|
|
|
|
version = project.version
|
|
|
|
|
|
|
|
from components.java
|
2019-09-14 14:25:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-15 14:16:55 +00:00
|
|
|
|
|
|
|
sonarqube {
|
|
|
|
properties {
|
|
|
|
property "sonar.organization", "mapwithai"
|
|
|
|
property "sonar.projectKey", "mapwithai"
|
2020-09-17 22:16:32 +00:00
|
|
|
property "sonar.forceAuthentication", "true"
|
|
|
|
property "sonar.host.url", "https://sonarcloud.io"
|
|
|
|
property "sonar.projectDescription", properties.get("plugin.description")
|
|
|
|
property "sonar.projectVersion", project.version
|
2020-09-18 15:54:06 +00:00
|
|
|
property "sonar.sources", ["src"]
|
2020-09-15 14:16:55 +00:00
|
|
|
}
|
|
|
|
}
|