com.intellij.openapi.roots.libraries.LibraryTablesRegistrar Java Examples

The following examples show how to use com.intellij.openapi.roots.libraries.LibraryTablesRegistrar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChooseLibrariesDialogBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void collectChildren(Object element, final List<Object> result) {
  if (element instanceof Application) {
    Collections.addAll(result, ProjectManager.getInstance().getOpenProjects());
    final LibraryTablesRegistrar instance = LibraryTablesRegistrar.getInstance();
    result.add(instance.getLibraryTable()); //1
    result.addAll(instance.getCustomLibraryTables()); //2
  }
  else if (element instanceof Project) {
    Collections.addAll(result, ModuleManager.getInstance((Project)element).getModules());
    result.add(LibraryTablesRegistrar.getInstance().getLibraryTable((Project)element));
  }
  else if (element instanceof LibraryTable) {
    Collections.addAll(result, ((LibraryTable)element).getLibraries());
  }
  else if (element instanceof Module) {
    for (OrderEntry entry : ModuleRootManager.getInstance((Module)element).getOrderEntries()) {
      if (entry instanceof LibraryOrderEntry) {
        final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry)entry;
        if (LibraryTableImplUtil.MODULE_LEVEL.equals(libraryOrderEntry.getLibraryLevel())) {
          final Library library = libraryOrderEntry.getLibrary();
          result.add(library);
        }
      }
    }
  }
}
 
Example #2
Source File: CamelProjectComponentTestIT.java    From camel-idea-plugin with Apache License 2.0 6 votes vote down vote up
public void testAddLegacyPackaging() throws IOException {
    CamelService service = ServiceManager.getService(myProject, CamelService.class);
    assertEquals(0, service.getLibraries().size());

    VirtualFile camelCoreVirtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(createTestArchive("camel-core-2.22.0.jar"));
    VirtualFile legacyJarPackagingFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(createTestArchive("legacy-custom-file-0.12.snapshot.jar"));

    final LibraryTable projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myProject);

    addLibraryToModule(camelCoreVirtualFile, projectLibraryTable, "Maven: org.apache.camel:camel-core:2.22.0-snapshot");
    addLibraryToModule(legacyJarPackagingFile, projectLibraryTable, "c:\\test\\libs\\legacy-custom-file-0.12.snapshot.jar");

    UIUtil.dispatchAllInvocationEvents();
    assertEquals(1, service.getLibraries().size());
    assertEquals(true, service.getLibraries().contains("camel-core"));
}
 
Example #3
Source File: CamelProjectComponentTestIT.java    From camel-idea-plugin with Apache License 2.0 6 votes vote down vote up
public void testAddModule() throws IOException {
    CamelService service = ServiceManager.getService(myProject, CamelService.class);
    assertEquals(0, service.getLibraries().size());

    File camelJar = createTestArchive("camel-core-2.22.0.jar");
    VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(camelJar);

    final LibraryTable projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myProject);
    ApplicationManager.getApplication().runWriteAction(() -> {
        final Module moduleA = createModule("myNewModel.iml");
        Library library = projectLibraryTable.createLibrary("Maven: org.apache.camel:camel-core:2.22.0-snapshot");
        final Library.ModifiableModel libraryModifiableModel = library.getModifiableModel();
        libraryModifiableModel.addRoot(virtualFile, OrderRootType.CLASSES);
        libraryModifiableModel.commit();
        ModuleRootModificationUtil.addDependency(moduleA, library);
    });

    UIUtil.dispatchAllInvocationEvents();
    assertEquals(1, service.getLibraries().size());
}
 
Example #4
Source File: CamelProjectComponentTestIT.java    From camel-idea-plugin with Apache License 2.0 6 votes vote down vote up
public void testRemoveLibrary() throws IOException {
    CamelService service = ServiceManager.getService(myProject, CamelService.class);
    assertEquals(0, service.getLibraries().size());

    VirtualFile camelCoreVirtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(createTestArchive("camel-core-2.22.0.jar"));
    VirtualFile camelSpringVirtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(createTestArchive("camel-spring-2.22.0.jar"));

    final LibraryTable projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myProject);

    Library springLibrary = addLibraryToModule(camelSpringVirtualFile, projectLibraryTable, "Maven: org.apache.camel:camel-spring:2.22.0-snapshot");
    Library coreLibrary = addLibraryToModule(camelCoreVirtualFile, projectLibraryTable, "Maven: org.apache.camel:camel-core:2.22.0-snapshot");

    UIUtil.dispatchAllInvocationEvents();
    assertEquals(2, service.getLibraries().size());
    assertEquals(true, service.isCamelPresent());

    ApplicationManager.getApplication().runWriteAction(() -> projectLibraryTable.removeLibrary(springLibrary));

    UIUtil.dispatchAllInvocationEvents();
    assertEquals(1, service.getLibraries().size());
}
 
