#KT-1333 Fixed
This commit is contained in:
+18
-7
@@ -99,8 +99,14 @@ public class ConfigureKotlinLibraryNotificationProvider implements EditorNotific
|
|||||||
|
|
||||||
private Library findOrCreateRuntimeLibrary(final Module module) {
|
private Library findOrCreateRuntimeLibrary(final Module module) {
|
||||||
LibraryTable table = ProjectLibraryTable.getInstance(myProject);
|
LibraryTable table = ProjectLibraryTable.getInstance(myProject);
|
||||||
final Library kotlinRuntime = table.getLibraryByName("KotlinRuntime");
|
Library kotlinRuntime = table.getLibraryByName("KotlinRuntime");
|
||||||
if (kotlinRuntime != null) return null;
|
if (kotlinRuntime != null) {
|
||||||
|
for (VirtualFile root : kotlinRuntime.getFiles(OrderRootType.CLASSES)) {
|
||||||
|
if (root.getName().equals("kotlin-runtime.jar")) {
|
||||||
|
return kotlinRuntime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
File runtimePath = PathUtil.getDefaultRuntimePath();
|
File runtimePath = PathUtil.getDefaultRuntimePath();
|
||||||
if (runtimePath == null) {
|
if (runtimePath == null) {
|
||||||
@@ -124,17 +130,20 @@ public class ConfigureKotlinLibraryNotificationProvider implements EditorNotific
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Library answer = table.createLibrary("KotlinRuntime");
|
if (kotlinRuntime == null) {
|
||||||
|
kotlinRuntime = table.createLibrary("KotlinRuntime");
|
||||||
|
}
|
||||||
|
|
||||||
|
final Library finalKotlinRuntime = kotlinRuntime;
|
||||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Library.ModifiableModel model = answer.getModifiableModel();
|
Library.ModifiableModel model = finalKotlinRuntime.getModifiableModel();
|
||||||
model.addRoot(VfsUtil.getUrlForLibraryRoot(targetJar), OrderRootType.CLASSES);
|
model.addRoot(VfsUtil.getUrlForLibraryRoot(targetJar), OrderRootType.CLASSES);
|
||||||
model.commit();
|
model.commit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return answer;
|
return kotlinRuntime;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EditorNotificationPanel createNotificationPanel(final Module module) {
|
private EditorNotificationPanel createNotificationPanel(final Module module) {
|
||||||
@@ -151,8 +160,10 @@ public class ConfigureKotlinLibraryNotificationProvider implements EditorNotific
|
|||||||
Library library = findOrCreateRuntimeLibrary(module);
|
Library library = findOrCreateRuntimeLibrary(module);
|
||||||
if (library != null) {
|
if (library != null) {
|
||||||
ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
|
ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
|
||||||
model.addLibraryEntry(library);
|
if (model.findLibraryOrderEntry(library) == null) {
|
||||||
model.commit();
|
model.addLibraryEntry(library);
|
||||||
|
model.commit();
|
||||||
|
}
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|||||||
Reference in New Issue
Block a user