Index: /applications/editors/josm/plugins/mapillary/.eclipse-pmd
===================================================================
--- /applications/editors/josm/plugins/mapillary/.eclipse-pmd	(revision 32692)
+++ /applications/editors/josm/plugins/mapillary/.eclipse-pmd	(revision 32693)
@@ -3,5 +3,5 @@
   <analysis enabled="true" />
   <rulesets>
-    <ruleset name="Ruleset for josm-mapillary-plugin" ref=".settings/pmd-ruleset.xml" refcontext="project" />
+    <ruleset name="Ruleset for josm-mapillary-plugin" ref="config/pmd/ruleset.xml" refcontext="project" />
   </rulesets>
 </eclipse-pmd>
Index: /applications/editors/josm/plugins/mapillary/.settings/launchers/Remote debug JOSM-Mapillary.launch
===================================================================
--- /applications/editors/josm/plugins/mapillary/.settings/launchers/Remote debug JOSM-Mapillary.launch	(revision 32692)
+++ /applications/editors/josm/plugins/mapillary/.settings/launchers/Remote debug JOSM-Mapillary.launch	(revision 32693)
@@ -17,5 +17,5 @@
   <mapAttribute key="org.eclipse.jdt.launching.CONNECT_MAP">
     <mapEntry key="hostname" value="localhost"/>
-    <mapEntry key="port" value="5006"/>
+    <mapEntry key="port" value="7051"/>
   </mapAttribute>
   <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="JOSM-Mapillary"/>
Index: plications/editors/josm/plugins/mapillary/.settings/pmd-ruleset.xml
===================================================================
--- /applications/editors/josm/plugins/mapillary/.settings/pmd-ruleset.xml	(revision 32692)
+++ 	(revision )
@@ -1,48 +1,0 @@
-<?xml version="1.0"?>
-<ruleset name="Ruleset for josm-mapillary-plugin"
-    xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
-  <description>
-    This ruleset checks some rules that you should normally follow for the josm-mapillary-plugin.
-  </description>
-  <rule ref="rulesets/java/basic.xml"/>
-  <rule ref="rulesets/java/braces.xml">
-    <exclude name="IfStmtsMustUseBraces"/>
-  </rule>
-  <rule ref="rulesets/java/clone.xml"/>
-
-  <rule ref="rulesets/java/controversial.xml/UnnecessaryConstructor"/>
-  <rule ref="rulesets/java/controversial.xml/AssignmentInOperand"/>
-  <rule ref="rulesets/java/controversial.xml/DontImportSun"/>
-  <rule ref="rulesets/java/controversial.xml/SuspiciousOctalEscape"/>
-  <rule ref="rulesets/java/controversial.xml/UnnecessaryParentheses"/>
-  <rule ref="rulesets/java/controversial.xml/DefaultPackage"/>
-
-  <rule ref="rulesets/java/coupling.xml">
-    <exclude name="LoosePackageCoupling" />
-    <exclude name="LawOfDemeter" />
-  </rule>
-  <rule ref="rulesets/java/design.xml">
-    <exclude name="AvoidSynchronizedAtMethodLevel" />
-    <exclude name="ConfusingTernary" />
-  </rule>
-  <rule ref="rulesets/java/empty.xml"/>
-  <rule ref="rulesets/java/finalizers.xml"/>
-  <rule ref="rulesets/java/imports.xml"/>
-  <rule ref="rulesets/java/naming.xml">
-    <exclude name="ShortVariable"/>
-    <exclude name="LongVariable"/>
-    <exclude name="AbstractNaming"/>
-  </rule>
-  <rule ref="rulesets/java/optimizations.xml">
-    <exclude name="LocalVariableCouldBeFinal" />
-    <exclude name="MethodArgumentCouldBeFinal" />
-  </rule>
-  <rule ref="rulesets/java/strictexception.xml"/>
-  <rule ref="rulesets/java/strings.xml"/>
-  <rule ref="rulesets/java/sunsecure.xml"/>
-  <rule ref="rulesets/java/typeresolution.xml"/>
-  <rule ref="rulesets/java/unnecessary.xml"/>
-  <rule ref="rulesets/java/unusedcode.xml"/>
-</ruleset>
Index: /applications/editors/josm/plugins/mapillary/build.gradle
===================================================================
--- /applications/editors/josm/plugins/mapillary/build.gradle	(revision 32692)
+++ /applications/editors/josm/plugins/mapillary/build.gradle	(revision 32693)
@@ -5,4 +5,12 @@
 apply plugin: 'java'
 apply plugin: 'pmd'
