1 | // Custom tasks for running JOSM with the plugin loaded
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Reset the JOSM home directory
|
---|
5 | */
|
---|
6 | task cleanJosm(type: Delete) {
|
---|
7 | delete "$buildDir/.josm"
|
---|
8 | }
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Initialize the JOSM preferences
|
---|
12 | */
|
---|
13 | task initJosmPrefs(type: Copy) {
|
---|
14 | if (!new File("$buildDir/.josm/preferences.xml").exists()) {
|
---|
15 | from "config/josm/preferences.xml"
|
---|
16 | into "$buildDir/.josm"
|
---|
17 | }
|
---|
18 | }
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Puts the freshly compiled plugin jar into the JOSM home dir that is used from Gradle
|
---|
22 | */
|
---|
23 | task updateJosmPlugin(type: Copy) {
|
---|
24 | dependsOn jar
|
---|
25 | dependsOn initJosmPrefs
|
---|
26 | from configurations.requiredPlugin
|
---|
27 | from "$buildDir/libs/${project.name}.jar"
|
---|
28 | into "$buildDir/.josm/plugins"
|
---|
29 | rename('(.*)-\\.jar', '$1.jar')
|
---|
30 | rename(project.name, project.hasProperty('plugin.jar.name') ? project.property('plugin.jar.name') : project.name)
|
---|
31 | }
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * This runs the JOSM-version specified in the dependency configuration above.
|
---|
35 | * The home-directory of this JOSM is located in $buildDir/.josm, so it doesn't interfere with any other JOSM-installations.
|
---|
36 | */
|
---|
37 | task runJosm(type: JavaExec) {
|
---|
38 | dependsOn updateJosmPlugin
|
---|
39 | classpath = sourceSets.main.runtimeClasspath
|
---|
40 | main = 'JOSM'
|
---|
41 | jvmArgs "-Djosm.home=$buildDir/.josm"
|
---|
42 | }
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Starts an instance of JOSM that is debuggable
|
---|
46 | */
|
---|
47 | task debugJosm(type: JavaExec) {
|
---|
48 | dependsOn updateJosmPlugin
|
---|
49 | classpath = sourceSets.main.runtimeClasspath
|
---|
50 | main = 'JOSM'
|
---|
51 | jvmArgs "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7051", "-Djosm.home=$buildDir/.josm"
|
---|
52 | }
|
---|