'Gradle cucumber error in command-line - command 'C:\Java\jdk-17\bin\java.exe'' finished with non-zero exit value 1
When I run cucumber test from IntelliJ terminal commandline and get subject error:
λ gradlew cucumber
Configuration on demand is an incubating feature.
> Task :compileTestKotlin
'compileTestJava' task (current target is 17) and 'compileTestKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java ver
sion.
> Task :cucumber FAILED
Version:
λ java --version
java 17 2021-09-14 LTS
Java(TM) SE Runtime Environment (build 17+35-LTS-2724)
Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)
λ gradle --version
------------------------------------------------------------
Gradle 7.4.2
------------------------------------------------------------
Build time: 2022-03-31 15:25:29 UTC
Revision: 540473b8118064efcc264694cbcaa4b677f61041
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 17 (Oracle Corporation 17+35-LTS-2724)
OS: Windows 10 10.0 amd64
However I have below code in my build.gradle file
task integrationTest(type: Test) {
useJUnitPlatform()
description = 'Run integration tests.'
check.dependsOn(it)
group = 'verification'
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
shouldRunAfter test
}
tasks.withType(Test) {
useJUnitPlatform()
// Prints any test outcomes to the console
testLogging {
events "passed", "skipped", "failed"
showStackTraces true
showExceptions true
showCauses true
exceptionFormat "full"
}
}
sourceSets {
integrationTest {
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}
configurations {
cucumberRuntime {
extendsFrom testImplementation
}
integrationTestImplementation.extendsFrom implementation
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntimeOnly.extendsFrom runtimeOnly
}
java.sourceCompatibility = JavaVersion.VERSION_17
java.targetCompatibility = java.sourceCompatibility
task cucumber() {
dependsOn assemble, testClasses
doLast {
javaexec { <============ Line 279 ===========
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin', 'pretty',
'--plugin', 'html:target/cucumber-report.html',
'--glue', 'xxxxx.stepdefinitions',
'src/integrationTest/resources']
}
}
}
Not sure what is missing. However cucumber tests are running via IntelliJ IDE edit configuration without any issue.
This is stacktrace error:
> Task :cucumber FAILED
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\xxxxx\build.gradle' line: 279 <==========
* What went wrong:
Execution failed for task ':cucumber'.
> Process 'command 'C:\Java\jdk-17\bin\java.exe'' finished with non-zero exit value 1
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':cucumber'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:147)
....
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
Caused by: org.gradle.process.internal.ExecException: Process 'command 'C:\Java\jdk-17\bin\java.exe'' finished with non-zero exit value 1
at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:414)
at org.gradle.process.internal.DefaultJavaExecAction.execute(DefaultJavaExecAction.java:52)
Solution 1:[1]
The exception clearly tells the reasons:
Caused by: org.gradle.process.internal.ExecException: Process 'command 'C:\Java\jdk-17\bin\java.exe'' finished with non-zero exit value 1
For some reason, the Java executable fails to launch the process on your system. The common problem could be with the antivirus/firewall blocking the process. Make sure to exclude the JDK directory from the scan.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Andrey |