* @see org.apache.tools.ant.Task#execute()
*/
@Override
public void execute() {
try {
final Util util = new Util(new AntLogger(), this.debug);
final File temp = File.createTempFile("smaller-ant", ".dir");
try {
temp.delete();
temp.mkdirs();
log("Reading config-file: " + this.configFilePath);
if (!this.configFilePath.exists()) {
throw new RuntimeException(this.configFilePath.toString());
}
final ConfigFile configFile = ConfigFile.read(this.configFilePath);
final List<String> includedFiles = new ArrayList<String>();
for (final String envName : configFile.getBuildServer()
.getEnvironments()) {
final Environment env = configFile.getEnvironments().get(envName);
for (final String dir : env.getFiles().getFolder()) {
copyFirstInputFile(env, dir, temp);
final String base = new File(this.configFilePath.getParentFile(),
dir).getAbsolutePath();
final String[] included = scanIncludedFiles(base, env.getFiles()
.getIncludes(), env.getFiles().getExcludes());
for (final String include : included) {
FileUtils.copyFile(new File(base, include), new File(temp,
include));
includedFiles.add(include);
}
}
}
util.unzip(this.target, util.send(this.host, this.port, this.proxyhost,
this.proxyport, util.zip(temp, includedFiles, configFile)));
} finally {
FileUtils.deleteDirectory(temp);
}
} catch (final IOException e) {
log(Util.formatException(e), Project.MSG_ERR);