Checkstyle plugin gives NPE

Hi everyone,

I’m trying add the checkstyle plugin. It seems that it can’t load the configuration file; I’m using this exact same configuration file in ant directly. Any ideas? I’m using Gradle 2.6

Stacktrace:

Caused by: : Unable to create a Checker: null
    at com.puppycrawl.tools.checkstyle.CheckStyleTask.createChecker(CheckStyleTask.java:362)
    at com.puppycrawl.tools.checkstyle.CheckStyleTask.realExecute(CheckStyleTask.java:280)
    at com.puppycrawl.tools.checkstyle.CheckStyleTask.execute(CheckStyleTask.java:243)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(BasicAntBuilder.java:77)
    at org.gradle.api.internal.project.AntBuilderDelegate.nodeCompleted(DefaultIsolatedAntBuilder.groovy:177)
    at org.gradle.api.plugins.quality.Checkstyle$_run_closure1.doCall(Checkstyle.groovy:142)
    at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:67)
    at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
    at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:91)
    at org.gradle.util.ConfigureUtil$configure.call(Unknown Source)
    at org.gradle.api.internal.project.DefaultIsolatedAntBuilder.execute(DefaultIsolatedAntBuilder.groovy:108)
    at org.gradle.api.internal.project.IsolatedAntBuilder$execute$0.call(Unknown Source)
    at org.gradle.api.plugins.quality.Checkstyle.run(Checkstyle.groovy:139)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:226)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:219)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:208)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 14 more
Caused by: java.lang.NullPointerException
    at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:128)
    at com.puppycrawl.tools.checkstyle.CheckStyleTask.createChecker(CheckStyleTask.java:353)

Config:

checkstyle {
    toolVersion '6.7' //We can't go above this until Gradle 2.7 https://issues.gradle.org/browse/GRADLE-3314
    configFile project.rootProject.file('checkstylefilter.xml')
    ignoreFailures true
    showViolations false
}

What’s the contents of checkstylefilter.xml? Does it define a SuppressionFilter with a path relative to checkstylefilter.xml?

Are you using the same version of Checkstyle with Ant?

The only thing in the configuration is suppression elements. I’m using version 6.4.1 with Ant, but using that version with gradle gives the same error as reported above with 6.7.

<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
    "-//Puppy Crawl//DTD Suppressions 1.1//EN"
    "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">

<suppressions>
    <suppress files=".*[\\/]com[\\/]leanlogistics[\\/]custom[\\/]ws[\\/].*" checks=".*"/>
    ... (several more, all similar to above)
</suppressions>

I’m brain dead, this is included by another file and I’m using the wrong one. Sorry for the hassle.