0

Using the AntBuilder seems to be the best way to create a backup zip file in Groovy. There are lots of solutions on this site that use methods like copy and zip but I can't see those methods the AntBuilder class in Groovy 2.1.5. Do I need to install an additional Jar?

new AntBuilder().zip(
    destfile: "mydir/myzip.zip") {
    fileset(dir: "mydir/myFile.txt")
}
user86834
  • 5,357
  • 10
  • 34
  • 47

1 Answers1

1

The methods in AntBuilder are dynamic and depend on the installed ant tasks.

Did you try zipping a folder with it before asking here?

If you try, you should see it works

Zip specific files with AntBuilder

Zip files/Directories in Groovy with AntBuilder

Community
  • 1
  • 1
tim_yates
  • 167,322
  • 27
  • 342
  • 338
  • I have tried it seeing exceptions, so it looks like a jar is missing: Caught: java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildException java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildException – user86834 Feb 22 '14 at 09:29
  • How are you ruining it and what are you running? – tim_yates Feb 22 '14 at 09:30
  • I'm using the Groovy Eclipse plugin. Right click on groovy file and Run As > Groovy Script. – user86834 Feb 22 '14 at 09:32
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/48128/discussion-between-user86834-and-tim-yates) – user86834 Feb 22 '14 at 09:49