Created
March 12, 2015 13:01
-
-
Save melix/88f5295cc49a81a272bc to your computer and use it in GitHub Desktop.
Create a zip file that only includes files in Git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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