use of com.intellij.util.PathsList in project intellij-community by JetBrains.
the class JdkUtil method appendParamsEncodingClasspath.
private static void appendParamsEncodingClasspath(SimpleJavaParameters javaParameters, GeneralCommandLine commandLine, ParametersList vmParameters) {
commandLine.addParameters(vmParameters.getList());
appendEncoding(javaParameters, commandLine, vmParameters);
PathsList classPath = javaParameters.getClassPath();
if (!classPath.isEmpty() && !explicitClassPath(vmParameters)) {
commandLine.addParameter("-classpath");
commandLine.addParameter(classPath.getPathsString());
}
PathsList modulePath = javaParameters.getModulePath();
if (!modulePath.isEmpty() && !explicitModulePath(vmParameters)) {
commandLine.addParameter("-p");
commandLine.addParameter(modulePath.getPathsString());
}
}
use of com.intellij.util.PathsList in project android by JetBrains.
the class AndroidGradleProjectResolver method enhanceRemoteProcessing.
@Override
public void enhanceRemoteProcessing(@NotNull SimpleJavaParameters parameters) {
PathsList classPath = parameters.getClassPath();
classPath.add(getJarPathForClass(getClass()));
classPath.add(getJarPathForClass(Revision.class));
classPath.add(getJarPathForClass(AndroidGradleSettings.class));
classPath.add(getJarPathForClass(AndroidProject.class));
}
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);
}
use of com.intellij.util.PathsList in project intellij-community by JetBrains.
the class PathListBuilderTest method testOrder.
@Test
public void testOrder() {
PathsList builder = new PathsList();
builder.add("a");
builder.addFirst("2");
builder.addTail("A");
builder.addFirst("1");
builder.add("b");
builder.addTail("B");
assertThat(builder.getPathList()).containsExactly("1", "2", "a", "b", "A", "B");
}
Aggregations