Skip to content
Advertisement

./gradlew run BUILD FAILED

I have my build.gradle file set up and my project is working good so far. The problem now is when i run ./gradlew run, it fails with the error :

What went wrong: Execution failed for task ‘:run’. Process ‘command ‘/usr/lib/jvm/java-7-openjdk-amd64/bin/java” finished with non-zero exit value 1

./gradlew build BUILD SUCCESSFULLY, Any clue as to why, Have also tried to check previous thread but all to no avail.Below is my gradle.build file:

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'

mainClassName = 'src.main.java.Functional.TestRun'

repositories {
mavenCentral()
}
sourceSets {
selenium
}

jar {
baseName = 'gs-gradle'
version =  '0.1.0'
manifest {
    attributes 'Main-Class': 'main.java.Functional.TestRun'
   }
}
compileJava {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}

dependencies {
seleniumCompile 'junit:junit:4.11'
seleniumCompile 'org.seleniumhq.selenium:selenium-java:2.45.0'
seleniumCompile 'org.seleniumhq.selenium:selenium-server:2.45.0'    
compile fileTree(dir: 'libraries', include: '*.jar') 
}
task jettyDaemon(type: org.gradle.api.plugins.jetty.JettyRun) {
daemon = true
}
task selenium(type: Test, dependsOn: jettyDaemon) {
testClassesDir = sourceSets.selenium.output.classesDir
classpath = sourceSets.selenium.runtimeClasspath
}
eclipse {
classpath {
    plusConfigurations += configurations.seleniumCompile
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}

ERROR:

ola@ola-VirtualBox:~/workspace/mainsite_automation$ ./gradlew run
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:run
Error: Could not find or load main class src.main.java.Functional.TestRun
:run FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished           
with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --     
debug option to get more log output.

BUILD FAILED

Total time: 2.185 secs

Advertisement

Answer

Replace mainClassName = 'src.main.java.Functional.TestRun' in your build.gradle by mainClassName = Functional.TestRun'. You should also fix your manifest entry.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement