# Unable to create a Checker: configLocation

**URL:** <https://discuss.gradle.org/t/unable-to-create-a-checker-configlocation/13216>\
**Category:** Help/Discuss\
**Created:** [December 13, 2015, 2:40pm UTC](https://discuss.gradle.org/t/unable-to-create-a-checker-configlocation/13216 "2015-12-13T14:40:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanniktech](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vanniktech/32/3680_2.png) [@vanniktech](https://discuss.gradle.org/u/vanniktech)\
**Post date:** [December 13, 2015, 2:40pm UTC](https://discuss.gradle.org/t/unable-to-create-a-checker-configlocation/13216/1 "2015-12-13T14:40:04Z")

</div>

I have a project with subprojects where some have the Java plugin applied and some have the Android Plugin applied.

My checkstyle configuration looks like this:

```
subprojects {
    plugins.apply('checkstyle')

    checkstyle {
        toolVersion = '6.13'
    }

    task checkstyle(type: Checkstyle) {
        configFile rootProject.file('code_quality_tools/checkstyle.xml')

        ignoreFailures false
        showViolations true

        source 'src'
        include '**/*.java'

        classpath = files()
    }
}

```

When I execute `./gradlew clean checkstyle` everything works as planned and I do get the checkstyle reports.

However the moment I execute `./gradlew clean build` I get this error:

> Caused by: : Unable to create a Checker: configLocation {\<project\_path\>/\<java\_module\>/config/checkstyle/checkstyle.xml}, classpath {\<project\_path\>/\<java\_module\>/build/classes/main:\<project\_path\>\<java\_module\>/build/resources/main}.  
> at com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask.createChecker(CheckstyleAntTask.java:416)  
> at com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask.realExecute(CheckstyleAntTask.java:320)  
> at com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask.execute(CheckstyleAntTask.java:303)  
> 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:78)  
> at org.gradle.api.internal.project.antbuilder.AntBuilderDelegate.nodeCompleted(AntBuilderDelegate.groovy:80)  
> at org.gradle.api.plugins.quality.Checkstyle$\_run\_closure1.doCall(Checkstyle.groovy:146)  
> 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.api.internal.project.antbuilder.DefaultIsolatedAntBuilder$3.execute(DefaultIsolatedAntBuilder.java:178)  
> at org.gradle.api.internal.project.antbuilder.DefaultIsolatedAntBuilder$3.execute(DefaultIsolatedAntBuilder.java:160)  
> at org.gradle.api.internal.project.antbuilder.ClassPathToClassLoaderCache.withCachedClassLoader(ClassPathToClassLoaderCache.java:139)  
> at org.gradle.api.internal.project.antbuilder.DefaultIsolatedAntBuilder.execute(DefaultIsolatedAntBuilder.java:154)  
> 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:227)

The Java Module is trying to default back to the [default configFile location](https://docs.gradle.org/current/dsl/org.gradle.api.plugins.quality.CheckstyleExtension.html#org.gradle.api.plugins.quality.CheckstyleExtension:configFile) even though I did specify it.

The moment I add the Checkstyle configuration file to `<project_path>/<java_module>/config/checkstyle/checkstyle.xml`, `./gradlew clean build` does work.

I’ve tested this with Gradle versions: 2.8, 2.9 and 2.10-rc-1 and none of them do work.

---

<div class="post-metadata">

**Author:** ![sterling](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/sterling/32/5395_2.png) [@sterling](https://discuss.gradle.org/u/sterling)\
**Post date:** [December 13, 2015, 8:29pm UTC](https://discuss.gradle.org/t/unable-to-create-a-checker-configlocation/13216/2 "2015-12-13T20:29:56Z")

</div>

The `checkstyle` plugin automatically adds some checkstyle tasks to Java projects (I imagine the task that fails is `checkstyleMain`?). You’re only configuring `configFile` for the `Checkstyle` task that you created (called `checkstyle`).

I think if you moved `configFile rootProject.file('code_quality_tools/checkstyle.xml')` into the `checkstyle {}` extension block, it would work. This configures the defaults (in the extension) for all `Checkstyle` tasks.

---

<div class="post-metadata">

**Author:** ![vanniktech](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vanniktech/32/3680_2.png) [@vanniktech](https://discuss.gradle.org/u/vanniktech)\
**Post date:** [December 13, 2015, 9:49pm UTC](https://discuss.gradle.org/t/unable-to-create-a-checker-configlocation/13216/3 "2015-12-13T21:49:08Z")

</div>

Yep you’re right `checkstyleMain` failed and moving the `configFile` into `checkstyle` did work. Thanks!
