source: osm/applications/editors/josm/plugins/mapillary/gradle/josm-tasks.gradle@ 32999

Last change on this file since 32999 was 32999, checked in by floscher, 8 years ago

[mapillary] Fix Gradle task initJosmPrefs when run together with cleanJosm

Previously the decision if 'initJosmPrefs' should actually copy the preferences or do nothing was made in the initialization phase of Gradle.
Otherwise if e.g. 'cleanJosm' also runs, it's decided in the init-phase that the preferences are not copied, because there already is a preference file. But that file is deleted, when 'cleanJosm' is executed. When 'initJosmPrefs' is then executed, that file would not be restored, because the decision not to copy already has been made.

Because of that, this decision is now made in the execution phase.

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