void (ModifiableRootModel model, LibraryOrderEntry addedEntry) { final OrderEntry[] order = model.getOrderEntries(); //place library after module sources assert order[order.length - 1] == addedEntry; int insertionPoint = -1; for (int i = 0; i < order.length - 1; i++) { if (order[i] instanceof ModuleSourceOrderEntry) { insertionPoint = i + 1; break; } } if (insertionPoint >= 0) { System.arraycopy(order, insertionPoint, order, insertionPoint + 1, order.length - 1 - insertionPoint); order[insertionPoint] = addedEntry; model.rearrangeOrderEntries(order); } }