I'm trying to set up a small post-update hook to clean up some temporary files when my module is updated, but so far I haven't figured out the correct way to do this.
I've tried to extend and use the ModuleInstall class, but unfortunately it seems to be quite rusty and its methods installed/uninstalled/updated just don't work at all - they're literally never called. The "restored" method does work, but it's not what I want since that is called on every startup.
I have also tried to define a post-install callback using this manual: http://wiki.netbeans.org/DevFaqNbmPostInstall, which might be the correct way to do this, but I can't quite wrap my head around it with my admittedly limited java knowledge.
I've created a "main" folder with a single "Updater" class that does what I need in the main method. I also copied the main.properties file from the example and changed mainClass to Updater. However, this apparently isn't enough as Updater is still not called when I install the NBM. Also, when I open my NBM in netbeans editor, it doesn't recognize my "main" folder like it does with the example project.
I have no idea whether I should specify something in relativeClassPath and I also have no idea how to test whether my post-install class runs at all, throws some errors or whatever. Any advice?
Wow, can't believe I actually figured this out myself, but apparently I did!
It occurred to me that perhaps netbeans just doesn't create the NBM correctly and leaves out my main folder because it's simply bugged. I tried to create a new NBM out of the example project and guess what - it didn't work either. So my next step was to rename my NBM file to .zip, manually add my "main" folder into the archive and rename it back to .nbm. This did the job and my Updater class is now called correctly, I also found out the options in main.properties are indeed optional except for the mainClass.
Hope this helps someone in the future. I have also just filed a bug report to possibly get this fixed: https://netbeans.org/bugzilla/show_bug.cgi?id=262580.