Example #5
Source File: LibrariesContainerFactory.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
@Nonnull
public Library[] getLibraries(@Nonnull final LibraryLevel libraryLevel) {
  if (libraryLevel == LibraryLevel.MODULE && myModule != null) {
    return getModuleLibraries();
  }

  LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
  if (libraryLevel == LibraryLevel.GLOBAL) {
    return registrar.getLibraryTable().getLibraries();
  }

  if (libraryLevel == LibraryLevel.PROJECT && myProject != null) {
    return registrar.getLibraryTable(myProject).getLibraries();
  }

  return EMPTY_LIBRARIES_ARRAY;
}
 
Example #6
Source File: LibrariesContainerFactory.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public Library createLibrary(@Nonnull NewLibraryEditor libraryEditor,
                             @Nonnull LibraryLevel level) {
  if (level == LibraryLevel.MODULE && myRootModel != null) {
    return createLibraryInTable(libraryEditor, myRootModel.getModuleLibraryTable());
  }

  LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
  LibraryTable table;
  if (level == LibraryLevel.GLOBAL) {
    table = registrar.getLibraryTable();
  }
  else if (level == LibraryLevel.PROJECT && myProject != null) {
    table = registrar.getLibraryTable(myProject);
  }
  else {
    return null;
  }
  return createLibraryInTable(libraryEditor, table);
}
 
Example #7
Source File: AbstractLibraryManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected static void removeFlutterLibraryDependency(@NotNull Module module, @NotNull Library library) {
  final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();

  try {
    boolean wasFound = false;

    for (final OrderEntry orderEntry : modifiableModel.getOrderEntries()) {
      if (orderEntry instanceof LibraryOrderEntry &&
          LibraryTablesRegistrar.PROJECT_LEVEL.equals(((LibraryOrderEntry)orderEntry).getLibraryLevel()) &&
          StringUtil.equals(library.getName(), ((LibraryOrderEntry)orderEntry).getLibraryName())) {
        wasFound = true;
        modifiableModel.removeOrderEntry(orderEntry);
      }
    }

    if (wasFound) {
      ApplicationManager.getApplication().invokeAndWait(() -> WriteAction.run(modifiableModel::commit));
    }
  }
  finally {
    if (!modifiableModel.isDisposed()) {
      modifiableModel.dispose();
    }
  }
}
 
Example #8
Source File: AbstractLibraryManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected static void addFlutterLibraryDependency(@NotNull Module module, @NotNull Library library) {
  final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();

  try {
    for (final OrderEntry orderEntry : modifiableModel.getOrderEntries()) {
      if (orderEntry instanceof LibraryOrderEntry &&
          LibraryTablesRegistrar.PROJECT_LEVEL.equals(((LibraryOrderEntry)orderEntry).getLibraryLevel()) &&
          StringUtil.equals(library.getName(), ((LibraryOrderEntry)orderEntry).getLibraryName())) {
        return; // dependency already exists
      }
    }

    modifiableModel.addLibraryEntry(library);

    ApplicationManager.getApplication().invokeAndWait(() -> WriteAction.run(modifiableModel::commit));
  }
  finally {
    if (!modifiableModel.isDisposed()) {
      modifiableModel.dispose();
    }
  }
}
 
Example #9
Source File: AbstractLibraryManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void updateLibraryContent(@NotNull Set<String> contentUrls) {
  if (!FlutterModuleUtils.declaresFlutter(project)) {
    // If we have a Flutter library, remove it.
    final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(project);
    final Library existingLibrary = getLibraryByName(getLibraryName());
    if (existingLibrary != null) {
      WriteAction.compute(() -> {
        final LibraryTable.ModifiableModel libraryTableModel = libraryTable.getModifiableModel();
        libraryTableModel.removeLibrary(existingLibrary);
        libraryTableModel.commit();
        return null;
      });
    }
    return;
  }
  updateLibraryContent(getLibraryName(), contentUrls, null);
}
 
