0

Is there a way to specify the main-class of the jar in its manifest file as a parameter in Groovy's AntBuilder?

def jAnt = project.createAntBuilder();
jAnt.jar(
            basedir: build_dir + "/classes", //I have only one class with the main method in it
            destfile: build_dir + "/jar/test-jar.jar"
    )

I just want to specify the main class here while creating the jar.

Rishikesh
  • 39
  • 1
  • 6

1 Answers1

0

all documentation about ant tasks: https://ant.apache.org/manual/anttaskslist.html

and for jar task there are a lot of examples including Main-Class specification

you just need to create corresponding groovy-builder code

def ant = new AntBuilder()
def build_dir = "/11/git/myprj/build"
ant.jar( basedir: "${build_dir}/classes", destfile: "${build_dir}/test-jar.jar"){
    manifest{
        attribute(name: "Built-By",   value: "me, myself" )
        attribute(name: "Main-Class", value: "myPackage.MyClass" )
    }
}
daggett
  • 26,404
  • 3
  • 40
  • 56