Improves diagnostic output and ensures separate build destination

Any generated metadata.json file would end up in the actual Module
source tree prior to this commit. Now care is taken to perform the
actual build beneath the build output directory. In essence, the
module is first copied before the metadata.json is added.

This commit also contains some improvements to diagnostics.