Example #10
Source File: AbstractLibraryManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected static void removeFlutterLibraryDependency(@NotNull Module module, @NotNull Library library) {
  final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();

  try {
    boolean wasFound = false;

    for (final OrderEntry orderEntry : modifiableModel.getOrderEntries()) {
      if (orderEntry instanceof LibraryOrderEntry &&
          LibraryTablesRegistrar.PROJECT_LEVEL.equals(((LibraryOrderEntry)orderEntry).getLibraryLevel()) &&
          StringUtil.equals(library.getName(), ((LibraryOrderEntry)orderEntry).getLibraryName())) {
        wasFound = true;
        modifiableModel.removeOrderEntry(orderEntry);
      }
    }

    if (wasFound) {
      ApplicationManager.getApplication().invokeAndWait(() -> WriteAction.run(modifiableModel::commit));
    }
  }
  finally {
    if (!modifiableModel.isDisposed()) {
      modifiableModel.dispose();
    }
  }
}
 
Example #11
Source File: AbstractLibraryManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected static void addFlutterLibraryDependency(@NotNull Module module, @NotNull Library library) {
  final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();

  try {
    for (final OrderEntry orderEntry : modifiableModel.getOrderEntries()) {
      if (orderEntry instanceof LibraryOrderEntry &&
          LibraryTablesRegistrar.PROJECT_LEVEL.equals(((LibraryOrderEntry)orderEntry).getLibraryLevel()) &&
          StringUtil.equals(library.getName(), ((LibraryOrderEntry)orderEntry).getLibraryName())) {
        return; // dependency already exists
      }
    }

    modifiableModel.addLibraryEntry(library);

    ApplicationManager.getApplication().invokeAndWait(() -> WriteAction.run(modifiableModel::commit));
  }
  finally {
    if (!modifiableModel.isDisposed()) {
      modifiableModel.dispose();
    }
  }
}
 
Example #12
Source File: AbstractLibraryManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void updateLibraryContent(@NotNull Set<String> contentUrls) {
  if (!FlutterModuleUtils.declaresFlutter(project)) {
    // If we have a Flutter library, remove it.
    final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(project);
    final Library existingLibrary = getLibraryByName(getLibraryName());
    if (existingLibrary != null) {
      WriteAction.compute(() -> {
        final LibraryTable.ModifiableModel libraryTableModel = libraryTable.getModifiableModel();
        libraryTableModel.removeLibrary(existingLibrary);
        libraryTableModel.commit();
        return null;
      });
    }
    return;
  }
  updateLibraryContent(getLibraryName(), contentUrls, null);
}
 
Example #13
Source File: IdeaModifiableModelsProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public LibraryTable.ModifiableModel getLibraryTableModifiableModel() {
  final Project[] projects = ProjectManager.getInstance().getOpenProjects();
  for (Project project : projects) {
    if (!project.isInitialized()) {
      continue;
    }
    StructureConfigurableContext context = getProjectStructureContext(project);
    LibraryTableModifiableModelProvider provider = context != null ? context.createModifiableModelProvider(LibraryTablesRegistrar.APPLICATION_LEVEL) : null;
    final LibraryTable.ModifiableModel modifiableModel = provider != null ? provider.getModifiableModel() : null;
    if (modifiableModel != null) {
      return modifiableModel;
    }
  }
  return LibraryTablesRegistrar.getInstance().getLibraryTable().getModifiableModel();
}
 
Example #14
Source File: StructureConfigurableContext.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void resetLibraries() {
  final LibraryTablesRegistrar tablesRegistrar = LibraryTablesRegistrar.getInstance();

  myLevel2Providers.clear();
  myLevel2Providers.put(LibraryTablesRegistrar.APPLICATION_LEVEL, new LibrariesModifiableModel(tablesRegistrar.getLibraryTable(), myProject, this));
  myLevel2Providers.put(LibraryTablesRegistrar.PROJECT_LEVEL, new LibrariesModifiableModel(tablesRegistrar.getLibraryTable(myProject), myProject, this));
  for (final LibraryTable table : tablesRegistrar.getCustomLibraryTables()) {
    myLevel2Providers.put(table.getTableLevel(), new LibrariesModifiableModel(table, myProject, this));
  }
}
 
