tidy up build scripts

- separate out common logic for distribution and non-distribution builds
- move library versions to top-level ext block
- enable sources & javadoc for all jar archives
- move sourceCompatibility & targetCompatibility to gradle.properties