throws Exception
{
final Map<String,Feature> installedFeatures = new HashMap<String,Feature>();
// run eclipse to get a list of existing installed features
Command command = new InfoCommand(new OutputHandler(){
public void process(String line){
logger.info(line);
if(line.startsWith(FEATURE)){
String[] attrs = StringUtils.split(line.substring(FEATURE.length()));
File site = null;
try{
site = new File(new URL(attrs[2]).getFile());
}catch(Exception e){
logger.error("Failed to parse feature: " + line, e);
}
installedFeatures.put(attrs[0], new Feature(attrs[1], site));
}else if(line.startsWith(CONFIGURATION)){
String config = line.substring(CONFIGURATION.length());
if (config.startsWith("file:")){
config = config.substring(5);
}
if(Os.isFamily(Os.FAMILY_WINDOWS) && config.startsWith("/")){
config = config.substring(1);
}
String local = new File(config).getParent();
logger.info("eclipse.local=" + local);
Installer.getContext().setValue("eclipse.local", local);
}else if(line.startsWith(PROFILE)){
String profile = line.substring(PROFILE.length());
logger.info("eclipse.profile=" + profile);
Installer.getContext().setValue("eclipse.profile", profile);
}
}
});
try{
command.start();
command.join();
if(command.getReturnCode() != 0){
if (command.isShutdown()){
return null;
}
throw new RuntimeException(
"error: " + command.getErrorMessage() +
" out: " + command.getResult());
}
}finally{
command.destroy();
}
return new EclipseInfo(
(String)Installer.getContext().getValue("eclipse.profile"),
(String)Installer.getContext().getValue("eclipse.local"),