当前位置: 首页>>代码示例>>Java>>正文


Java OrderEnumerator.productionOnly方法代码示例

本文整理汇总了Java中com.intellij.openapi.roots.OrderEnumerator.productionOnly方法的典型用法代码示例。如果您正苦于以下问题:Java OrderEnumerator.productionOnly方法的具体用法?Java OrderEnumerator.productionOnly怎么用?Java OrderEnumerator.productionOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.roots.OrderEnumerator的用法示例。


在下文中一共展示了OrderEnumerator.productionOnly方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assertClasspath

import com.intellij.openapi.roots.OrderEnumerator; //导入方法依赖的package包/类
private void assertClasspath(String moduleName, Scope scope, Type type, String... expectedPaths) throws Exception {
  createOutputDirectories();

  PathsList actualPathsList;
  Module module = getModule(moduleName);

  if (scope == Scope.RUNTIME) {
    JavaParameters params = new JavaParameters();
    params.configureByModule(module, type == Type.TESTS ? JavaParameters.CLASSES_AND_TESTS : JavaParameters.CLASSES_ONLY);
    actualPathsList = params.getClassPath();
  }
  else {
    OrderEnumerator en = OrderEnumerator.orderEntries(module).recursively().withoutSdk().compileOnly();
    if (type == Type.PRODUCTION) en.productionOnly();
    actualPathsList = en.classes().getPathsList();
  }

  assertPaths(expectedPaths, actualPathsList.getPathList());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:MavenClasspathsAndSearchScopesTest.java

示例2: getJdkToRunModule

import com.intellij.openapi.roots.OrderEnumerator; //导入方法依赖的package包/类
private Sdk getJdkToRunModule(Module module) {
    final Sdk moduleSdk = ModuleRootManager.getInstance(module).getSdk();
    if (moduleSdk == null) {
        return null;
    }

    final Set<Sdk> sdksFromDependencies = new LinkedHashSet<>();
    OrderEnumerator enumerator = OrderEnumerator.orderEntries(module).runtimeOnly().recursively();
    enumerator = enumerator.productionOnly();
    enumerator.forEachModule(module1 -> {
        Sdk sdk = ModuleRootManager.getInstance(module1).getSdk();
        if (sdk != null && sdk.getSdkType().equals(moduleSdk.getSdkType())) {
            sdksFromDependencies.add(sdk);
        }
        return true;
    });
    return findLatestVersion(moduleSdk, sdksFromDependencies);
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:19,代码来源:XQueryRunProfileState.java

示例3: getJdkToRunModule

import com.intellij.openapi.roots.OrderEnumerator; //导入方法依赖的package包/类
@Nullable
public static Sdk getJdkToRunModule(Module module, boolean productionOnly)
{
	final Sdk moduleSdk = ModuleUtilCore.getSdk(module, JavaModuleExtension.class);
	if(moduleSdk == null)
	{
		return null;
	}

	final Set<Sdk> sdksFromDependencies = new LinkedHashSet<>();
	OrderEnumerator enumerator = OrderEnumerator.orderEntries(module).runtimeOnly().recursively();
	if(productionOnly)
	{
		enumerator = enumerator.productionOnly();
	}
	enumerator.forEachModule(module1 ->
	{
		Sdk sdk = ModuleUtilCore.getSdk(module1, JavaModuleExtension.class);
		if(sdk != null && sdk.getSdkType().equals(moduleSdk.getSdkType()))
		{
			sdksFromDependencies.add(sdk);
		}
		return true;
	});
	return findLatestVersion(moduleSdk, sdksFromDependencies);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:OwnJavaParameters.java

示例4: configureEnumerator

import com.intellij.openapi.roots.OrderEnumerator; //导入方法依赖的package包/类
private static OrderRootsEnumerator configureEnumerator(OrderEnumerator enumerator, int classPathType, Sdk jdk)
{
	if((classPathType & INCLUDE_PROVIDED) == 0)
	{
		enumerator = enumerator.runtimeOnly();
	}
	if((classPathType & JDK_ONLY) == 0)
	{
		enumerator = enumerator.withoutSdk();
	}
	if((classPathType & TESTS_ONLY) == 0)
	{
		enumerator = enumerator.productionOnly();
	}
	OrderRootsEnumerator rootsEnumerator = enumerator.classes();
	if((classPathType & JDK_ONLY) != 0)
	{
		rootsEnumerator = rootsEnumerator.usingCustomRootProvider(e -> e instanceof ModuleExtensionWithSdkOrderEntry ? jdkRoots(jdk) : e.getFiles(OrderRootType.CLASSES));
	}
	return rootsEnumerator;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:OwnJavaParameters.java

示例5: configureEnumerator

import com.intellij.openapi.roots.OrderEnumerator; //导入方法依赖的package包/类
private static OrderRootsEnumerator configureEnumerator(OrderEnumerator enumerator, int classPathType, Sdk jdk)
{
	if((classPathType & JDK_ONLY) == 0)
	{
		enumerator = enumerator.withoutSdk();
	}
	if((classPathType & TESTS_ONLY) == 0)
	{
		enumerator = enumerator.productionOnly();
	}
	OrderRootsEnumerator rootsEnumerator = enumerator.classes();
	final NotNullFunction<OrderEntry, VirtualFile[]> provider = computeRootProvider(classPathType, jdk);
	if(provider != null)
	{
		rootsEnumerator = rootsEnumerator.usingCustomRootProvider(provider);
	}
	return rootsEnumerator;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:JavaParameters.java

示例6: orderEnumerator

import com.intellij.openapi.roots.OrderEnumerator; //导入方法依赖的package包/类
private OrderEnumerator orderEnumerator(Module module, boolean exportedOnly, Condition<OrderEntry> condition) {
  OrderEnumerator enumerator = OrderEnumerator.orderEntries(module).compileOnly().satisfying(condition);
  if ((mySourcesFilter & TEST_SOURCES) == 0) {
    enumerator = enumerator.productionOnly();
  }
  enumerator = enumerator.recursively();
  return exportedOnly ? enumerator.exportedOnly() : enumerator;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:9,代码来源:ModuleChunk.java

示例7: collectAllowedDependencies

import com.intellij.openapi.roots.OrderEnumerator; //导入方法依赖的package包/类
private void collectAllowedDependencies() {
  myAllowedDependencies.add(myTargetModule);
  OrderEnumerator orderEnumerator = ModuleRootManager.getInstance(myTargetModule).orderEntries();
  VirtualFile vFile = myPsiClass.getContainingFile().getVirtualFile();
  if (!ProjectFileIndex.SERVICE.getInstance(myTargetModule.getProject()).isInTestSourceContent(vFile)) {
    orderEnumerator = orderEnumerator.productionOnly();
  }
  orderEnumerator.recursively().forEachModule(new Processor<Module>() {
    @Override
    public boolean process(Module module) {
      myAllowedDependencies.add(module);
      return true;
    }
  });
}
 
开发者ID:JetBrains,项目名称:hackathon-unchain,代码行数:16,代码来源:Unchainer.java

示例8: doCreateArtifact

import com.intellij.openapi.roots.OrderEnumerator; //导入方法依赖的package包/类
@Nullable
public NewArtifactConfiguration doCreateArtifact(final Module[] modules, final String mainClassName,
                                                 final String directoryForManifest,
                                                 final boolean extractLibrariesToJar,
                                                 final boolean includeTests) {
  VirtualFile manifestFile = null;
  final Project project = myContext.getProject();
  if (mainClassName != null && !mainClassName.isEmpty() || !extractLibrariesToJar) {
    final VirtualFile directory;
    try {
      directory = ApplicationManager.getApplication().runWriteAction(new ThrowableComputable<VirtualFile, IOException>() {
        @Override
        public VirtualFile compute() throws IOException {
          return VfsUtil.createDirectoryIfMissing(directoryForManifest);
        }
      });
    }
    catch (IOException e) {
      LOG.info(e);
      Messages.showErrorDialog(project, "Cannot create directory '" + directoryForManifest + "': " + e.getMessage(),
                               CommonBundle.getErrorTitle());
      return null;
    }
    if (directory == null) return null;

    manifestFile = ManifestFileUtil.createManifestFile(directory, project);
    if (manifestFile == null) {
      return null;
    }
    ManifestFileUtil.updateManifest(manifestFile, mainClassName, null, true);
  }

  String name = modules.length == 1 ? modules[0].getName() : project.getName();

  final PackagingElementFactory factory = PackagingElementFactory.getInstance();
  final CompositePackagingElement<?> archive = factory.createArchive(ArtifactUtil.suggestArtifactFileName(name) + ".jar");

  OrderEnumerator orderEnumerator = ProjectRootManager.getInstance(project).orderEntries(Arrays.asList(modules));

  final Set<Library> libraries = new THashSet<Library>();
  if (!includeTests) {
    orderEnumerator = orderEnumerator.productionOnly();
  }
  final ModulesProvider modulesProvider = myContext.getModulesProvider();
  final OrderEnumerator enumerator = orderEnumerator.using(modulesProvider).withoutSdk().runtimeOnly().recursively();
  enumerator.forEachLibrary(new CommonProcessors.CollectProcessor<Library>(libraries));
  enumerator.forEachModule(new Processor<Module>() {
    @Override
    public boolean process(Module module) {
      if (ProductionModuleOutputElementType.ELEMENT_TYPE.isSuitableModule(modulesProvider, module)) {
        archive.addOrFindChild(factory.createModuleOutput(module));
      }
      if (includeTests && TestModuleOutputElementType.ELEMENT_TYPE.isSuitableModule(modulesProvider, module)) {
        archive.addOrFindChild(factory.createTestModuleOutput(module));
      }
      return true;
    }
  });

  final JarArtifactType jarArtifactType = JarArtifactType.getInstance();
  if (manifestFile != null && !manifestFile.equals(ManifestFileUtil.findManifestFile(archive, myContext, jarArtifactType))) {
    archive.addFirstChild(factory.createFileCopyWithParentDirectories(manifestFile.getPath(), ManifestFileUtil.MANIFEST_DIR_NAME));
  }

  final String artifactName = name + ":jar";
  if (extractLibrariesToJar) {
    addExtractedLibrariesToJar(archive, factory, libraries);
    return new NewArtifactConfiguration(archive, artifactName, jarArtifactType);
  }
  else {
    final ArtifactRootElement<?> root = factory.createArtifactRootElement();
    List<String> classpath = new ArrayList<String>();
    root.addOrFindChild(archive);
    addLibraries(libraries, root, archive, classpath);
    ManifestFileUtil.updateManifest(manifestFile, mainClassName, classpath, true);
    return new NewArtifactConfiguration(root, artifactName, PlainArtifactType.getInstance());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:79,代码来源:JarFromModulesTemplate.java

示例9: configureEnumerator

import com.intellij.openapi.roots.OrderEnumerator; //导入方法依赖的package包/类
private OrderRootsEnumerator configureEnumerator(OrderEnumerator enumerator, Sdk jdk) {
    enumerator = enumerator.productionOnly();
    OrderRootsEnumerator rootsEnumerator = enumerator.classes();
    rootsEnumerator = rootsEnumerator.usingCustomRootProvider(e -> e instanceof JdkOrderEntry ? jdkRoots(jdk) : e.getFiles(OrderRootType.CLASSES));
    return rootsEnumerator;
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:7,代码来源:XQueryRunProfileState.java

示例10: doCreateArtifact

import com.intellij.openapi.roots.OrderEnumerator; //导入方法依赖的package包/类
@Nullable
public NewArtifactConfiguration doCreateArtifact(final Module[] modules, final String mainClassName,
                                                 final String directoryForManifest,
                                                 final boolean extractLibrariesToJar,
                                                 final boolean includeTests) {
  VirtualFile manifestFile = null;
  final Project project = myContext.getProject();
  if (mainClassName != null && !mainClassName.isEmpty() || !extractLibrariesToJar) {
    final VirtualFile directory;
    try {
      directory = ApplicationManager.getApplication().runWriteAction(new ThrowableComputable<VirtualFile, IOException>() {
        @Override
        public VirtualFile compute() throws IOException {
          return VfsUtil.createDirectoryIfMissing(directoryForManifest);
        }
      });
    }
    catch (IOException e) {
      LOG.info(e);
      Messages.showErrorDialog(project, "Cannot create directory '" + directoryForManifest + "': " + e.getMessage(),
                               CommonBundle.getErrorTitle());
      return null;
    }
    if (directory == null) return null;

    manifestFile = ManifestFileUtil.createManifestFile(directory, project);
    if (manifestFile == null) {
      return null;
    }
    ManifestFileUtil.updateManifest(manifestFile, mainClassName, null, true);
  }

  String name = modules.length == 1 ? modules[0].getName() : project.getName();

  final PackagingElementFactory factory = PackagingElementFactory.getInstance();
  final CompositePackagingElement<?> archive = factory.createZipArchive(ArtifactUtil.suggestArtifactFileName(name) + ".jar");

  OrderEnumerator orderEnumerator = ProjectRootManager.getInstance(project).orderEntries(Arrays.asList(modules));

  final Set<Library> libraries = new THashSet<Library>();
  if (!includeTests) {
    orderEnumerator = orderEnumerator.productionOnly();
  }
  final ModulesProvider modulesProvider = myContext.getModulesProvider();
  final OrderEnumerator enumerator = orderEnumerator.using(modulesProvider).withoutSdk().runtimeOnly().recursively();
  enumerator.forEachLibrary(new CommonProcessors.CollectProcessor<Library>(libraries));
  enumerator.forEachModule(new Processor<Module>() {
    @Override
    public boolean process(Module module) {
      if (ProductionModuleOutputElementType.getInstance().isSuitableModule(modulesProvider, module)) {
        archive.addOrFindChild(factory.createModuleOutput(module));
      }
      if (includeTests && TestModuleOutputElementType.getInstance().isSuitableModule(modulesProvider, module)) {
        archive.addOrFindChild(factory.createTestModuleOutput(module));
      }
      return true;
    }
  });

  final JarArtifactType jarArtifactType = JarArtifactType.getInstance();
  if (manifestFile != null && !manifestFile.equals(ManifestFileUtil.findManifestFile(archive, myContext, jarArtifactType))) {
    archive.addFirstChild(factory.createFileCopyWithParentDirectories(manifestFile.getPath(), ManifestFileUtil.MANIFEST_DIR_NAME));
  }

  final String artifactName = name + ":jar";
  if (extractLibrariesToJar) {
    addExtractedLibrariesToJar(archive, factory, libraries);
    return new NewArtifactConfiguration(archive, artifactName, jarArtifactType);
  }
  else {
    final ArtifactRootElement<?> root = factory.createArtifactRootElement();
    List<String> classpath = new ArrayList<String>();
    root.addOrFindChild(archive);
    addLibraries(libraries, root, archive, classpath);
    ManifestFileUtil.updateManifest(manifestFile, mainClassName, classpath, true);
    return new NewArtifactConfiguration(root, artifactName, PlainArtifactType.getInstance());
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:79,代码来源:JarFromModulesTemplate.java


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