[email protected]

Gradle Small Hints #1 - Zipping up a file tree

Don’t know but took me some time to figure out how to ZIP up a project directory required for my AWS Elastic Beanstalk Deployment.

The task will collect all relevant files for my project directory (which contains the docker configuration) and writes it into the build directly.


task myZip(type: Zip) {
   from ('.')
   include '**/*.groovy'
   include '**/*.config'
   include '*'
   exclude '.gradle'
   exclude '.settings'
   exclude 'bin'
   exclude 'build'
   exclude 'logs'
   exclude 'src/test'
   exclude '.classpath'
   exclude '.project'
   into '.'
   destinationDir(file("build")) 
  } 


Or also possible


task dockerZip(type: Zip) { 
    from fileTree(dir: '.', 
    includes: ['**/*.groovy', '**/*.config','*'], 
    excludes: ['.gradle','.settings','bin','build','logs','src/test','.classpath','.project']) 
    into '.'
   destinationDir(file("build")) 
  } 



comments powered by Disqus