Cool Groovy features 5 – integration with Ant

The Ant build tool provides a number of really useful features, but when coding in Java it isn’t particularly easy to invoke Ant from your code. Groovy includes Ant and an AntBuilder class that allows you to access it, which makes it very easy to perform tasks like moving and copying files, ftp, sftp, zip and unzip:

AntBuilder antBuilder = new AntBuilder()
antBuilder.scp( file: "mysqlbackup@9.20.1.138:/backup/db_backup.sql.gz",
		  todir: "c:\db_backups",
		  verbose: true,
		  password: "password",
		  trust: true,
		  sftp: true)
antBuilder.gunzip( src: "c:\db_backups\db_backup.sql.gz" )

This entry was posted in Groovy and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

503,487 Spambots Blocked by Simple Comments

HTML tags are not allowed.