kamal
kamal

Reputation: 9785

Create uberJar from cucumber/groovy tests including dependencies using gradle

i have some functional tests in {project_home}/src/test/groovy/

i want to be able to use a gradle task to:

  1. Make a jar file from all the .groovy files under {project_home}/src/test/groovy/ including all of the dependencies

  2. be able to run this jar file as a substitute of running individual groovy files

All the example i came across have a main method , the one i have have no main()

so i tried to use the "Project's" build.gradle and appended

task fatJar(type: Jar) {
    baseName = project.name + '-all'
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
}

and ran $gradle clean fatJar

but got compile failure:

:Tests:EndToEndFunctionalTests:fatJar FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':Tests:EndToEndFunctionalTests:fatJar'.
> archive contains more than 65535 entries.

  To build this archive, please enable the zip64 extension.
  See: https://docs.gradle.org/2.7/dsl/org.gradle.api.tasks.bundling.Zip.html#org.gradle.api.tasks.bundling.Zip:zip64

i do have the jar file under /build/libs

Upvotes: 4

Views: 2507

Answers (1)

kamal
kamal

Reputation: 9785

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

}

Solved the issue.

Upvotes: 6

Related Questions