How to set up a JOSM plugin with Maven dependencies

I’m stumped by the process of setting up the development environment for a JOSM plugin that uses Maven dependencies (including a considerable number of transitive dependencies).

While the possibility of using Maven to build plugins is occasionally mentioned, the guide on developing plugins only properly documents using Ant. And while I was successfully able to follow that guide to set up the environment to build a simple plugin without dependencies, I didn’t get much further. Using Ivy and a custom ivy_settings.xml file defining an extra resolver (the dependency is hosted on jitpack), I was able to pull in a dependency and run ant dist, but as the plugin jar doesn’t include the transitive dependencies, I naturally get plenty of NoClassDefFoundErrors at runtime.

(It should be noted that my most recent encounters with Ant (or SVN) were brief and more than a decade ago, so I’m far outside my comfort zone here.)

It should be quite easy. Something like this:

  <dependencies>
        <!-- JOSM main dependency -->
        <dependency>
            <groupId>org.openstreetmap.josm</groupId>
            <artifactId>josm</artifactId>
            <version>${josm.version}</version>
            <scope>provided</scope>
        </dependency>
     ...
  </dependencies>

I guess you could use the pom file of this project as example. :wink:

1 Like