+
+configurations {
+  compile.extendsFrom(requiredPlugin)
+}
+
+apply from: 'gradle/manifest.gradle'
+apply from: 'gradle/josm-tasks.gradle'
+apply from: 'gradle/tool-config.gradle'
 
 sourceCompatibility = '1.8'
@@ -39,6 +47,6 @@
   compile(':josm:10583')
   // For plugins it's irrelevant, which version is specified, always the latest version is used.
-  compile (name: 'apache-commons'){changing=true}
-  compile (name: 'apache-http'){changing=true}
+  requiredPlugin (name: 'apache-commons'){changing=true}
+  requiredPlugin (name: 'apache-http'){changing=true}
 
   testCompile 'junit:junit:4.12'
@@ -82,40 +90,6 @@
 tasks.eclipse.dependsOn = ['eclipseClasspath', 'eclipseProject']
 
-pmd {
-  toolVersion project.property('tools.pmd.version')
-  ignoreFailures true
-  targetJdk 1.7 // 1.8 is not yet available (as of Gradle 2.14, see https://docs.gradle.org/current/javadoc/org/gradle/api/plugins/quality/TargetJdk.html)
-  ruleSetConfig = resources.text.fromFile('.settings/pmd-ruleset.xml')
-}
-
-build.dependsOn jacocoTestReport
-
 tasks.withType(Javadoc) {
   failOnError false
-}
-
-/** FindBugs configuration */
-findbugs {
-  toolVersion = project.property('tools.findbugs.version')
-  ignoreFailures = true
-  effort = "max"
-  reportLevel = "low"
-}
-tasks.withType(FindBugs) {
-  reports {
-    xml.enabled = false
-    html.enabled = true
-  }
-}
-
-/** JaCoCo configuration */
-jacoco {
-  toolVersion = project.property('tools.jacoco.version')
-}
-jacocoTestReport {
-  reports {
-    xml.enabled true
-    html.destination "$buildDir/reports/jacoco"
-  }
 }
 
@@ -126,63 +100,2 @@
   }
 }
