Thomas Lee
Thomas Lee

Reputation: 1027

Gradle Fail to zip the .gitignore and .gitattributes

I am trying to zip the the .gitattributes and .gitignore but no matter how I try they are still not existing in the zip.

task packageZip(type:Zip) {  
    from('.') {  
      include '**/**'  
      include '**/.gitattributes'  
      exclude 'build'  
   }  
}

I know those 2 files are excluding by default but I have no idea how to set defaultExclude into false. But it fails.

I don't want to change the gradle setting of the default exclude since it may affect other tasks. Can you give me a sample?

task packageZip(type:Zip) {  
       from "./"  
       defaultExclude = "false"  
}

Upvotes: 1

Views: 294

Answers (1)

Wojtek Erbetowski
Wojtek Erbetowski

Reputation: 3275

That wasn't easy to find, but finally I have a solution for you.

You may use defaultexcludes only in Ant directly (Zip task, or AbstractCopyTask whis it extends doesn't seem to implement that. If it does - please correct me). But Ant does. Therefore go with:

ant.zip(destfile: 'archive.zip') {
  fileset(dir: 'dir', defaultexcludes:"no")
}

To put that into a task just go with

task packageZip << {
  // ant.zip ....
}

I hope that helps.

Upvotes: 3

Related Questions