Skip to content

Instantly share code, notes, and snippets.

@melix
Created March 12, 2015 13:01
Show Gist options
  • Save melix/88f5295cc49a81a272bc to your computer and use it in GitHub Desktop.
Save melix/88f5295cc49a81a272bc to your computer and use it in GitHub Desktop.
Create a zip file that only includes files in Git
task srcZip(type:Zip) {
appendix = 'gitsources'
from project.projectDir
doFirst {
Set excludeList = [relativePath(archivePath).toString()]
def p = "git status --ignored --porcelain .".execute([], project.projectDir)
def writer = new StringWriter()
p.consumeProcessOutput(writer, null)
p.waitFor()
writer.toString().eachLine { l ->
def (status,path) = l.split(' ')
excludeList << path
}
exclude {
String path = it.directory?"${it.path}${File.separator}":it.path
excludeList.contains(path)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment