After upgrading to 2.14-rc-2 checkstyle task fails with exception

After upgrading to 2.14-rc-2 we observe checkstyle task failing with exception:

Caused by: java.io.FileNotFoundException: /Users/sfaber/linkedin/tscp-targeting_trunk/targeting/tscp-targeting-api/config/checkstyle/checkstyle.xml

Full stack trace below. It could be that it’s our configuration of the checkstyle plugin causes the behavior. However, it works with Gradle 2.13 but stopped working with the 2.14. In the release notes I see there were changes in checkstyle task (conversion to java! yay!!!). I will dig more into this issue but if you have some pointers now it would be great.

We configure the Checkstyle task with custom ‘configFile’. Without digging deeper, could it be that in certain projects this configFile setting is no longer respected? Only some portion of our projects fails consistently with this exception with 2.14.

Thanks in advance for any pointers!!!

Full exception:

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:targeting:tscp-targeting-api:checkstyleMainGeneratedDataTemplate’.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
    Caused by: : Unable to create a Checker: unable to find /Users/sfaber/linkedin/tscp-targeting_trunk/targeting/tscp-targeting-api/config/checkstyle/checkstyle.xml
    at com.puppycrawl.tools.checkstyle.CheckStyleTask.createChecker(CheckStyleTask.java:383)
    at com.puppycrawl.tools.checkstyle.CheckStyleTask.realExecute(CheckStyleTask.java:300)
    at com.puppycrawl.tools.checkstyle.CheckStyleTask.execute(CheckStyleTask.java:262)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
    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.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:371)
    at org.gradle.internal.metaobject.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:166)
    at org.gradle.internal.metaobject.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:163)
    at org.gradle.api.internal.project.antbuilder.AntBuilderDelegate.nodeCompleted(AntBuilderDelegate.java:118)
    at org.gradle.api.plugins.quality.Checkstyle$_run_closure1.doCall(Checkstyle.groovy:150)
    at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:67)
    at org.gradle.api.internal.project.antbuilder.DefaultIsolatedAntBuilder$2.execute(DefaultIsolatedAntBuilder.java:145)
    at org.gradle.api.internal.project.antbuilder.DefaultIsolatedAntBuilder$2.execute(DefaultIsolatedAntBuilder.java:127)
    at org.gradle.api.internal.project.antbuilder.ClassPathToClassLoaderCache.withCachedClassLoader(ClassPathToClassLoaderCache.java:134)
    at org.gradle.api.internal.project.antbuilder.DefaultIsolatedAntBuilder.execute(DefaultIsolatedAntBuilder.java:121)
    at org.gradle.api.internal.project.IsolatedAntBuilder$execute$0.call(Unknown Source)
    at org.gradle.api.plugins.quality.Checkstyle.run(Checkstyle.groovy:143)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:228)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:621)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:604)
    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: com.puppycrawl.tools.checkstyle.api.CheckstyleException: unable to find /Users/sfaber/linkedin/tscp-targeting_trunk/targeting/tscp-targeting-api/config/checkstyle/checkstyle.xml
    at com.puppycrawl.tools.checkstyle.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:342)
    at com.puppycrawl.tools.checkstyle.CheckStyleTask.createChecker(CheckStyleTask.java:356)
    … 39 more
    Caused by: java.io.FileNotFoundException: /Users/sfaber/linkedin/tscp-targeting_trunk/targeting/tscp-targeting-api/config/checkstyle/checkstyle.xml
    at com.puppycrawl.tools.checkstyle.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:328)
    … 40 more

The Checkstyle task itself is still Groovy (but annotated with @CompileStatic).

Does /Users/sfaber/linkedin/tscp-targeting_trunk/targeting/tscp-targeting-api/config/checkstyle/checkstyle.xml actually exist? Is that the same path used by 2.13?

Are you setting configFile in the checkstyle extension or on the task itself?

Do you happen to have a Closure as an extra property that’s named checkstyle that configures the checkstyle extension?

I found out what the problem is - it’s on our side. Thanks Sterling for looking into it!

In our base plugins we remove checktyle dependencies from the ‘check’ task (design choice). This ‘removal’ is pretty hacky and is coupled with Gradle’s impl details (we use getDependsOn, manipulate the results and then setDependsOn). We will fix this and avoid coupling with impl details.

Some suggestions for Gradle :slight_smile:

  • It turns out that checkstyle task breaks somewhat confusingly if the config file is not provided. Perhaps Gradle’s Checkstyle task should have the configFile property mandatory?
  • It would be nice if the model was more tweakable - e.g. if we were able to cleanly modify the task dependencies declared by Gradle’s bulit-in plugins. I hope new configuration model helps addressing it.

Thanks for your report. We’re still doing a RC3 due to another problem we found.

Yeah, it’s defaulting to a particular path (which probably only makes sense in single-project builds). I think it would be better if we defaulted to one of the built-in checkstyle configs (https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml) instead. That would be better out-of-the-box experience.

Yeah, at the very least, just making that sort of behavior separate from the bulk of the plugin’s behavior. That’s the sort of thing we’ve done with the new test suite plugins. There’s a base that adds all the functionality and a separate conventions plugin that assumes these sorts of defaults.