{
File updateDir = Installer.tempDir("update");
Extractor.extractResource("/files/installer-update-site.zip", updateDir);
String url = "file://" + updateDir;
Command command = new InstallCommand(
null, url, "org.eclim.installer", "org.eclipse.equinox.p2.director");
try{
command.start();
command.join();
if(command.getReturnCode() != 0){
if (command.isShutdown()){
return false;
}
RuntimeException re = new RuntimeException(
"error: " + command.getErrorMessage() +
" out: " + command.getResult());
logger.warn(
"Error installing eclim installer feature, " +
"attempting uninstall/reinstall.");
// attempt to uninstall the feature
Command uninstall = new UninstallCommand(
null, url, "org.eclim.installer", "org.eclipse.equinox.p2.director");
uninstall.start();
uninstall.join();
// now try to install again
command = new InstallCommand(
null, url, "org.eclim.installer", "org.eclipse.equinox.p2.director");
command.start();
command.join();
if(command.getReturnCode() != 0){
if (command.isShutdown()){
return false;
}
throw re;
}
}
Installer.getProject().setProperty("eclim.installer.feature.installed", "true");
Installer.getProject().setProperty("eclim.installer.feature.location", url);
}finally{
command.destroy();
}
return true;
}