The widgetset error

I’ve been using the framework to build a few apps and I’m generally quite happy with it, except for that dreaded error that says “Requested resource
[/VAADIN/widgetsets/AppWidgetset/AppWidgetset.nocache.js] not found…”
I get it when I’m including new addons, either from a JAR file or through Maven. Sometimes, if I’ve added the dependency in Maven, adding the JAR file as well fixes it, sometimes it’s the other way around, other times compiling the widgetset and theme fixes it, and sometimes nothing helps. This type of behavior seems to me more random than scientific.
I would love to know how to properly add dependencies to the project so that I can avoid this problem.