Example #15
Source File: BaseLibrariesConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static BaseLibrariesConfigurable getInstance(@Nonnull Project project, @Nonnull String tableLevel) {
  if (tableLevel.equals(LibraryTablesRegistrar.PROJECT_LEVEL)) {
    return ProjectLibrariesConfigurable.getInstance(project);
  }
  else {
    return null;
  }
}
 
Example #16
Source File: LibraryProjectStructureElement.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void reportInvalidRoots(ProjectStructureProblemsHolder problemsHolder, LibraryEx library,
                                final OrderRootType type, String rootName, final ProjectStructureProblemType problemType) {
  final List<String> invalidUrls = library.getInvalidRootUrls(type);
  if (!invalidUrls.isEmpty()) {
    final String description = createInvalidRootsDescription(invalidUrls, rootName, library.getName());
    final PlaceInProjectStructure place = createPlace();
    final String message = ProjectBundle.message("project.roots.error.message.invalid.roots", rootName, invalidUrls.size());
    ProjectStructureProblemDescription.ProblemLevel level = library.getTable().getTableLevel().equals(LibraryTablesRegistrar.PROJECT_LEVEL)
                                                            ? ProjectStructureProblemDescription.ProblemLevel.PROJECT : ProjectStructureProblemDescription.ProblemLevel.GLOBAL;
    problemsHolder.registerProblem(new ProjectStructureProblemDescription(message, description, place,
                                                                          problemType, level,
                                                                          Collections.singletonList(new RemoveInvalidRootsQuickFix(library, type, invalidUrls)),
                                                                          true));
  }
}
 
Example #17
Source File: ProjectStructureConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
public BaseLibrariesConfigurable getConfigurableFor(final Library library) {
  if (LibraryTablesRegistrar.PROJECT_LEVEL.equals(library.getTable().getTableLevel())) {
    return myProjectLibrariesConfig;
  } else {
    return null;
  }
}
 
Example #18
Source File: IdeaModifiableModelsProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public LibraryTable.ModifiableModel getLibraryTableModifiableModel(Project project) {
  StructureConfigurableContext context = getProjectStructureContext(project);
  if (context != null) {
    LibraryTableModifiableModelProvider provider = context.createModifiableModelProvider(LibraryTablesRegistrar.PROJECT_LEVEL);
    return provider.getModifiableModel();
  }
  return LibraryTablesRegistrar.getInstance().getLibraryTable(project).getModifiableModel();
}
 
Example #19
Source File: ChooseLibrariesFromTablesDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static List<LibraryTable> getLibraryTables(final Project project, final boolean showCustomLibraryTables) {
  final List<LibraryTable> tables = new ArrayList<LibraryTable>();
  final LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
  if (project != null) {
    tables.add(registrar.getLibraryTable(project));
  }
  tables.add(registrar.getLibraryTable());
  if (showCustomLibraryTables) {
    for (LibraryTable table : registrar.getCustomLibraryTables()) {
      tables.add(table);
    }
  }
  return tables;
}
 
Example #20
Source File: MavenImportingTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
public void assertProjectLibraries(String... expectedNames) {
  List<String> actualNames = new ArrayList<>();
  for (Library each : LibraryTablesRegistrar.getInstance().getLibraryTable(myProject).getLibraries()) {
    String name = each.getName();
    actualNames.add(name == null ? "<unnamed>" : name);
  }
  assertUnorderedElementsAreEqual(actualNames, expectedNames);
}
 
Example #21
Source File: PackagingElementsTestCase.java    From consulo with Apache License 2.0 5 votes vote down vote up
static Library addProjectLibrary(final Project project, final @javax.annotation.Nullable Module module, final String name, final DependencyScope scope, final VirtualFile[] jars) {
  return WriteAction.compute(() -> {
    final Library library = LibraryTablesRegistrar.getInstance().getLibraryTable(project).createLibrary(name);
    final Library.ModifiableModel libraryModel = library.getModifiableModel();
    for (VirtualFile jar : jars) {
      libraryModel.addRoot(jar, BinariesOrderRootType.getInstance());
    }
    libraryModel.commit();
    if (module != null) {
      ModuleRootModificationUtil.addDependency(module, library, scope, false);
    }
    return library;
  });
}
 
