Gradle and Ant build producing different .class files (of the same size) from same .java file

I found that with our Gradle build and Ant build of the same source files is producting .class files of the same size, yet when I do a ‘diff’ on the .class files, they differ. I would suspect it’s some compiler option that is different between the two builds, but wanted to check if anyone else had ran into similar scenarios.

Nevermind that. I realized that my Ant build was using Java 7, and the Gradle build was using Java 6. Once I changed my build.gradle to use 1.7, diff produced no differences.

I confirmed that I’m using JDK_1.8 in ant as well as in Gradle but still seeing the size differences in few KBs.

I compared the content of the classes, it seems to be same… not getting what could be the differences.

If you want to print out the compiler args you can do something like

tasks.withType(JavaCompile) { task ->
   doFirst {
      println "Compiling: $project.name - $task.name - $task.options.allCompilerArgs"
   } 
} 

See CompileOptions