Build script improvements

* Detects Java version and doesn't add MaxPermSize argument if 1.8 or
  later (copied from Activator)
* Support for a debug parameter (similar to old play script)
Merge pull request #2851 from jroper/build-script

Build script improvements