How can I set up builds of Play apps and (custom) Play modules in a CI system so that when a module's build is good, the build installs the module artifacts in a local repository and/or deploys them to a remote repository, and the apps use the artifacts in that repository?

The solution should also work well for a developer who's working locally.

I'm using Jenkins, and running in trouble whatever way I try to do this.

Before I elaborate on all the problems I've encountered, I'll wait, because it is laborious, and maybe someone else can offer how they do it.