Search in sources :

Example 11 with PathsList

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());
    }
}
Also used : PathsList(com.intellij.util.PathsList)

Example 12 with PathsList

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));
}
Also used : PathsList(com.intellij.util.PathsList) Revision(com.android.repository.Revision) AndroidGradleSettings(com.android.tools.idea.gradle.util.AndroidGradleSettings) AndroidProject(com.android.builder.model.AndroidProject) NativeAndroidProject(com.android.builder.model.NativeAndroidProject)

Example 13 with PathsList

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;
}
Also used : BuildToolInfo(com.android.sdklib.BuildToolInfo) HashMap(com.intellij.util.containers.HashMap) AndroidCompilerMessageKind(org.jetbrains.android.util.AndroidCompilerMessageKind) PathsList(com.intellij.util.PathsList) PathsList(com.intellij.util.PathsList) ArrayList(java.util.ArrayList) List(java.util.List) FileUtilRt(com.intellij.openapi.util.io.FileUtilRt) Sdk(com.intellij.openapi.projectRoots.Sdk) ExecutionException(com.intellij.execution.ExecutionException) File(java.io.File)

Example 14 with PathsList

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);
}
Also used : PathsList(com.intellij.util.PathsList)

Example 15 with PathsList

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");
}
Also used : PathsList(com.intellij.util.PathsList) Test(org.junit.Test)

Aggregations

PathsList (com.intellij.util.PathsList)20 Test (org.junit.Test)6 File (java.io.File)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)2 ExecutionException (com.intellij.execution.ExecutionException)2 JavaParameters (com.intellij.execution.configurations.JavaParameters)2 Module (com.intellij.openapi.module.Module)2 Sdk (com.intellij.openapi.projectRoots.Sdk)2 IOException (java.io.IOException)2 AndroidPlatform (org.jetbrains.android.sdk.AndroidPlatform)2 AndroidProject (com.android.builder.model.AndroidProject)1 JavaArtifact (com.android.builder.model.JavaArtifact)1 NativeAndroidProject (com.android.builder.model.NativeAndroidProject)1 Revision (com.android.repository.Revision)1 BuildToolInfo (com.android.sdklib.BuildToolInfo)1 AndroidGradleSettings (com.android.tools.idea.gradle.util.AndroidGradleSettings)1 PsiClassWriter (com.intellij.compiler.PsiClassWriter)1 FileSetCompileScope (com.intellij.compiler.impl.FileSetCompileScope)1 InstrumentationClassFinder (com.intellij.compiler.instrumentation.InstrumentationClassFinder)1