import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.*;
+import com.intellij.openapi.roots.impl.OrderEntryUtil;
import com.intellij.openapi.roots.impl.libraries.LibraryEx;
import com.intellij.openapi.roots.impl.libraries.LibraryTableBase;
import com.intellij.openapi.roots.libraries.Library;
if (myRootModel != null) {
return myRootModel.getModuleLibraryTable().getLibraries();
}
- OrderEntry[] orderEntries = ModuleRootManager.getInstance(myModule).getOrderEntries();
- List<Library> libraries = new ArrayList<Library>();
- for (OrderEntry orderEntry : orderEntries) {
- if (orderEntry instanceof LibraryOrderEntry) {
- final LibraryOrderEntry entry = (LibraryOrderEntry)orderEntry;
- if (entry.isModuleLevel()) {
- libraries.add(entry.getLibrary());
- }
- }
- }
+ List<Library> libraries = OrderEntryUtil.getModuleLibraries(ModuleRootManager.getInstance(myModule));
return libraries.toArray(new Library[libraries.size()]);
}
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.ArrayList;
+import java.util.List;
+
public class OrderEntryUtil {
private OrderEntryUtil() {
}
if (scope1 == DependencyScope.TEST || scope2 == DependencyScope.TEST) return DependencyScope.TEST;
return scope1;
}
+
+ @NotNull
+ public static List<Library> getModuleLibraries(@NotNull ModuleRootModel model) {
+ OrderEntry[] orderEntries = model.getOrderEntries();
+ List<Library> libraries = new ArrayList<Library>();
+ for (OrderEntry orderEntry : orderEntries) {
+ if (orderEntry instanceof LibraryOrderEntry) {
+ final LibraryOrderEntry entry = (LibraryOrderEntry)orderEntry;
+ if (entry.isModuleLevel()) {
+ libraries.add(entry.getLibrary());
+ }
+ }
+ }
+ return libraries;
+ }
}