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)