How to create a jar file from groovy test files and be able to run them

the .groovy files have also dependencies.

  1. make a jar file with all dependencies Test.jar
  2. run it using gradle junit task, or groovy task

now the groovy files do not have a main() which does not make it a candidate for application plugin

i got this one figured out.

apply plugin: 'groovy'

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


i have the jar file in …/build/lib but now how do i run this jar file with gradle ?