Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle zip task ignores files having filename starting with .#

Tags:

gradle

I have a simple gradle zip task, I found out any files starting with .# from input folder are ignored

task zipIt(type: Zip) {
   from 'input/'
   archiveName = 'output.zip'
}

Does someone knows why is so? And how can I override this behavior so I include those files in the zip?

Later edit: Adding the file pattern explicitly doesn't seem to help

On the other hand, looking over @opal links led me to a solution:

import org.apache.tools.ant.DirectoryScanner

task zipIt(type: Zip) {
    doFirst{
        DirectoryScanner.removeDefaultExclude("**/.#*")
   }
   from 'input/'
   archiveName = 'output.zip'
}
like image 932
Adrian Rus Avatar asked Nov 20 '25 11:11

Adrian Rus


2 Answers

Expounding on Opal's answer, Gradle uses ANT's default excludes which are as follows:

As of Ant 1.8.1 they are:

 **/*~
 **/#*#
 **/.#*
 **/%*%
 **/._*
 **/CVS
 **/CVS/**
 **/.cvsignore
 **/SCCS
 **/SCCS/**
 **/vssver.scc
 **/.svn
 **/.svn/**
 **/.DS_Store

Ant 1.8.2 adds the following default excludes:

 **/.git
 **/.git/**
 **/.gitattributes
 **/.gitignore
 **/.gitmodules
 **/.hg
 **/.hg/**
 **/.hgignore
 **/.hgsub
 **/.hgsubstate
 **/.hgtags
 **/.bzr
 **/.bzr/**
 **/.bzrignore

The .# is by default excluded. Updating your build.gradle file with a task similar to the following should allow you to overwrite the default excludes.

task copyPoundFiles(type: Copy) {
  from '/path/to/files'
  into '/dest/for/files'
  include '**/.#*'
}
like image 163
Nathan Avatar answered Nov 24 '25 23:11

Nathan


As far as I remember gradle used the same default excludes as ant does. Have you tried including the file explicitly?

Please have some further reading here and here.

like image 30
Opal Avatar answered Nov 25 '25 00:11

Opal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!