Checkstyle not found in root project


I am trying to move my Gradle test project to Teamcity. When I run the project, I am getting below problem.

[06:22:43][Step 1/1] ##teamcity[buildProblem identity=‘1951325147’ description=‘org.gradle.execution.TaskSelectionException: Task |’.checkstyle|’ not found in root project |‘224080ebb5779376|’.’ type=‘gradleBuildProblem’]

I already have below in my build.gradle. Please let me know what could be going wrong.

apply plugin: ‘checkstyle’

checkstyle {
toolVersion = '6.4.1’
sourceSets = [sourceSets.main]
configFile = rootProject.file("/checkstyle.xml");
showViolations = true
ignoreFailures = true

checkstyleTest {
enabled = false

tasks.withType(Checkstyle) {
reports {
html.destination rootProject.file(“build/reports/checkstyle.html”)


There is no task called “checkstyle”. The task for the main source set is called “checkstyleMain”. Depending on your use case you might just wanna call check (which also runs all tests) or create an aggregator task for all your code quality tasks:

task codeQuality() {
  dependsOn tasks.withType(CheckStyle)

Thank you for your reply.

I had missed out on adding settings.gradle to my git repo, I have done it now.

I deleted a hidden file called .checkstyle from my project. Now the error has changed to ‘org.gradle.execution.TaskSelectionException: Task |’.classpath|’ not found in $MYPROJECTNAME. Both .checkstyle and .classpath are hidden files in my project.

I am new to Gradle so might have made some mistake, does the information above provide any clue?

Looks like your teamcity config is broken. Can you take a screenshot of it?

Config is very basic. I have attached above.

Please note, there were some arguments for tests such as URL etc that were passed in "Additional Gradle command line parameters: " as -PenvUrl=Test1 that I have removed.

Thank you for poining me to the right direction. I was using -P flag for values that I actually wanted to pass to my Java tests. I have updated that to -D. Now build is going on fine. Your help is very much appreciated :slight_smile:

1 Like