Library(path/url) doesn't get added to External Libraries Follow
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
LibraryTable.ModifiableModel modifiableModel = rootModel.getModuleLibraryTable().getModifiableModel();
String libraryPath = VirtualFileManager.constructUrl(LocalFileSystem.PROTOCOL, src);
VirtualFile url = VirtualFileManager.getInstance().findFileByUrl(libraryPath);
if (url != null) {
Library iceLibrary = modifiableModel.createLibrary("NME");
Library.ModifiableModel libModel = iceLibrary.getModifiableModel();
libModel.addRoot(libraryPath, OrderRootType.CLASSES);
libModel.addRoot(libraryPath, OrderRootType.SOURCES);
libModel.addJarDirectory(libraryPath, true);
libModel.commit();
modifiableModel.commit();
///* 115 */ rootModel.addLibraryEntry(iceLibrary);
rootModel.commit();
}
}
})
Please sign in to leave a comment.
This does runs on ProjectOptions.apply (but doesn't adds anything)
Triggers on apply button click - no error, nothing changed.
Doesn't works too.
Doesn't works too.