java - ./gradlew 运行构建失败

标签 java linux eclipse gradle webdriver

我已经设置了 build.gradle 文件,目前我的项目运行良好。现在的问题是当我运行 ./gradlew run 时,它失败并显示错误:

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

最佳答案

将 build.gradle 中的 mainClassName = 'src.main.java.Functional.TestRun' 替换为 mainClassName = Functional.TestRun'。您还应该修复您的 list 条目。

关于java - ./gradlew 运行构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36546422/

相关文章:

java - KeyListener 在 Java 中不起作用

linux - 使用 sed,行切割提取 sql 插入

django - 无法启动Django项目: No Module Named django.核心

java - Eclipse null 分析引发误报 NullPointerException 警告

Eclipse tomcat错误: Document base does not exist or is not a readable directory

java - 如何从 Retrofit2 拦截器开始登录 Activity

java - 使用 Jackson 解析器获取整个 JSON 对象

linux - Unix shell 描述符重定向

java - Web 服务的生命周期异常

Java 抽象类 - 实例变量应该是私有(private)的还是 protected ?