• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DependencyScope类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.openapi.roots.DependencyScope的典型用法代码示例。如果您正苦于以下问题:Java DependencyScope类的具体用法?Java DependencyScope怎么用?Java DependencyScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DependencyScope类属于com.intellij.openapi.roots包,在下文中一共展示了DependencyScope类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: configureModuleDependencies

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
private void configureModuleDependencies(
    @NotNull final HybrisModuleDescriptor moduleDescriptor,
    @NotNull final Module module,
    @NotNull final Collection<Module> allModules,
    @NotNull final Set<HybrisModuleDescriptor> extModules,
    final @NotNull IdeModifiableModelsProvider modifiableModelsProvider
) {
    final ModifiableRootModel rootModel = modifiableModelsProvider.getModifiableRootModel(module);

    for (HybrisModuleDescriptor dependency : moduleDescriptor.getDependenciesTree()) {
        if (moduleDescriptor instanceof OotbHybrisModuleDescriptor) {
            if (extModules.contains(dependency)) {
                continue;
            }
        }

        Optional<Module> targetDependencyModule = findModuleByNameIgnoreCase(allModules, dependency.getName());
        final ModuleOrderEntry moduleOrderEntry = targetDependencyModule.isPresent()
            ? rootModel.addModuleOrderEntry(targetDependencyModule.get())
            : rootModel.addInvalidModuleEntry(dependency.getName());

        moduleOrderEntry.setExported(true);
        moduleOrderEntry.setScope(DependencyScope.COMPILE);
    }
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:26,代码来源:DefaultModulesDependenciesConfigurator.java


示例2: isExported

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
public static boolean isExported( Module ijModule, Module child )
{
  for( OrderEntry entry : ModuleRootManager.getInstance( ijModule ).getOrderEntries() )
  {
    if( entry instanceof ModuleOrderEntry )
    {
      final ModuleOrderEntry moduleEntry = (ModuleOrderEntry)entry;
      final DependencyScope scope = moduleEntry.getScope();
      if( !scope.isForProductionCompile() && !scope.isForProductionRuntime() )
      {
        continue;
      }
      final Module module = moduleEntry.getModule();
      if( module != null && module == child )
      {
        return moduleEntry.isExported();
      }
    }
  }
  return false;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:22,代码来源:ManProject.java


示例3: addProjectLibrary

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
static Library addProjectLibrary(final Project project, final @Nullable Module module, final String name, final DependencyScope scope,
                                 final VirtualFile[] jars) {
  return new WriteAction<Library>() {
    @Override
    protected void run(@NotNull final Result<Library> result) {
      final Library library = LibraryTablesRegistrar.getInstance().getLibraryTable(project).createLibrary(name);
      final Library.ModifiableModel libraryModel = library.getModifiableModel();
      for (VirtualFile jar : jars) {
        libraryModel.addRoot(jar, OrderRootType.CLASSES);
      }
      libraryModel.commit();
      if (module != null) {
        ModuleRootModificationUtil.addDependency(module, library, scope, false);
      }
      result.setResult(library);
    }
  }.execute().getResultObject();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PackagingElementsTestCase.java


示例4: getAndroidLibraryDependencies

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
@NotNull
public static List<AndroidFacet> getAndroidLibraryDependencies(@NotNull Module module) {
  final List<AndroidFacet> depFacets = new ArrayList<AndroidFacet>();

  for (OrderEntry orderEntry : ModuleRootManager.getInstance(module).getOrderEntries()) {
    if (orderEntry instanceof ModuleOrderEntry) {
      final ModuleOrderEntry moduleOrderEntry = (ModuleOrderEntry)orderEntry;

      if (moduleOrderEntry.getScope() == DependencyScope.COMPILE) {
        final Module depModule = moduleOrderEntry.getModule();

        if (depModule != null) {
          final AndroidFacet depFacet = AndroidFacet.getInstance(depModule);

          if (depFacet != null && depFacet.isLibraryProject()) {
            depFacets.add(depFacet);
          }
        }
      }
    }
  }
  return depFacets;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AndroidUtils.java


示例5: updateDependency

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
private void updateDependency(@NotNull Module module,
                              @NotNull IdeModifiableModelsProvider modelsProvider,
                              @NotNull JavaModuleDependency dependency) {
  DependencySetupErrors setupErrors = getSetupErrors(module.getProject());

  String moduleName = dependency.getModuleName();
  Module found = null;
  for (Module m : modelsProvider.getModules()) {
    if (moduleName.equals(m.getName())) {
      found = m;
    }
  }

  final ModifiableRootModel moduleModel = modelsProvider.getModifiableRootModel(module);
  if (found != null) {
    ModuleOrderEntry orderEntry = moduleModel.addModuleOrderEntry(found);
    orderEntry.setExported(true);
    DependencyScope scope = parseScope(dependency.getScope());
    orderEntry.setScope(scope);
    return;
  }
  setupErrors.addMissingModule(moduleName, module.getName(), null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:DependenciesModuleCustomizer.java


示例6: addLibrary

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
/**
 * Add a library, along with any recursive library dependencies
 */
private static void addLibrary(@NotNull AndroidLibrary library,
                               @NotNull DependencySet dependencies,
                               @NotNull DependencyScope scope,
                               @NotNull Set<File> unique) {
  // We're using the library location as a unique handle rather than the AndroidLibrary instance itself, in case
  // the model just blindly manufactures library instances as it's following dependencies
  File folder = library.getFolder();
  if (unique.contains(folder)) {
    return;
  }
  unique.add(folder);

  LibraryDependency dependency = createLibraryDependency(library, scope);
  dependencies.add(dependency);

  for (AndroidLibrary dependentLibrary : library.getLibraryDependencies()) {
    addLibrary(dependentLibrary, dependencies, scope, unique);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:Dependency.java


示例7: testExtractFromWithJar

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
public void testExtractFromWithJar() {
  File jarFile = new File("~/repo/guava/guava-11.0.2.jar");

  myVariant.getMainArtifact().getDependencies().addJar(jarFile);
  myVariant.getInstrumentTestArtifact().getDependencies().addJar(jarFile);

  Collection<LibraryDependency> dependencies = Dependency.extractFrom(myIdeaAndroidProject).onLibraries();
  assertEquals(1, dependencies.size());

  LibraryDependency dependency = ContainerUtil.getFirstItem(dependencies);
  assertNotNull(dependency);
  assertEquals("guava-11.0.2", dependency.getName());
  // Make sure that is a "compile" dependency, even if specified as "test".
  assertEquals(DependencyScope.COMPILE, dependency.getScope());

  Collection<String> binaryPaths = dependency.getPaths(LibraryDependency.PathType.BINARY);
  assertEquals(1, binaryPaths.size());
  assertEquals(jarFile.getPath(), ContainerUtil.getFirstItem(binaryPaths));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ExtractAndroidDependenciesTest.java


示例8: testExtractFromWithLibraryAar

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
public void testExtractFromWithLibraryAar() {
  String rootDirPath = myAndroidProject.getRootDir().getPath();
  File bundle = new File(rootDirPath, "bundle.aar");
  File libJar = new File(rootDirPath, FileUtil.join("bundle_aar", "library.jar"));
  AndroidLibraryStub library = new AndroidLibraryStub(bundle, libJar);

  myVariant.getMainArtifact().getDependencies().addLibrary(library);
  myVariant.getInstrumentTestArtifact().getDependencies().addLibrary(library);

  Collection<LibraryDependency> dependencies = Dependency.extractFrom(myIdeaAndroidProject).onLibraries();
  assertEquals(1, dependencies.size());

  LibraryDependency dependency = ContainerUtil.getFirstItem(dependencies);
  assertNotNull(dependency);
  assertEquals("bundle", dependency.getName());
  // Make sure that is a "compile" dependency, even if specified as "test".
  assertEquals(DependencyScope.COMPILE, dependency.getScope());

  Collection<String> binaryPaths = dependency.getPaths(LibraryDependency.PathType.BINARY);
  assertEquals(2, binaryPaths.size());
  assertTrue(binaryPaths.contains(libJar.getPath()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ExtractAndroidDependenciesTest.java


示例9: testExtractFromWithProject

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
public void testExtractFromWithProject() {
  String gradlePath = "abc:xyz:library";
  myVariant.getMainArtifact().getDependencies().addProject(gradlePath);
  myVariant.getInstrumentTestArtifact().getDependencies().addProject(gradlePath);
  Collection<ModuleDependency> dependencies = Dependency.extractFrom(myIdeaAndroidProject).onModules();
  assertEquals(1, dependencies.size());

  ModuleDependency dependency = ContainerUtil.getFirstItem(dependencies);
  assertNotNull(dependency);
  assertEquals(gradlePath, dependency.getGradlePath());
  // Make sure that is a "compile" dependency, even if specified as "test".
  assertEquals(DependencyScope.COMPILE, dependency.getScope());

  LibraryDependency backup = dependency.getBackupDependency();
  assertNull(backup);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ExtractAndroidDependenciesTest.java


示例10: testAddLibrary

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
public void testAddLibrary() {
  LibraryDependency dependency1 = new LibraryDependency("library-1.0.1.jar", DependencyScope.COMPILE);
  dependency1.addPath(LibraryDependency.PathType.BINARY, new File("file1.jar"));
  myDependencies.add(dependency1);

  LibraryDependency dependency2 = new LibraryDependency("library-1.0.1.jar", DependencyScope.TEST);
  dependency2.addPath(LibraryDependency.PathType.BINARY, new File("file2.jar"));
  myDependencies.add(dependency2);

  LibraryDependency dependency3 = new LibraryDependency("library-1.0.1.jar", DependencyScope.COMPILE);
  dependency3.addPath(LibraryDependency.PathType.BINARY, new File("file2.jar"));
  myDependencies.add(dependency3);

  Collection<LibraryDependency> all = myDependencies.onLibraries();
  assertEquals(2, all.size());
  assertTrue(all.contains(dependency1));
  assertTrue(all.contains(dependency3));

  assertFalse(dependency1.getName().equals(dependency3.getName()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:DependencySetTest.java


示例11: parseScope

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
@Nullable
private static DependencyScope parseScope(@Nullable IdeaDependencyScope scope) {
  if (scope == null) {
    return null;
  }
  String scopeAsString = scope.getScope();
  if (scopeAsString == null) {
    return null;
  }
  for (DependencyScope dependencyScope : DependencyScope.values()) {
    if (scopeAsString.equalsIgnoreCase(dependencyScope.toString())) {
      return dependencyScope;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:BaseGradleProjectResolverExtension.java


示例12: getDefaultDependencyScope

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
@Nullable
@Override
public DependencyScope getDefaultDependencyScope(@NotNull Library library) {
  if (!(library instanceof LibraryEx)) {
    return null;
  }
  LibraryEx libraryEx = (LibraryEx)library;
  LibraryProperties libraryProperties = libraryEx.getProperties();
  if (libraryProperties == null || !(libraryProperties instanceof RepositoryLibraryProperties)) {
    return null;
  }
  RepositoryLibraryProperties repositoryLibraryProperties = (RepositoryLibraryProperties)libraryProperties;
  RepositoryLibraryDescription libraryDescription = RepositoryLibraryDescription.findDescription(repositoryLibraryProperties);

  return libraryDescription.getSuggestedScope();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:RepositoryLibraryDependencyScopeSuggester.java


示例13: getClasspath

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
@NotNull
public String getClasspath(@NotNull MavenProject mavenProject,
                           @Nullable Element manifestConfiguration) {
  StringBuilder classpath = new StringBuilder();
  String classpathPrefix = getClasspathPrefix(manifestConfiguration);
  for (MavenArtifact mavenArtifact : mavenProject.getDependencies()) {
    final DependencyScope scope = MavenModuleImporter.selectScope(mavenArtifact.getScope());
    if (scope.isForProductionCompile() || scope.isForProductionRuntime()) {
      if (classpath.length() > 0) {
        classpath.append(" ");
      }
      classpath.append(classpathPrefix);
      String artifactFileName = mavenArtifact.getArtifactId() + "-" + mavenArtifact.getVersion() + "." + mavenArtifact.getExtension();
      classpath.append(doGetClasspathItem(mavenProject, mavenArtifact, artifactFileName));
    }
  }
  return classpath.toString();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ManifestImporter.java


示例14: testAddModuleDependency

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
public void testAddModuleDependency() throws IOException {
  createTwoModulesPom("m1", "m2");
  VirtualFile m1 = createModulePom("m1", "<groupId>test</groupId>" +
                                         "<artifactId>m1</artifactId>" +
                                         "<version>1</version>");
  createModulePom("m2", "<groupId>test</groupId>" +
                        "<artifactId>m2</artifactId>" +
                        "<version>1</version>");
  importProject();

  Promise<Void> result = getExtension().addModuleDependency(getModule("m1"), getModule("m2"), DependencyScope.COMPILE);
  assertNotNull(result);
  assertHasDependency(m1, "test", "m2");
  waitUntilImported(result);
  assertModuleModuleDeps("m1", "m2");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:MavenProjectModelModifierTest.java


示例15: addProjectLibrary

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
static Library addProjectLibrary(final Project project, final @Nullable Module module, final String name, final DependencyScope scope,
                                 final VirtualFile[] jars) {
  return new WriteAction<Library>() {
    @Override
    protected void run(final Result<Library> result) {
      final Library library = LibraryTablesRegistrar.getInstance().getLibraryTable(project).createLibrary(name);
      final Library.ModifiableModel libraryModel = library.getModifiableModel();
      for (VirtualFile jar : jars) {
        libraryModel.addRoot(jar, OrderRootType.CLASSES);
      }
      libraryModel.commit();
      if (module != null) {
        ModuleRootModificationUtil.addDependency(module, library, scope, false);
      }
      result.setResult(library);
    }
  }.execute().getResultObject();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:PackagingElementsTestCase.java


示例16: addProjectLibrary

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
static Library addProjectLibrary(final Project project, final @Nullable Module module, final String name, final DependencyScope scope,
                                 final VirtualFile[] jars) {
  return new WriteAction<Library>() {
    @Override
    protected void run(final Result<Library> result) {
      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);
      }
      result.setResult(library);
    }
  }.execute().getResultObject();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:PackagingElementsTestCase.java


示例17: invoke

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
@Override
public void invoke(@NotNull Project project, final Editor editor, PsiFile file) throws IncorrectOperationException
{
	DependencyScope scope = suggestScopeByLocation(myCurrentModule, myReference.getElement());
	JavaProjectModelModificationService.getInstance(project).addDependency(myCurrentModule, myLibraryDescriptor, scope).doWhenDone(aVoid -> new WriteAction()
	{
		protected void run(@NotNull final Result result)
		{
			try
			{
				importClass(myCurrentModule, editor, myReference, myQualifiedClassName);
			}
			catch(IndexNotReadyException e)
			{
				LOG.info(e);
			}
		}
	}.execute());
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:20,代码来源:AddExternalLibraryToDependenciesQuickFix.java


示例18: addDependencyOnModule

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
private void addDependencyOnModule(Project project, Editor editor, @Nullable Module module)
{
	if(module == null)
	{
		return;
	}
	Pair<Module, Module> circularModules = ModuleCompilerUtil.addingDependencyFormsCircularity(myCurrentModule, module);
	if(circularModules == null || showCircularWarning(project, circularModules, module))
	{
		boolean test = ModuleRootManager.getInstance(myCurrentModule).getFileIndex().isInTestSourceContent(myRefVFile);
		DependencyScope scope = test ? DependencyScope.TEST : DependencyScope.COMPILE;
		JavaProjectModelModificationService.getInstance(project).addDependency(myCurrentModule, module, scope);

		if(editor != null && !myClasses.isEmpty())
		{
			PsiClass[] targetClasses = myClasses.stream().filter(c -> ModuleUtilCore.findModuleForPsiElement(c) == module).toArray(PsiClass[]::new);
			if(targetClasses.length > 0)
			{
				new AddImportAction(project, myReference, editor, targetClasses).execute();
			}
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:24,代码来源:AddModuleDependencyFix.java


示例19: DefaultJavaLibraryDescriptor

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
public DefaultJavaLibraryDescriptor(
    @NotNull final File libraryFile,
    final boolean isExported
) {
    Validate.notNull(libraryFile);

    this.libraryFile = libraryFile;
    this.sourcesFile = null;
    this.isExported = isExported;
    this.isDirectoryWithClasses = false;
    this.scope = DependencyScope.COMPILE;
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:13,代码来源:DefaultJavaLibraryDescriptor.java


示例20: setLibraryEntryScope

import com.intellij.openapi.roots.DependencyScope; //导入依赖的package包/类
private void setLibraryEntryScope(
    @NotNull final ModifiableRootModel modifiableRootModel,
    @NotNull final Library library,
    @NotNull DependencyScope scope
) {
    final LibraryOrderEntry entry = findOrderEntryForLibrary(modifiableRootModel, library);

    if (entry != null) {
        entry.setScope(scope);
    }
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:12,代码来源:DefaultLibRootsConfigurator.java



注:本文中的com.intellij.openapi.roots.DependencyScope类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AuthenticationException类代码示例发布时间:2022-05-23
下一篇:
Java NextFilter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap