Update Gradle build to jdk1.7 and refactored code accordingly.