static InstallationDescriptor generateMergedInstallationDescriptor(File rootDir,
String aggCompName, File aggDescFile, InstallationDescriptor[] dlgInstDescs,
File[] dlgRootDirs) throws IOException {
// create aggregate installation descriptor
File aggInsdFile = new File(rootDir, PackageBrowser.INSTALLATION_DESCRIPTOR_FILE);
InstallationDescriptor aggInsdObject = new InstallationDescriptor(aggInsdFile);
aggInsdObject.setMainComponent(aggCompName);
// 1st step: set aggregate component descriptor
String aggDescPath = MAIN_ROOT + "/"
+ FileUtil.getRelativePath(rootDir, aggDescFile.getAbsolutePath());
aggInsdObject.setMainComponentDesc(aggDescPath);
// 2nd step: collect installation actions from delegates
for (int i = 0; i < dlgInstDescs.length; i++) {
InstallationDescriptor dlgInsdObject = dlgInstDescs[i];
// add implicit installation actions
File dlgRootDir = dlgRootDirs[i];
String adjMainRoot = MAIN_ROOT + "/" + dlgRootDir.getName();
StringBuffer cpBuffer = new StringBuffer();
// add JAR files in delegate lib dir to CLASSPATH
File dlgLibDir = new File(dlgRootDir, PackageBrowser.LIBRARY_DIR);
if (dlgLibDir.isDirectory()) {
// get list of JAR files
File[] jarFiles = dlgLibDir.listFiles(new FileUtil.ExtFilenameFilter(".jar"));
// build delegate CLASSPATH buffer
cpBuffer.setLength(0);
for (int n = 0; n < jarFiles.length; n++) {
if (cpBuffer.length() > 0)
cpBuffer.append(STANDARD_PATH_SEPARATOR_CHAR);
cpBuffer.append(adjMainRoot + "/"
+ FileUtil.getRelativePath(dlgRootDir, jarFiles[n].getAbsolutePath()));
}
// add 'set_env_variable' action
if (cpBuffer.length() > 0)
aggInsdObject.addInstallationAction(createEnvAction("CLASSPATH", cpBuffer.toString()));
}
// add delegate bin dir to CLASSPATH and PATH
File dlgBinDir = new File(dlgRootDir, PackageBrowser.BINARY_DIR);
if (dlgBinDir.isDirectory()) {
String adjBinDirPath = adjMainRoot + "/"
+ FileUtil.getRelativePath(dlgRootDir, dlgBinDir.getAbsolutePath());
aggInsdObject.addInstallationAction(createEnvAction("CLASSPATH", adjBinDirPath));
aggInsdObject.addInstallationAction(createEnvAction("PATH", adjBinDirPath));
}
// add explicit installation actions
Collection dlgInstActs = dlgInsdObject.getInstallationActions();
Iterator list = dlgInstActs.iterator();
while (list.hasNext())
aggInsdObject.addInstallationAction((InstallationDescriptor.ActionInfo) list.next());
}
// save aggregate installation descriptor file