-
-jar {
-  manifest {
-    attributes(
-      "Gradle-Version": project.getGradle().getGradleVersion(),
-      "Created-By": System.getProperty("java.version")+" ("+System.getProperty("java.vendor")+")",
-      "Plugin-Mainversion": project.property('plugin.main.version'),
-      "Plugin-Version": project.property('plugin.svnrevision'),
-      "Plugin-SemVersion": project.property('plugin.version'),
-      "Plugin-Class": project.property('plugin.class'),
-      "Plugin-Description": project.property('plugin.description'),
-      "Plugin-Date": String.format("%1\$tY-%1\$tm-%1\$tdT%1\$tH:%1\$tM:%1\$tS%1\$tz", new GregorianCalendar()),
-      "Author": project.property('plugin.author'),
-      "Plugin-Link": project.property('plugin.link'),
-      "Plugin-Icon": project.property("plugin.icon"),
-      "Plugin-Requires": project.property("plugin.requires"),
-      "Plugin-Canloadatruntime": project.property('plugin.canloadatruntime')
-    )
-  }
-}
-
-task activatePlugin(type: Copy) {
-  if (!new File("$buildDir/.josm/preferences.xml").exists()) {
-    from "gradle/josm-preferences.xml"
-    into "$buildDir/.josm"
-    rename 'josm-preferences.xml', 'preferences.xml'
-  }
-}
-
-task installPlugin(type: Copy) {
- from "$buildDir/libs/${project.name}.jar"
- from configurations.runtime
- into "$buildDir/.josm/plugins"
- include 'apache*.jar'
- include "${project.name}.jar"
- rename "${project.name}.jar", 'Mapillary.jar'
- rename 'apache-(.*)-.*.jar', 'apache-$1.jar'
-}
-installPlugin.dependsOn jar
-installPlugin.dependsOn activatePlugin
-
-/**
- * This runs the JOSM-version specified in the dependency configuration above.
- * The home-directory of this JOSM is located in $buildDir/.josm, so it doesn't interfere with any other JOSM-installations.
- */
-task runJosm(type: JavaExec) {
-  classpath = sourceSets.main.runtimeClasspath
-  main = 'JOSM'
-  args '--offline=josm_website'
-  jvmArgs "-Djosm.home=$buildDir/.josm"
-}
-runJosm.dependsOn installPlugin
-
-
-task debugJosm(type: JavaExec) {
-  classpath = sourceSets.main.runtimeClasspath
-  main = 'JOSM'
-  args '--offline=josm_website'
-  jvmArgs "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006", "-Djosm.home=$buildDir/.josm"
-}
-debugJosm.dependsOn installPlugin
Index: /applications/editors/josm/plugins/mapillary/config/josm/preferences.xml
===================================================================
--- /applications/editors/josm/plugins/mapillary/config/josm/preferences.xml	(revision 32693)
+++ /applications/editors/josm/plugins/mapillary/config/josm/preferences.xml	(revision 32693)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<preferences xmlns="http://josm.openstreetmap.de/preferences-1.0">
+  <list key='plugins'>
+    <entry value='Mapillary'/>
+    <entry value='apache-commons'/>
+    <entry value='apache-http'/>
+  </list>
+  <tag key='pluginmanager.time-based-update.policy' value='never'/>
+  <tag key='pluginmanager.version-based-update.policy' value='never'/>
+</preferences>
Index: /applications/editors/josm/plugins/mapillary/config/pmd/ruleset.xml
===================================================================
--- /applications/editors/josm/plugins/mapillary/config/pmd/ruleset.xml	(revision 32693)
+++ /applications/editors/josm/plugins/mapillary/config/pmd/ruleset.xml	(revision 32693)
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<ruleset name="Ruleset for josm-mapillary-plugin"
+    xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
+  <description>
+    This ruleset checks some rules that you should normally follow for the josm-mapillary-plugin.
+  </description>
+  <rule ref="rulesets/java/basic.xml"/>
+  <rule ref="rulesets/java/braces.xml">
+    <exclude name="IfStmtsMustUseBraces"/>
+  </rule>
+  <rule ref="rulesets/java/clone.xml"/>
+
+  <rule ref="rulesets/java/controversial.xml/UnnecessaryConstructor"/>
+  <rule ref="rulesets/java/controversial.xml/AssignmentInOperand"/>
+  <rule ref="rulesets/java/controversial.xml/DontImportSun"/>
+  <rule ref="rulesets/java/controversial.xml/SuspiciousOctalEscape"/>
+  <rule ref="rulesets/java/controversial.xml/UnnecessaryParentheses"/>
+  <rule ref="rulesets/java/controversial.xml/DefaultPackage"/>
+
+  <rule ref="rulesets/java/coupling.xml">
+    <exclude name="LoosePackageCoupling" />
+    <exclude name="LawOfDemeter" />
+  </rule>
+  <rule ref="rulesets/java/design.xml">
+    <exclude name="AvoidSynchronizedAtMethodLevel" />
+    <exclude name="ConfusingTernary" />
+  </rule>
+  <rule ref="rulesets/java/empty.xml"/>
+  <rule ref="rulesets/java/finalizers.xml"/>
+  <rule ref="rulesets/java/imports.xml"/>
+  <rule ref="rulesets/java/naming.xml">
+    <exclude name="ShortVariable"/>
+    <exclude name="LongVariable"/>
+    <exclude name="AbstractNaming"/>
+  </rule>
+  <rule ref="rulesets/java/optimizations.xml">
+    <exclude name="LocalVariableCouldBeFinal" />
+    <exclude name="MethodArgumentCouldBeFinal" />
+  </rule>
+  <rule ref="rulesets/java/strictexception.xml"/>
+  <rule ref="rulesets/java/strings.xml"/>
+  <rule ref="rulesets/java/sunsecure.xml"/>
+  <rule ref="rulesets/java/typeresolution.xml"/>
+  <rule ref="rulesets/java/unnecessary.xml"/>
+  <rule ref="rulesets/java/unusedcode.xml"/>
+</ruleset>
Index: /applications/editors/josm/plugins/mapillary/gradle.properties
===================================================================
--- /applications/editors/josm/plugins/mapillary/gradle.properties	(revision 32692)
+++ /applications/editors/josm/plugins/mapillary/gradle.properties	(revision 32693)
@@ -7,10 +7,12 @@
 plugin.main.version=10580
 plugin.requires=apache-commons;apache-http
