final Library library = modifiableModel.getModuleLibraryTable().createLibrary("Dart custom package roots");
final Library.ModifiableModel libModel = library.getModifiableModel();
libModel.addRoot(customPack1.getUrl(), OrderRootType.CLASSES);
libModel.addRoot(customPack2.getUrl(), OrderRootType.CLASSES);
libModel.commit();
modifiableModel.commit();
}
catch (Exception e) {
if (!modifiableModel.isDisposed()) modifiableModel.dispose();
}
}