Gradle For Android: Why Doesn't Javaexec Pick Up My Classpath?
I have an Android project (on Windows) where I am trying to run cucumber-jvm as a non-instrumented 'unit test'. I.e. execute Cucumber features when I run gradlew test. Here are the
Solution 1:
I believe I've found a solution for my issue. Here's the code that works for me:
testOptions {
unitTests.all {
def classpath2 = getClasspath()
javaexec {
main = "cucumber.api.cli.Main"
classpath = classpath2
args = ['--plugin', 'pretty', '--glue', 'gradle.cucumber', 'src/test/java/cucumber/assets']
}
}
}
It seems to me that my original call to getClassPath()
inside the javaexec
closure was returning an empty file collection. At the same time, in the closure for unitTests.all
, getClassPath()
contains the correct classpath.
By passing the classpath from the external closure into the internal closure via a variable, cucumber.api.cli.Main
now runs successfully and my Cucumber features run as part of the Gradle test
task.
Post a Comment for "Gradle For Android: Why Doesn't Javaexec Pick Up My Classpath?"