-plugin.version=1.1.5
 plugin.svnrevision=31976
 #plugin.early=...
 #plugin.stage=...
 
-tools.pmd.version=5.5.0
-tools.findbugs.version=3.0.1
-tools.jacoco.version=0.7.7.201606060606
+# The name for the JAR file produced by Gradle (optional, defaults to ${project.name})
+plugin.jar.name=Mapillary
+
+tool.pmd.version=5.5.0
+tool.findbugs.version=3.0.1
+tool.jacoco.version=0.7.7.201606060606
Index: plications/editors/josm/plugins/mapillary/gradle/josm-preferences.xml
===================================================================
--- /applications/editors/josm/plugins/mapillary/gradle/josm-preferences.xml	(revision 32692)
+++ 	(revision )
@@ -1,8 +1,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<preferences xmlns="http://josm.openstreetmap.de/preferences-1.0">
-  <list key='plugins'>
-    <entry value='Mapillary'/>
-    <entry value='apache-commons'/>
-    <entry value='apache-http'/>
-  </list>
-</preferences>
Index: /applications/editors/josm/plugins/mapillary/gradle/josm-tasks.gradle
===================================================================
--- /applications/editors/josm/plugins/mapillary/gradle/josm-tasks.gradle	(revision 32693)
+++ /applications/editors/josm/plugins/mapillary/gradle/josm-tasks.gradle	(revision 32693)
@@ -0,0 +1,52 @@
+// Custom tasks for running JOSM with the plugin loaded
+
+/**
+ * Reset the JOSM home directory
+ */
+task cleanJosm(type: Delete) {
+  delete "$buildDir/.josm"
+}
+
+/**
+ * Initialize the JOSM preferences
+ */
+task initJosmPrefs(type: Copy) {
+  if (!new File("$buildDir/.josm/preferences.xml").exists()) {
+    from "config/josm/preferences.xml"
+    into "$buildDir/.josm"
+  }
+}
+
+/**
+ * Puts the freshly compiled plugin jar into the JOSM home dir that is used from Gradle
+ */
+task updateJosmPlugin(type: Copy) {
+  dependsOn jar
+  dependsOn initJosmPrefs
+  from configurations.requiredPlugin
+  from "$buildDir/libs/${project.name}.jar"
+  into "$buildDir/.josm/plugins"
+  rename('(.*)-\\.jar', '$1.jar')
+  rename(project.name, project.hasProperty('plugin.jar.name') ? project.property('plugin.jar.name') : project.name)
+}
+
+/**
+ * This runs the JOSM-version specified in the dependency configuration above.
+ * The home-directory of this JOSM is located in $buildDir/.josm, so it doesn't interfere with any other JOSM-installations.
+ */
+task runJosm(type: JavaExec) {
+  dependsOn updateJosmPlugin
+  classpath = sourceSets.main.runtimeClasspath
+  main = 'JOSM'
+  jvmArgs "-Djosm.home=$buildDir/.josm"
+}
+
+/**
+ * Starts an instance of JOSM that is debuggable
+ */
+task debugJosm(type: JavaExec) {
+  dependsOn updateJosmPlugin
+  classpath = sourceSets.main.runtimeClasspath
+  main = 'JOSM'
+  jvmArgs "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7051", "-Djosm.home=$buildDir/.josm"
+}
Index: /applications/editors/josm/plugins/mapillary/gradle/manifest.gradle
===================================================================
--- /applications/editors/josm/plugins/mapillary/gradle/manifest.gradle	(revision 32693)
+++ /applications/editors/josm/plugins/mapillary/gradle/manifest.gradle	(revision 32693)
@@ -0,0 +1,38 @@
+import org.gradle.process.internal.ExecException;
+apply from: 'gradle/version-functions.gradle'
+
+// Required attributes
+def manifestAtts = [
+  "Created-By": System.getProperty("java.version") + " (" + System.getProperty("java.vendor") + ")",
+  "Gradle-Version": getGradle().getGradleVersion(),
+  "Plugin-Class": property('plugin.class'),
+  "Plugin-Date": String.format("%1\$tY-%1\$tm-%1\$tdT%1\$tH:%1\$tM:%1\$tS%1\$tz", new GregorianCalendar()),
+  "Plugin-Description": property('plugin.description'),
+  "Plugin-Mainversion": property('plugin.main.version'),
+  "Plugin-Version": property('plugin.svnrevision')
+]
+
+try {
+  manifestAtts["Plugin-SemVersion"] = getVersionName()
+} catch (ExecException e) {
+  System.out.println("This is probably not a git-repository. So the semantic version number is not available.")
+}
+
+// Optional attributes
+if (hasProperty('plugin.author')) {
+  manifestAtts["Author"] = property('plugin.author')
+}
+if (hasProperty('plugin.canloadatruntime')) {
+  manifestAtts["Plugin-Canloadatruntime"] = property('plugin.canloadatruntime')
+}
+if (hasProperty('plugin.icon')) {
+  manifestAtts["Plugin-Icon"] = property('plugin.icon')
+}
+if (hasProperty('plugin.link')) {
+  manifestAtts["Plugin-Link"] = property('plugin.link')
+}
+if (hasProperty('plugin.requires')) {
+  manifestAtts["Plugin-Requires"] = property('plugin.requires')
+}
+
+jar.manifest.attributes manifestAtts
Index: /applications/editors/josm/plugins/mapillary/gradle/tool-config.gradle
===================================================================
--- /applications/editors/josm/plugins/mapillary/gradle/tool-config.gradle	(revision 32693)
+++ /applications/editors/josm/plugins/mapillary/gradle/tool-config.gradle	(revision 32693)
@@ -0,0 +1,30 @@
+findbugs {
+  toolVersion = project.property('tool.findbugs.version')
+  ignoreFailures = true
+  effort = "max"
+  reportLevel = "low"
+}
+tasks.withType(FindBugs) {
+  reports {
+    xml.enabled = false
+    html.enabled = true
+  }
+}
+
+jacoco {
+  toolVersion = project.property('tool.jacoco.version')
+}
+jacocoTestReport {
+  reports {
+    xml.enabled true
+    html.destination "$buildDir/reports/jacoco"
+  }
+}
+build.dependsOn jacocoTestReport
+
+pmd {
+  toolVersion project.property('tool.pmd.version')
+  ignoreFailures true
+  targetJdk 1.7 // 1.8 is not yet available (as of Gradle 2.14.1, see https://docs.gradle.org/current/javadoc/org/gradle/api/plugins/quality/TargetJdk.html)
+  ruleSetConfig = resources.text.fromFile('config/pmd/ruleset.xml')
+}
Index: /applications/editors/josm/plugins/mapillary/gradle/version-functions.gradle
===================================================================
--- /applications/editors/josm/plugins/mapillary/gradle/version-functions.gradle	(revision 32693)
+++ /applications/editors/josm/plugins/mapillary/gradle/version-functions.gradle	(revision 32693)
@@ -0,0 +1,10 @@
+ext.getVersionName = { ->
+  def resultStream = new ByteArrayOutputStream()
+  def nullOut = new ByteArrayOutputStream()
+  exec {
+    commandLine 'git', 'describe', '--always', '--dirty'
+    standardOutput = resultStream
+    errorOutput = nullOut
+  }
+  return resultStream.toString().trim()
+}
Index: /applications/editors/josm/plugins/mapillary/gradle/wrapper/gradle-wrapper.properties
===================================================================
--- /applications/editors/josm/plugins/mapillary/gradle/wrapper/gradle-wrapper.properties	(revision 32692)
+++ /applications/editors/josm/plugins/mapillary/gradle/wrapper/gradle-wrapper.properties	(revision 32693)
@@ -3,4 +3,4 @@
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-all.zip
-distributionSha256Sum=65bbc0ef9c48be86fb06522fc927d59dcc7c04266f2bb8156be76971f7c3fc4a
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
+distributionSha256Sum=88a910cdf2e03ebbb5fe90f7ecf534fc9ac22e12112dc9a2fee810c598a76091
