Adds support for jar files (in order to support generation of webjars - www.webjars.org); extracts duplicate code.