if(!J2EEProjectUtilities.isJEEProject(project)){
return;
}
//if the ear project Java EE level was < 5.0, the following would throw a ClassCastException
final IEARModelProvider earModel = (IEARModelProvider)ModelProviderManager.getModelProvider(project);
if (earModel == null) {
return;
}
final Application app = (Application)earModel.getModelObject();
if (app != null) {
if (newLibDir == null || "/".equals(newLibDir)) { //$NON-NLS-1$
newLibDir = "lib"; //$NON-NLS-1$
}
//MECLIPSEWTP-167 : lib directory mustn't start with a slash
else if (newLibDir.startsWith("/")) { //$NON-NLS-1$
newLibDir = newLibDir.substring(1);
}
String oldLibDir = app.getLibraryDirectory();
if (newLibDir.equals(oldLibDir)) return;
final String libDir = newLibDir;
earModel.modify(new Runnable() {
@Override
public void run() {
app.setLibraryDirectory(libDir);
}}, null);
}