forked from osmlab/josm-atlas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
175 lines (154 loc) · 5.48 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
plugins {
id 'org.openstreetmap.josm' version '0.3.4'
id 'com.diffplug.gradle.spotless' version '3.9.0'
// Used to promote a staging release build
// https://github.com/Codearte/gradle-nexus-staging-plugin
// gradle closeAndReleaseRepository
id "io.codearte.nexus-staging" version "0.11.0"
id 'java'
id 'checkstyle'
id 'maven'
id 'maven-publish'
id 'signing'
id 'idea'
}
// Define tool and dependency versions
checkstyle {
toolVersion = '8.10.1'
}
josm { // see https://floscher.github.io/gradle-josm-plugin/kdoc/v0.3.4/gradle-josm-plugin/org.openstreetmap.josm.gradle.plugin.config/-josm-plugin-extension
josmCompileVersion '13959'
manifest.minJosmVersion = '13957'
}
ext.versions = [
'atlas': '5.0.16'
]
// corresponds to POM description/group
description = "Atlas Library"
group = 'org.openstreetmap.atlas'
// for the version number see `gradle.properties`
// JOSM plugin configuration
archivesBaseName = 'josm-atlas'
josm.manifest { // see https://floscher.github.io/gradle-josm-plugin/kdoc/v0.3.4/gradle-josm-plugin/org.openstreetmap.josm.gradle.plugin.config/-josm-manifest
author = 'James Gage'
canLoadAtRuntime = true
description = 'Allows you to view an Atlas file as a layer.'
iconPath = 'images/dialogs/world-3.png'
mainClass = 'org.openstreetmap.atlas.AtlasReader'
website = new URL('https://github.com/osmlab/josm-atlas')
}
sourceCompatibility=1.8
targetCompatibility=1.8
repositories {
// For geotools
maven { url "http://download.osgeo.org/webdav/geotools/" }
mavenCentral()
}
dependencies {
packIntoJar "org.openstreetmap.atlas:atlas:${versions.atlas}"
}
idea {
project {
languageLevel = '1.8'
}
}
spotless {
java {
importOrder 'static java', 'static javax', 'static org', 'static com', 'static scala', 'java', 'javax', 'org', 'com', 'scala'
removeUnusedImports()
eclipse().configFile 'config/format/code_format.xml'
}
}
// This is to skip the tasks for which there is a skip<TaskName>=true environment variable
def skippedTaskNames = System.getenv().findAll { key, value ->
key.startsWith("skip") && value.equalsIgnoreCase("true")
}.keySet().collect { it.substring(4) }
gradle.startParameter.excludedTaskNames += skippedTaskNames
test {
testLogging {
events "passed", "skipped", "failed"
}
}
tasks.withType(Test) {
// Use `build/reports/$testTaskName` instead of `build/reports/$sourceSetName`
reports.html.setDestination(file("${reporting.baseDir}/${name}"))
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives javadocJar, sourcesJar
}
if (System.env.containsKey("GPG_KEY_ID") && System.env.containsKey("GPG_PASSPHRASE") && System.env.containsKey("GPG_KEY_LOCATION")) {
ext."signing.keyId" = System.env.GPG_KEY_ID
ext."signing.password" = System.env.GPG_PASSPHRASE
ext."signing.secretKeyRingFile" = System.env.GPG_KEY_LOCATION
}
if (!ext.has("signing.keyId") || !ext.has("signing.password") || !ext.has("signing.secretKeyRingFile")) {
logger.warn "\nThe artifacts of this build are not signed.\nSet GPG_KEY_ID, GPG_PASSPHRASE and GPG_KEY_LOCATION to sign it.\n"
if (
System.env.containsKey("TRAVIS_REPO_SLUG")
&& System.env.containsKey("TRAVIS_PULL_REQUEST")
&& "osmlab/josm-atlas".equals(System.env.TRAVIS_REPO_SLUG)
&& "false".equals(System.env.TRAVIS_PULL_REQUEST)
) {
throw new GradleException("Builds for the repository ${System.env.TRAVIS_REPO_SLUG} must be signed!")
}
} else {
signing {
sign configurations.archives
}
}
/**
* JOSM SPECIFIC TASKS
*/
import org.gradle.internal.os.OperatingSystem
/**
* This task installs the plugin in your system's JOSM plugins directory.
*
* https://josm.openstreetmap.de/wiki/Help/Preferences
*
* On macOS:
*
* ~/Library/JOSM/plugins/
*/
task installPlugin(type: Copy) {
def destStr
if(OperatingSystem.current().isMacOsX()) {
destStr = "${System.getProperty('user.home')}/Library/JOSM/plugins"
} else if(OperatingSystem.current().isWindows()) {
destStr = "${System.getenv()['APPDATA']}/JOSM/plugins"
} else if (new File("${System.getProperty('user.home')}/.josm").exists()) {
destStr = "${System.getProperty('user.home')}/.josm/plugins"
} else {
destStr = "${System.getProperty('user.home')}/.local/share/JOSM/plugins"
}
logger.lifecycle("Plugin JAR Archive Path: " + dist.outputs.files.asFileTree.files[0])
logger.lifecycle("Plugin JAR Destination Path: " + destStr)
from tasks.dist
into destStr
project.afterEvaluate {
finalizedBy activatePlugin
}
}
/**
* Starts a JOSM instance and activates the plugin if it's not already active.
*
* The difference to the `runJosm` task is that there a completely clean instance is started up and a temporary JOSM_HOME is used.
* Here your default JOSM_HOME is used and you have to have JOSM already installed.
*/
task activatePlugin(type: Exec, dependsOn: installPlugin) {
def configFile = new File(buildDir, "addPluginConfig.xml")
doFirst {
configFile.withWriter { out ->
out.print "<?xml version=\"1.0\" encoding=\"UTF-8\"?><config><preferences operation=\"append\"><list key=\"plugins\"><entry value=\"${project.archivesBaseName}\"/></list></preferences></config>"
}
}
executable 'josm'
args '--load-preferences=' + configFile.toURI().toURL().toString()
}