本文整理汇总了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());
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
});
}
示例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());
}
}
示例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;
}
示例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());
}
}