Step 1: Decide how you are going to build it. I would not recommend gradle. ant and maven will both work, and I’ve got examples for both. If you go the ant route, you’ll need a specific folder hierarchy (unless you want to do a lot of work). If you go the maven route, JOSM releases and plugins can be found on Nexus Repository Manager .
The JOSM mapwithai plugin has a standalone pom.xml file that you can use as an example. I would recommend ignoring all the stuff to manually set directories though – that was done for compatibility the the ant build system.
Of specific note, the JOSM main jar and any plugins should be marked as provided in maven, not compile. This will keep default settings for fat jar creation from adding those dependencies to your jar file.
Step 2: Write the plugin entry point. See MapWithAIPlugin.java for an example. Of specific note, you just need a constructor method that takes a PluginInformation object, but I would strongly recommend extending Plugin instead.
Step 3: Figure out what your plugin will do. This is where things get complicated.