Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a gradle build finish successful with checkstyle errors?

I haven an Android Gradle build that is run on Jenkins.

Jenkins checks checkstyle warnings and errors and publishes the results. If there is a checkstyle error the build stops and is marked as failed. Jenkins also stops and does not publish the checkstyle report.

How can I let the build run through even with checkstyle errors?

like image 717
Janusz Avatar asked Nov 26 '14 09:11

Janusz


People also ask

What is Checkstyle plugin in Gradle?

The Checkstyle plugin performs quality checks on your project’s Java source files using Checkstyle and generates reports from these checks. Here we will see how to use checkstyle plugin in gradle based project.

How do I check the quality of a Gradle project?

Example 1. Using the Checkstyle plugin The plugin adds a number of tasks to the project that perform the quality checks. You can execute the checks by running gradle check. Note that Checkstyle will run with the same Java version used to run Gradle. The Checkstyle plugin adds the following tasks to the project:

Does Checkstyle work with Java build tasks?

We continue to add code analysis tooling to the Java build tasks with Checkstyle support for Gradle, and – in a few days – for Maven. Checkstyle is the analyzer of choice for enforcing a coding standard.

What is the config file for the Checkstyle plugin?

In our case, the config file is checkstyle.xml. The goal check mentioned in the execution section asks the plugin to run in the verify phase of the build and forces a build failure when a violation of coding standards occurs.


2 Answers

There is an even nicer and easier solution than that from Rene. Just add:

checkstyle {
   ignoreFailures = true
}

to your build.gradle file.

like image 169
Janusz Avatar answered Oct 09 '22 15:10

Janusz


The Checkstyle task can be configured to ignore failures:

checkstyleTask.ignoreFailures = true
like image 24
Rene Groeschke Avatar answered Oct 09 '22 16:10

Rene Groeschke