How can i run an uberJar comprised of cucumber/groovy tests and dependencies

时间:2016-04-04 18:27:25

标签: gradle jar uberjar

here is what i am trying to accomplish:

Build an uberJar for the EndToEndFunctionalTests tests :

task uberJar(type: Jar,dependsOn:[':compileGroovy']) {
    zip64 true
    from files(sourceSets.main.output.classesDir)
    from configurations.runtime.asFileTree.files.collect {zipTree(it) }
    with jar

}

as a result, i get:

EndToEndFunctionalTests-develop.local.SNAPSHOT.jar

so what i am trying to do is to execute this as:

$ java -jar EndToEndFunctionalTests-develop.local.SNAPSHOT.jar
no main manifest attribute, in EndToEndFunctionalTests-develop.local.SNAPSHOT.jar

is there a way to fake a main() and include it in the MANIFEST, so this jar executes.

I was able to run cucumber tests from the command line via gradle using cucumber runner, but what i want is to be able to run the jar because:

  1. I would be able to run this jar anywhere, since it has all the dependencies
  2. I would cut short the running time for these tests, in staging and qa, as i would have to just make it once, and run it in various environment, in the Continuous Integration Pipeline

1 个答案:

答案 0 :(得分:0)

src/main/groovy/Test.groovy

class Test{
        public static void main(String[] args){
                 println 'dummy main'
}

和结果:

java -jar Serenity-develop.local.SNAPSHOT.jar
dummy main

它是可执行的,但现在我必须弄清楚我是否可以从这个类中调用黄瓜跑步者