Task 'run' not found in root project

C:\Users\LAB4>gradle run

FAILURE: Build failed with an exception.

  • What went wrong:
    Task ‘run’ not found in root project ‘LAB4’.

  • Try:
    Run gradle tasks to get a list of available tasks. Run with --stacktrace option
    to get the stack trace. Run with -
    or -
    option to get more log output.


Bulid gradle file:

apply plugin: 'java’
apply plugin: ‘application’

mainClassName = 'GmailQuickstart’
sourceCompatibility = 1.7
targetCompatibility = 1.7
version = ‘1.0’

repositories {

dependencies {
compile 'com.google.api-client:google-api-client:1.20.0’
compile 'com.google.oauth-client:google-oauth-client-jetty:1.20.0’
compile ‘com.google.apis:google-api-services-gmail:v1-rev29-1.20.0’


What is the output of gradle tasks?

I am having the same issue, with my first project (following a Spark tutorial). Here is the output of “gradle tasks”

All tasks runnable from root project

Build tasks

assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend
on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles main classes.
clean - Deletes the build directory.
jar - Assembles a jar archive containing the main classes.
testClasses - Assembles test classes.

Build Setup tasks

init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]

Documentation tasks

javadoc - Generates Javadoc API documentation for the main source code.

Help tasks

buildEnvironment - Displays all buildscript dependencies declared in root projec
t ‘redemption-api’.
components - Displays the components produced by root project ‘redemption-api’.
dependencies - Displays all dependencies declared in root project ‘redemption-ap
dependencyInsight - Displays the insight into a specific dependency in root proj
ect ‘redemption-api’.
help - Displays a help message.
model - Displays the configuration model of root project ‘redemption-api’. [incu
projects - Displays the sub-projects of root project ‘redemption-api’.
properties - Displays the properties of root project ‘redemption-api’.
tasks - Displays the tasks runnable from root project ‘redemption-api’.

IDE tasks

cleanEclipse - Cleans all Eclipse files.
eclipse - Generates all Eclipse files.

Upload tasks

uploadArchives - Uploads all artifacts belonging to configuration ‘:archives’

Verification tasks

check - Runs all checks.
test - Runs the unit tests.


Pattern: clean: Cleans the output files of a task.
Pattern: build: Assembles the artifacts of a configuration.
Pattern: upload: Assembles and uploads the artifacts belongin
g to a configuration.

To see all tasks and more detail, run gradle tasks --all

To see more detail about a task, run gradle help --task


Total time: 6.517 secs`

I figured it out: my gradle.build did not have the line

apply plugin: ‘application’

The build file was generated by gradle 1.5 in Eclipse, which I then upgraded to 2.11. I leave this here in case anyone else encounters the issue. I also needed to specify

mainClassName = ‘Main’

use single-quotes, I got an error with double-quotes.

1 Like