public void testClasspathConfiguration() throws CantRunException { JavaParameters parameters = new JavaParameters(); RunConfigurationModule module = new JavaRunConfigurationModule(myProject, false); Module module1 = getModule1(); Module module2 = getModule2(); addDependency(module1, module2); Module module3 = getModule3(); addDependency(module2, module3); addDependency(module1, module3); addOutputs(module1, 1); addOutputs(module2, 2); addOutputs(module3, 3); module.setModule(module1); parameters.configureByModule(module.getModule(), JavaParameters.JDK_AND_CLASSES_AND_TESTS); ArrayList<String> classPath = new ArrayList<>(); StringTokenizer tokenizer = new StringTokenizer(parameters.getClassPath().getPathsString(), File.pathSeparator); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); classPath.add(token); } CHECK.singleOccurence(classPath, getOutput(module1, false)); CHECK.singleOccurence(classPath, getOutput(module1, false)); CHECK.singleOccurence(classPath, getOutput(module1, true)); CHECK.singleOccurence(classPath, getOutput(module2, false)); CHECK.singleOccurence(classPath, getOutput(module2, true)); CHECK.singleOccurence(classPath, getOutput(module3, false)); CHECK.singleOccurence(classPath, getOutput(module3, true)); CHECK.singleOccurence(classPath, getFSPath(findFile(MOCK_JUNIT))); }
@Nullable public static PathsList getClassPathFromRootModel( Module module, boolean isTests, JavaParameters params, boolean allowDuplication, PathsList pathList) throws CantRunException { if (module == null) { return null; } final JavaParameters tmp = new JavaParameters(); tmp.configureByModule( module, isTests ? JavaParameters.CLASSES_AND_TESTS : JavaParameters.CLASSES_ONLY); if (tmp.getClassPath().getVirtualFiles().isEmpty()) { return null; } Set<VirtualFile> core = new HashSet<VirtualFile>(params.getClassPath().getVirtualFiles()); for (VirtualFile virtualFile : tmp.getClassPath().getVirtualFiles()) { if (allowDuplication || !core.contains(virtualFile)) { pathList.add(virtualFile); } } return pathList; }
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()); }