Example #22
Source File: LibraryOrderEntryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void addListeners() {
  final String libraryLevel = getLibraryLevel();
  final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTableByLevel(libraryLevel, getRootModel().getProject());
  if (libraryTable != null) {
    myProjectRootManagerImpl.addListenerForTable(myLibraryListener, libraryTable);
  }
}
 
Example #23
Source File: LibraryOrderEntryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void dispose() {
  super.dispose();
  final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTableByLevel(getLibraryLevel(), getRootModel().getProject());
  if (libraryTable != null) {
    myProjectRootManagerImpl.removeListenerForTable(myLibraryListener, libraryTable);
  }
}
 
Example #24
Source File: LibraryOrderEntryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void searchForLibrary(@Nonnull String name, @Nonnull String level) {
  if (myLibrary != null) return;
  final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTableByLevel(level, getRootModel().getModule().getProject());
  final Library library = libraryTable != null ? libraryTable.getLibraryByName(name) : null;
  if (library == null) {
    myLibraryName = name;
    myLibraryLevel = level;
    myLibrary = null;
  }
  else {
    myLibraryName = null;
    myLibraryLevel = null;
    myLibrary = library;
  }
}
 
Example #25
Source File: LibraryOrderEntryType.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public LibraryOrderEntryImpl loadOrderEntry(@Nonnull Element element, @Nonnull ModuleRootLayer moduleRootLayer) throws InvalidDataException {
  String name = element.getAttributeValue(NAME_ATTR);
  if (name == null) {
    throw new InvalidDataException();
  }

  String level = element.getAttributeValue(LEVEL_ATTR, LibraryTablesRegistrar.PROJECT_LEVEL);
  DependencyScope dependencyScope = DependencyScope.readExternal(element);
  boolean exported = element.getAttributeValue(EXPORTED_ATTR) != null;
  return new LibraryOrderEntryImpl(name, level, (ModuleRootLayerImpl)moduleRootLayer, dependencyScope, exported, false);
}
 
Example #26
Source File: PantsCodeInsightFixtureTestCase.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void tearDown() throws Exception {
  final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myFixture.getProject());
  final Library libraryByName = libraryTable.getLibraryByName(PantsConstants.PANTS_LIBRARY_NAME);
  if (libraryByName != null) {
    ApplicationManager.getApplication().runWriteAction(() -> libraryTable.removeLibrary(libraryByName));
  }
  super.tearDown();
}
 
Example #27
Source File: FlutterSdk.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
private static Library getDartSdkLibrary(@NotNull Project project) {
  final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(project);
  for (Library lib : libraryTable.getLibraries()) {
    if ("Dart SDK".equals(lib.getName())) {
      return lib;
    }
  }
  return null;
}
 
Example #28
Source File: FlutterSdk.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
private static Library getDartSdkLibrary(@NotNull Project project) {
  final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(project);
  for (Library lib : libraryTable.getLibraries()) {
    if ("Dart SDK".equals(lib.getName())) {
      return lib;
    }
  }
  return null;
}
 
Example #29
Source File: ProtostuffPluginController.java    From protobuf-jetbrains-plugin with Apache License 2.0 5 votes vote down vote up
@Nullable
private Library findGlobalProtobufLibrary(Project project, VirtualFile libraryBundle) {
    LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(project);
    Library library = libraryTable.getLibraryByName(LIB_NAME);
    if (library != null) {
        // check library - update if needed
        if (Arrays.stream(library.getFiles(ORDER_ROOT_TYPE))
                .anyMatch(file -> file.getName().equals(libraryBundle.getName()))) {
            return library;
        }
    }
    return null;
}
 
Example #30
Source File: CamelProjectComponentTestIT.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
public void testAddLibrary() throws IOException {
    CamelService service = ServiceManager.getService(myProject, CamelService.class);
    assertEquals(0, service.getLibraries().size());

    File camelJar = createTestArchive("camel-core-2.22.0.jar");
    VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(camelJar);

    final LibraryTable projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myProject);
    addLibraryToModule(virtualFile, projectLibraryTable, "Maven: org.apache.camel:camel-core:2.22.0-snapshot");

    UIUtil.dispatchAllInvocationEvents();
    assertEquals(1, service.getLibraries().size());
    assertEquals(true, service.isCamelPresent());
}