Q:

`assert` is a keyword, compiling with Gradle

I'm compiling a Java project with Gradle.  When I run gradle build, I get:

Task :compileJava FAILED
  /home/mvh/projects/research/DPM/src/main/java/DPM/bandera/Bandera.java:102: error: as of release 1.4, 'assert' is a keyword, and may not be used as an identifier
      public static void assert(boolean expr) {
                         ^
    (use -source 1.3 or lower to use 'assert' as an identifier)
  1 error

Apparently when compiling with javac, the solution is to add the argument -source 1.3, per the error message.  So I tried adding this argument in gradle as follows:
compileJava {
    options.compilerArgs << '-ea'
}

I also tried enableassertions, -enableassertions, and ea in place of -ea.
I also tried this:
test {
    enableAssertions = true
}

Also to no avail.  How can I get my gradle build file to enable assertions when it compiles my project?  Thanks!

A:

Did you tried?
compileJava {
    options.compilerArgs << '-source 1.3'
}

I have to warn you this way you loose all "modern" language features (like generics).
PS:
Proper solution will be rename assert method in class Bandera.
EDIT
Correct way to set this flag is 
compileJava {
    sourceCompatibility = 1.3
}

Renaming method is better way to solve this issue.

