[autobuild] org.gradle.execution.TaskSelectionException: Task 'testClasses' not found in root project 'xx' and its subprojects.

See original GitHub issue

I have a brand new “Hello World” Android project created by Android Studio called HMMobile. I am trying to enable CodeQL (Java).

Here is the minimum reproduction repo: https://github.com/Hongbo-Miao/bug-codeql-java

CodeQL full error log

In the CodeQL autobuild step, these lines worth mentioning:

  [2022-12-04 00:02:09] [autobuild] > ./gradlew --no-daemon -S -Dorg.gradle.dependency.verification=off --init-script "/tmp/semmleTempDir/init.gradle" testClasses
  [2022-12-04 00:02:09] [autobuild] Picked up JAVA_TOOL_OPTIONS:  -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false
  [2022-12-04 00:02:10] [autobuild] To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.4/userguide/gradle_daemon.html#sec:disabling_the_daemon.
  [2022-12-04 00:02:11] [autobuild] Daemon will be stopped at the end of the build 
  [2022-12-04 00:02:18] [autobuild] FAILURE: Build failed with an exception.
  [2022-12-04 00:02:18] [autobuild] * What went wrong:
  [2022-12-04 00:02:18] [autobuild] Task 'testClasses' not found in root project 'HMMobile'.
  [2022-12-04 00:02:18] [autobuild] * Try:
  [2022-12-04 00:02:18] [autobuild] > Run gradlew tasks to get a list of available tasks.
  [2022-12-04 00:02:18] [autobuild] > Run with --info or --debug option to get more log output.
  [2022-12-04 00:02:18] [autobuild] > Run with --scan to get full insights.
  [2022-12-04 00:02:18] [autobuild] * Exception is:
  [2022-12-04 00:02:18] [autobuild] org.gradle.execution.TaskSelectionException: Task 'testClasses' not found in root project 'HMMobile'.

My code has no testClasses inside. I am wondering why does CodeQL run the command with testClasses?

./gradlew --no-daemon -S -Dorg.gradle.dependency.verification=off --init-script "/tmp/semmleTempDir/init.gradle" testClasses

(For default Android project created by Android Studio, the command to build is just ./gradlew build. The command for unit test is ./gradlew test)

Any guide to help fix would be appreciate. Thanks! 😃

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:8

github_iconTop GitHub Comments

3reactions
smowtoncommented, Dec 12, 2022

The fix has been merged and will ship in the next CodeQL release after Christmas (expected mid-January). The cause was standard Android Gradle projects no longer explicitly referencing com.android.tools.build:gradle as of earlier this year, and consequently our autobuild heuristic to recognise such a project and avoid using the non-existent testClasses target no longer worked.

3reactions
smowtoncommented, Dec 6, 2022

I’ve identified the change we need to make; hope to have a fix PR today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trying Gradle build - "Task 'build' not found in root project"
What's the final result that I want to accomplish - First I want to figure out where is my mistake and how to...
Read more >
Task 'run' not found in root project - Gradle Forums
FAILURE: Build failed with an exception. What went wrong: Task 'run' not found in root project 'LAB4'. Try: Run gradle tasks to get...
Read more >
'Project not found in root project' when running Gradle test ...
'Project not found in root project' when running Gradle test package. Relates to 1. Relates to 1 issue (1 unresolved). N. IDEA-201911 Gradle...
Read more >
Task with name 'build' not found in root project ... - GitHub
A problem occurred configuring root project 'gradlebuild_examples'. Task with name 'build' not found in root project gradlebuild_examples'.
Read more >
Task 'assembleDebug' not found in root project - Google Groups
What went wrong: Task 'assembleDebug' not found in root project 'myProjectName'. however when I build in Android Studio or run gradlew build ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found