A working gradle build

These changes fix the issues related to gradle builds.
For more details about the issues, see branch 'test-gradle-build'.