diff --git a/gradle/javaproject.gradle b/gradle/javaproject.gradle
index 5381460644d0d271292c9e0b0d1f6dbb92a99fa1..b1425c13ec24adaa3bc632ed171b83200d650d96 100644
--- a/gradle/javaproject.gradle
+++ b/gradle/javaproject.gradle
@@ -8,6 +8,7 @@ task wrapper(type: Wrapper) {
     distributionUrl = "http://svncisd.ethz.ch/repos/cisd/ivy-repository/trunk/gradle/distribution/1.8/gradle-1.8-all.zip"
 }
 
+addSource = (sourceCompatibility == org.gradle.api.JavaVersion.VERSION_1_6)
 sourceCompatibility='1.6'
 targetCompatibility='1.6'
 
@@ -131,8 +132,13 @@ compileJava {
     doFirst {
         options.forkOptions.with {
             executable = 'java'
-            jvmArgs = ['-cp', configurations.ecj.asPath, 'org.eclipse.jdt.internal.compiler.batch.Main', 
-                       '-nowarn']
+            if (addSource) {
+	            jvmArgs = ['-cp', configurations.ecj.asPath, 'org.eclipse.jdt.internal.compiler.batch.Main', 
+	                       '-nowarn', '-source', '1.6']
+	        } else {
+	            jvmArgs = ['-cp', configurations.ecj.asPath, 'org.eclipse.jdt.internal.compiler.batch.Main', 
+	                       '-nowarn']
+	        }
         }
     }
 }
@@ -143,8 +149,13 @@ compileTestJava {
     doFirst {
         options.forkOptions.with {
             executable = 'java'
-            jvmArgs = ['-cp', configurations.ecj.asPath, 'org.eclipse.jdt.internal.compiler.batch.Main', 
-                       '-nowarn']
+            if (addSource) {
+	            jvmArgs = ['-cp', configurations.ecj.asPath, 'org.eclipse.jdt.internal.compiler.batch.Main', 
+	                       '-nowarn', '-source', '1.6']
+	        } else {
+	            jvmArgs = ['-cp', configurations.ecj.asPath, 'org.eclipse.jdt.internal.compiler.batch.Main', 
+	                       '-nowarn']
+	        }
         }
     }
 }