forked from osmlab/josm-atlas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
168 lines (146 loc) · 4.52 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
plugins {
id 'org.openstreetmap.josm' version '0.3.2'
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.8.0"
id 'java'
id 'checkstyle'
id 'maven'
id 'maven-publish'
id 'signing'
id 'idea'
}
// corresponds to POM description/group
description = "Atlas Library"
group = 'org.openstreetmap.atlas'
archivesBaseName = 'josm-atlas'
josm { // see https://floscher.github.io/gradle-josm-plugin/kdoc/v0.3.2/gradle-josm-plugin/org.openstreetmap.josm.gradle.plugin.config/-josm-plugin-extension
josmCompileVersion '13367'
manifest { // see https://floscher.github.io/gradle-josm-plugin/kdoc/v0.3.2/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'
minJosmVersion = '12712'
website = new URL('https://github.com/osmlab/josm-atlas')
}
}
apply from: 'dependencies.gradle'
sourceCompatibility=1.8
targetCompatibility=1.8
repositories
{
// For geotools
maven { url "http://download.osgeo.org/webdav/geotools/" }
mavenCentral()
}
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
checkstyle
{
toolVersion = versions.checkstyle
}
test
{
testLogging
{
events "passed", "skipped", "failed"
}
}
configurations
{
all
{
resolutionStrategy
{
force packages.atlas
}
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}
}
dependencies
{
packIntoJar packages.atlas
}
tasks.withType(Test) {
reports.html.destination = file("${reporting.baseDir}/${name}")
}
// Javadoc currently fails on a dependency issue
//task javadocJar(type: Jar) {
// classifier = 'javadoc'
// from javadoc
//}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts
{
archives /*javadocJar,*/ sourcesJar
}
/**
* 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()
}