diff --git a/build.gradle b/build.gradle
index 4cc10616fd8c35ced26dd20ff76b1cfba334fcdb..4c96ee6bd881da815cf7e30e0c062bfffc80a59e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,20 +17,22 @@ wrapper {
   distributionType = Wrapper.DistributionType.ALL
 }
 
-sourceCompatibility = 7
-targetCompatibility = 7
-
 repositories {
   mavenCentral()
 }
 
-mainClassName = "org.sablecc.sablecc.SableCC"
-
 java {
+  sourceCompatibility = JavaVersion.VERSION_1_7
+  targetCompatibility = JavaVersion.VERSION_1_7
+
   withSourcesJar()
   withJavadocJar()
 }
 
+application {
+  mainClass = "org.sablecc.sablecc.SableCC"
+}
+
 processResources {
   inputs.property("project.version", project.version)
   filesMatching("org/sablecc/sablecc/build.properties") {
@@ -41,7 +43,7 @@ processResources {
 jar {
   manifest {
     attributes([
-      'Main-Class': mainClassName,
+      'Main-Class': application.mainClass.get(),
       'Automatic-Module-Name': 'org.sablecc.sablecc',
     ])
   }