File sourcesFile = new File(getDestFile().getParentFile(), name);
if (sourcesFile.exists()) {
sourcesFile.delete();
}
Jar jar = new Jar();
jar.setTaskName(getTaskName());
jar.setProject(getProject());
// set the destination file
jar.setDestFile(sourcesFile);
List<File> folders = build.getConfig().getSourceDirectories(Scope.compile, tag);
for (File folder : folders) {
FileSet srcSet = new FileSet();
srcSet.setProject(getProject());
srcSet.setDir(folder);
srcSet.setIncludes("**/*.java");
jar.addFileset(srcSet);
// include source folder resources
FileSet resSet = new FileSet();
resSet.setProject(getProject());
resSet.setDir(folder);
resSet.setExcludes(excludes);
jar.addFileset(resSet);
}
if (includeResources) {
for (File dir : build.getConfig().getResourceDirectories(Scope.compile, tag)) {
FileSet set = new FileSet();
set.setDir(dir);
set.setExcludes(Toolkit.DEFAULT_RESOURCE_EXCLUDES);
jar.addFileset(set);
}
}
// set the source jar manifest
try {
Manifest mft = new Manifest();
configureManifest(mft);
jar.addConfiguredManifest(mft);
} catch (ManifestException e) {
console.error(e);
}
start = System.currentTimeMillis();
jar.execute();
console.log(1, "{0} KB, generated in {1} ms", (sourcesFile.length()/1024), System.currentTimeMillis() - start);
}
}