File userWebXML = getWebXML(userWebFilesDir);
IClasspathEntry[] jarEntries = getJarEntries();
File userClassFilesDir = getAbsoluteOutputLocation(this.javaProject);
outputWar.delete();
War warTask = new War();
progressMonitor.worked(1);
Project antProject = new Project();
antProject.init();
warTask.setProject(antProject);
warTask.setDestFile(outputWar);
ZipFileSet classes = new ZipFileSet();
classes.setDir(userClassFilesDir);
warTask.addClasses(classes);
classes = new ZipFileSet();
classes.setDir(userClassFilesDir);
classes.setIncludes("log4j.properties");
warTask.addClasses(classes);
if (userWebFilesDir != null && userWebFilesDir.exists())
{
FileSet webFiles = new FileSet();
webFiles.setDir(userWebFilesDir);
webFiles.setExcludes(WEBINF);
warTask.addFileset(webFiles);
}
if (userWebXML != null && userWebXML.exists())
{
warTask.setWebxml(userWebXML);
}
else
{
// Without a webxml attribute the Ant war task
// requires the update attribute set to true
// That's why we actually need an existing war file.
try
{
// A file is needed for war creation
File voidFile = File.createTempFile("void", null);
createZipFile(outputWar, voidFile);
voidFile.delete();
}
catch (IOException e)
{
throw new CoreException(
new Status(
IStatus.ERROR,
WebappPlugin.getPluginId(),
IStatus.OK,
WebappMessages.getString(
"WarBuilder.message.createwar.temp"),
e));
}
warTask.setUpdate(true);
}
ZipFileSet[] jarFS = getZipFileSets(jarEntries);
for (int i = 0; i < jarFS.length; i++)
{
warTask.addLib(jarFS[i]);
}
warTask.execute();
progressMonitor.worked(2);
return outputWar;
}