use of com.intellij.util.PathsList in project intellij-community by JetBrains.
the class PathListBuilderTest method testAsString.
@Test
public void testAsString() {
PathsList builder = new PathsList();
builder.add("a" + File.pathSeparatorChar + "b" + File.pathSeparatorChar);
builder.add("c" + File.pathSeparatorChar);
assertThat(builder.getPathsString()).isEqualTo("a" + File.pathSeparatorChar + "b" + File.pathSeparatorChar + "c");
}
use of com.intellij.util.PathsList in project intellij-community by JetBrains.
the class GroovyScriptRunner method addClasspathFromRootModel.
protected static void addClasspathFromRootModel(@Nullable Module module, boolean isTests, JavaParameters params, boolean allowDuplication) throws CantRunException {
PathsList nonCore = new PathsList();
getClassPathFromRootModel(module, isTests, params, allowDuplication, nonCore);
final String cp = nonCore.getPathsString();
if (!StringUtil.isEmptyOrSpaces(cp)) {
params.getProgramParametersList().add("--classpath");
params.getProgramParametersList().add(cp);
}
}
use of com.intellij.util.PathsList in project intellij-community by JetBrains.
the class TestObject method createJavaParameters.
@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
JavaParameters javaParameters = super.createJavaParameters();
javaParameters.setMainClass(JUnitConfiguration.JUNIT_START_CLASS);
javaParameters.getProgramParametersList().add(JUnitStarter.IDE_VERSION + JUnitStarter.VERSION);
final StringBuilder buf = new StringBuilder();
collectListeners(javaParameters, buf, IDEAJUnitListener.EP_NAME, "\n");
if (buf.length() > 0) {
try {
myListenersFile = FileUtil.createTempFile("junit_listeners_", "", true);
javaParameters.getProgramParametersList().add("@@" + myListenersFile.getPath());
FileUtil.writeToFile(myListenersFile, buf.toString().getBytes(CharsetToolkit.UTF8_CHARSET));
} catch (IOException e) {
LOG.error(e);
}
}
final Project project = getConfiguration().getProject();
final SourceScope sourceScope = getSourceScope();
if (isJUnit5(getConfiguration().getConfigurationModule().getModule(), sourceScope, project)) {
javaParameters.getProgramParametersList().add(JUnitStarter.JUNIT5_PARAMETER);
javaParameters.getClassPath().add(PathUtil.getJarPathForClass(JUnit5IdeaTestRunner.class));
final PathsList classPath = javaParameters.getClassPath();
classPath.add(PathUtil.getJarPathForClass(TestExecutionListener.class));
classPath.add(PathUtil.getJarPathForClass(JupiterTestEngine.class));
classPath.add(PathUtil.getJarPathForClass(JUnitException.class));
classPath.add(PathUtil.getJarPathForClass(TestEngine.class));
classPath.add(PathUtil.getJarPathForClass(JUnitPlatform.class));
try {
JUnitUtil.getTestCaseClass(sourceScope);
classPath.add(PathUtil.getJarPathForClass(VintageTestEngine.class));
} catch (JUnitUtil.NoJUnitException ignore) {
}
}
return javaParameters;
}
use of com.intellij.util.PathsList in project android by JetBrains.
the class AndroidDxWrapper method execute.
@SuppressWarnings({ "IOResourceOpenedButNotSafelyClosed" })
public static Map<AndroidCompilerMessageKind, List<String>> execute(@NotNull Module module, @NotNull IAndroidTarget target, @NotNull String outputDir, @NotNull String[] compileTargets, @NotNull String additionalVmParams, int maxHeapSize, boolean optimize) {
BuildToolInfo buildToolInfo = target.getBuildToolInfo();
if (buildToolInfo == null) {
return Collections.singletonMap(AndroidCompilerMessageKind.ERROR, Collections.singletonList("No Build Tools in the Android SDK."));
}
String outFile = outputDir + File.separatorChar + AndroidCommonUtils.CLASSES_FILE_NAME;
final Map<AndroidCompilerMessageKind, List<String>> messages = new HashMap<AndroidCompilerMessageKind, List<String>>(2);
messages.put(AndroidCompilerMessageKind.ERROR, new ArrayList<String>());
messages.put(AndroidCompilerMessageKind.INFORMATION, new ArrayList<String>());
messages.put(AndroidCompilerMessageKind.WARNING, new ArrayList<String>());
String dxJarPath = buildToolInfo.getPath(BuildToolInfo.PathId.DX_JAR);
File dxJar = new File(dxJarPath);
if (!dxJar.isFile()) {
messages.get(AndroidCompilerMessageKind.ERROR).add(AndroidBundle.message("android.file.not.exist.error", dxJarPath));
return messages;
}
JavaParameters parameters = new JavaParameters();
Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
// dex runs after simple java compilation, so JDK must be specified
assert sdk != null;
parameters.setJdk(sdk);
parameters.setMainClass(AndroidDxRunner.class.getName());
ParametersList programParamList = parameters.getProgramParametersList();
programParamList.add(dxJarPath);
programParamList.add(outFile);
programParamList.add("--optimize", Boolean.toString(optimize));
programParamList.addAll(compileTargets);
programParamList.add("--exclude");
ParametersList vmParamList = parameters.getVMParametersList();
if (additionalVmParams.length() > 0) {
vmParamList.addParametersString(additionalVmParams);
}
if (!AndroidCommonUtils.hasXmxParam(vmParamList.getParameters())) {
vmParamList.add("-Xmx" + maxHeapSize + "M");
}
final PathsList classPath = parameters.getClassPath();
classPath.add(PathUtil.getJarPathForClass(AndroidDxRunner.class));
classPath.add(PathUtil.getJarPathForClass(FileUtilRt.class));
// delete file to check if it will exist after dex compilation
if (!new File(outFile).delete()) {
LOG.info("Cannot delete file " + outFile);
}
Process process;
try {
parameters.setUseDynamicClasspath(true);
GeneralCommandLine commandLine = parameters.toCommandLine();
LOG.info(commandLine.getCommandLineString());
process = commandLine.createProcess();
AndroidCommonUtils.handleDexCompilationResult(process, commandLine.getCommandLineString(), outFile, messages, false);
} catch (ExecutionException e) {
messages.get(AndroidCompilerMessageKind.ERROR).add("ExecutionException: " + e.getMessage());
LOG.info(e);
return messages;
}
return messages;
}
use of com.intellij.util.PathsList in project android by JetBrains.
the class AndroidJunitPatcherTest method testMultipleMockableJars_oldModel.
public void testMultipleMockableJars_oldModel() throws Exception {
String jar22 = myRoot + "lib1/build/intermediates/mockable-android-22.jar";
String jar15 = myRoot + "lib2/build/intermediates/mockable-android-15.jar";
PathsList classPath = myJavaParameters.getClassPath();
classPath.addFirst(jar22);
classPath.addFirst(jar15);
myPatcher.patchJavaParameters(myModule, myJavaParameters);
List<String> pathList = classPath.getPathList();
assertEquals(myMockableAndroidJar, Iterables.getLast(pathList));
assertThat(pathList).containsNoneOf(jar15, jar22);
}
Aggregations