Gradle build system

In case anyone is interested, these commits should enable gradle build on the project.