com.intellij.openapi.roots.DependencyScope Java Examples

The following examples show how to use com.intellij.openapi.roots.DependencyScope. 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: AndroidModuleLibraryManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void updateAndroidModuleLibraryDependencies(Module flutterModule) {
  for (final Module module : ModuleManager.getInstance(getProject()).getModules()) {
    if (module != flutterModule) {
      if (null != FacetManager.getInstance(module).findFacet(AndroidFacet.ID, "Android")) {
        Object circularModules = CircularModuleDependenciesDetector.addingDependencyFormsCircularity(module, flutterModule);
        if (circularModules == null) {
          ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
          if (!rootManager.isDependsOn(flutterModule)) {
            JavaProjectModelModifier[] modifiers = JavaProjectModelModifier.EP_NAME.getExtensions(getProject());
            for (JavaProjectModelModifier modifier : modifiers) {
              if (modifier instanceof IdeaProjectModelModifier) {
                modifier.addModuleDependency(module, flutterModule, DependencyScope.COMPILE, false);
              }
            }
          }
        }
      }
    }
  }
}
 
Example #2
Source File: AndroidModuleLibraryManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void updateAndroidModuleLibraryDependencies(Module flutterModule) {
  for (final Module module : ModuleManager.getInstance(getProject()).getModules()) {
    if (module != flutterModule) {
      if (null != FacetManager.getInstance(module).findFacet(AndroidFacet.ID, "Android")) {
        Object circularModules = CircularModuleDependenciesDetector.addingDependencyFormsCircularity(module, flutterModule);
        if (circularModules == null) {
          ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
          if (!rootManager.isDependsOn(flutterModule)) {
            JavaProjectModelModifier[] modifiers = JavaProjectModelModifier.EP_NAME.getExtensions(getProject());
            for (JavaProjectModelModifier modifier : modifiers) {
              if (modifier instanceof IdeaProjectModelModifier) {
                modifier.addModuleDependency(module, flutterModule, DependencyScope.COMPILE, false);
              }
            }
          }
        }
      }
    }
  }
}
 
Example #3
Source File: GradleImportingTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
protected void assertMergedModuleCompileModuleDepScope(String moduleName, String depName) {
  if (isGradleOlderThen_3_4() || isGradleNewerThen_4_5()) {
    assertModuleModuleDepScope(moduleName, depName, DependencyScope.COMPILE);
  }
  else {
    assertModuleModuleDepScope(moduleName, depName, DependencyScope.PROVIDED, DependencyScope.TEST, DependencyScope.RUNTIME);
  }
}
 
Example #4
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 #5
Source File: ProjectLibraryTabContext.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private static DependencyScope getDefaultScope(Library item) {
  for (LibraryDependencyScopeSuggester suggester : LibraryDependencyScopeSuggester.EP_NAME.getExtensions()) {
    DependencyScope scope = suggester.getDefaultDependencyScope(item);
    if (scope != null) {
      return scope;
    }
  }
  return null;
}
 
Example #6
Source File: UsageInModuleClasspath.java    From consulo with Apache License 2.0 5 votes vote down vote up
public UsageInModuleClasspath(@Nonnull StructureConfigurableContext context,
                              @Nonnull ModuleProjectStructureElement containingElement,
                              ProjectStructureElement sourceElement,
                              @Nullable DependencyScope scope) {
  myContext = context;
  myContainingElement = containingElement;
  myScope = scope;
  myModule = containingElement.getModule();
  mySourceElement = sourceElement;
}
 
Example #7
Source File: ModuleSourceItemGroup.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void collectDependentModules(final Module module, Set<Module> modules, ArtifactEditorContext context) {
  if (!modules.add(module)) return;
  
  for (OrderEntry entry : context.getModulesProvider().getRootModel(module).getOrderEntries()) {
    if (entry instanceof ModuleOrderEntry) {
      final ModuleOrderEntry moduleEntry = (ModuleOrderEntry)entry;
      final Module dependency = moduleEntry.getModule();
      final DependencyScope scope = moduleEntry.getScope();
      if (dependency != null && scope.isForProductionRuntime()) {
        collectDependentModules(dependency, modules, context);
      }
    }
  }
}
 
Example #8
Source File: ClasspathTableModel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
  final ClasspathTableItem<?> item = myItems.get(rowIndex);
  if (columnIndex == EXPORT_COLUMN) {
    item.setExported(((Boolean)aValue).booleanValue());
  }
  else if (columnIndex == SCOPE_COLUMN && aValue instanceof DependencyScope) {
    item.setScope((DependencyScope) aValue);
  }
}
 
Example #9
Source File: ModuleLibraryOrderEntryType.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public ModuleLibraryOrderEntryImpl loadOrderEntry(@Nonnull Element element, @Nonnull ModuleRootLayer moduleRootLayer) throws InvalidDataException {
  boolean exported = element.getAttributeValue(EXPORTED_ATTR) != null;
  DependencyScope scope = DependencyScope.readExternal(element);
  Library library = LibraryTableImplUtil.loadLibrary(element, (ModuleRootLayerImpl)moduleRootLayer);
  return new ModuleLibraryOrderEntryImpl(library, (ModuleRootLayerImpl)moduleRootLayer, exported, scope, false);
}
 
