Created
August 25, 2015 15:02
-
-
Save Gazer/defeab06646fefc48033 to your computer and use it in GitHub Desktop.
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
// Creates a copy of the git tree into target directory to be included on the final EAR | |
// Use zipfileset(dir: "${warDest}/src", prefix: 'src') on your ant.ear task. | |
target(generateSourceCode: "Generates a src copy") { | |
depends(defineContextRoot) | |
ProcessBuilder ps=new ProcessBuilder("/usr/bin/git", "ls-tree", "--name-only", "-r", "HEAD"); | |
def dir = "${projectTargetDir}/src" | |
new File(dir).mkdirs(); | |
ps.redirectErrorStream(true); | |
Process pr = ps.start(); | |
def reader = new BufferedReader(new InputStreamReader(pr.getInputStream())); | |
String line; | |
while ((line = reader.readLine()) != null) { | |
File source = new File(line) | |
File destination = new File("${dir}/${line}") | |
destination.parentFile.mkdirs() | |
source?.withInputStream { | |
destination << it | |
} | |
} | |
pr.waitFor(); | |
reader.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment