int hyphen;
String orbName, srcDir, destDir;
Expand unjar = new Expand();
Delete delete = new Delete();
Mkdir mkdir = new Mkdir();
Jar jar = new Jar();
try {
/* Remove any existing work directory */
delete.setProject(getProject());
delete.setDir(new File(workdir));
delete.execute();
/* Get list of files */
final int numLibs = libs.size() ;
for(int count = 0 ; count < numLibs ; count++)
{
final FileSet fileSet = (FileSet)libs.get(count) ;
ds = fileSet.getDirectoryScanner(project);
ds.scan();
final String[] files = ds.getIncludedFiles() ;
for (int i = 0; i < files.length;i++) {
/* Build extract directory name */
destDir = workdir.concat("/classes");
hyphen = files[i].lastIndexOf('-');
orbName = new String();
if (!ignoreOrb && (hyphen > 0)) {
orbName = orbName.concat(
files[i].substring(hyphen,
files[i].indexOf(".jar")));
destDir = destDir.concat(orbName);
if (!orbList.contains(orbName)) {
orbList.add(orbName);
}
} else {
if (!orbList.contains("")) {
orbList.add("");
}
}
/* Unpack jar file */
unjar.setProject(getProject());
unjar.setDest(new File(destDir));
unjar.setSrc(new File(ds.getBasedir(), files[i]));
unjar.setOverwrite(true);
unjar.execute();
}
}
for (Iterator i = orbList.iterator(); i.hasNext();) {
/* Delete META-INF directory */
orbName = i.next().toString();
srcDir = workdir.concat("/classes");
srcDir = srcDir.concat(orbName);
srcDir = srcDir.concat("/META-INF");
delete.setDir(new File(srcDir));
delete.execute();
/* Create destination directory */
mkdir.setProject(getProject());
mkdir.setDir(new File(destdir));
mkdir.execute();
/* Create new jar files */
srcDir = workdir.concat("/classes");
srcDir = srcDir.concat(orbName);
destDir = destdir.concat("/");
destDir = destDir.concat(destfile);
destDir = destDir.concat(orbName);
destDir = destDir.concat(".jar");
jar.setProject(getProject());
jar.setBasedir(new File(srcDir));
jar.setJarfile(new File(destDir));
jar.execute();
}
/* Remove the work directory */
delete.setDir(new File(workdir));
delete.execute();
}