Example #10
Source File: ModuleOrderEntryType.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public ModuleOrderEntryImpl loadOrderEntry(@Nonnull Element element, @Nonnull ModuleRootLayer moduleRootLayer) throws InvalidDataException {
  String moduleName = element.getAttributeValue(MODULE_NAME_ATTR);
  if (moduleName == null) {
    throw new InvalidDataException();
  }
  DependencyScope dependencyScope = DependencyScope.readExternal(element);
  boolean exported = element.getAttributeValue(EXPORTED_ATTR) != null;
  boolean productionOnTestDependency = element.getAttributeValue(PRODUCTION_ON_TEST_ATTRIBUTE) != null;
  return new ModuleOrderEntryImpl(moduleName, (ModuleRootLayerImpl)moduleRootLayer, dependencyScope, exported, productionOnTestDependency);
}
 
Example #11
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 #12
Source File: ClasspathTableModel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Class getColumnClass(int column) {
  if (column == EXPORT_COLUMN) {
    return Boolean.class;
  }
  if (column == SCOPE_COLUMN) {
    return DependencyScope.class;
  }
  if (column == ITEM_COLUMN) {
    return ClasspathTableItem.class;
  }
  return super.getColumnClass(column);
}
 
Example #13
Source File: GradleImportingTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
protected void assertMergedModuleCompileLibDepScope(String moduleName, String depName) {
  if (isGradleOlderThen_3_4() || isGradleNewerThen_4_5()) {
    assertModuleLibDepScope(moduleName, depName, DependencyScope.COMPILE);
  }
  else {
    assertModuleLibDepScope(moduleName, depName, DependencyScope.PROVIDED, DependencyScope.TEST, DependencyScope.RUNTIME);
  }
}
 
Example #14
Source File: UsageInModuleClasspath.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public String getPresentableLocationInElement() {
  return myScope != null && myScope != DependencyScope.COMPILE ? "[" + StringUtil.decapitalize(myScope.getDisplayName()) + "]" : null;
}
 
Example #15
Source File: ClasspathTableItem.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
public final DependencyScope getScope() {
  return myEntry instanceof ExportableOrderEntry ? ((ExportableOrderEntry)myEntry).getScope() : null;
}
 
Example #16
Source File: ClasspathTableItem.java    From consulo with Apache License 2.0 4 votes vote down vote up
public final void setScope(DependencyScope scope) {
  if (myEntry instanceof ExportableOrderEntry) {
    ((ExportableOrderEntry)myEntry).setScope(scope);
  }
}
 
Example #17
Source File: ArtifactCompilerTestCase.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected Library addProjectLibrary(final @javax.annotation.Nullable Module module, final String name, final DependencyScope scope,
                                    final VirtualFile... jars) {
  return PackagingElementsTestCase.addProjectLibrary(myProject, module, name, scope, jars);
}
 
Example #18
Source File: ArtifactCompilerTestCase.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected Library addProjectLibrary(final @Nullable Module module, final String name, final VirtualFile... jars) {
  return addProjectLibrary(module, name, DependencyScope.COMPILE, jars);
}
 
Example #19
Source File: PackagingElementsTestCase.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected Library addProjectLibrary(final @Nullable Module module, final String name, final DependencyScope scope, final VirtualFile... jars) {
  return addProjectLibrary(myProject, module, name, scope, jars);
}
 
Example #20
Source File: PackagingElementsTestCase.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected Library addProjectLibrary(final @javax.annotation.Nullable Module module, final String name, final VirtualFile... jars) {
  return addProjectLibrary(module, name, DependencyScope.COMPILE, jars);
}
 
Example #21
Source File: AbstractDependencyData.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setScope(DependencyScope scope) {
  myScope = scope;
}
 
Example #22
Source File: AbstractDependencyData.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public DependencyScope getScope() {
  return myScope;
}
 
Example #23
Source File: DependencyData.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
DependencyScope getScope();
 
Example #24
Source File: PantsCodeInsightFixtureTestCase.java    From intellij-pants-plugin with Apache License 2.0 4 votes vote down vote up
public static void addLibraryDependency(Module module, Library library) {
  final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
  final DependencyScope defaultScope = LibraryDependencyScopeSuggester.getDefaultScope(library);
  modifiableModel.addLibraryEntry(library).setScope(defaultScope);
  modifiableModel.commit();
}
 
Example #25
Source File: MavenImportingTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
protected void assertModuleModuleDepScope(String moduleName, String depName, DependencyScope scope) {
  ModuleOrderEntry dep = getModuleModuleDep(moduleName, depName);
  assertEquals(scope, dep.getScope());
}
 
Example #26
Source File: MavenImportingTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
protected void assertModuleLibDepScope(String moduleName, String depName, DependencyScope scope) {
  LibraryOrderEntry dep = getModuleLibDep(moduleName, depName);
  assertEquals(scope, dep.getScope());
}