3

I want that the java gradle plugins outputs warnings as errors when I do gradle build or gradle compileJava.

I tried to insert the following in my build.gradle:

allprojects {
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            // Warnings as errors
            options.compilerArgs <<  '-Werror'
        }
    }
}

or this:

compileJava {
 options.compilerArgs << "-Werror"
}

But the result is the same. Compile works without reporting anything.

How can I output warnings as error using the Gradle Java plugin?

Michael
  • 32,527
  • 49
  • 210
  • 370

0 Answers0