Search in sources :

Example 21 with ParametersList

use of com.intellij.execution.configurations.ParametersList in project intellij-plugins by JetBrains.

the class FelixRunner method setupParameters.

/**
   * See <a href="http://felix.apache.org/site/apache-felix-framework-configuration-properties.html">Felix Configuration Properties</a>.
   */
@Override
protected void setupParameters(@NotNull JavaParameters parameters) {
    ParametersList vmParameters = parameters.getVMParametersList();
    // bundles and start levels
    MultiMap<Integer, String> startBundles = new MultiMap<>();
    List<String> installBundles = ContainerUtil.newSmartList();
    for (SelectedBundle bundle : myBundles) {
        String bundlePath = bundle.getBundlePath();
        if (bundlePath == null)
            continue;
        boolean isFragment = CachingBundleInfoProvider.isFragmentBundle(bundlePath);
        String bundleUrl = toFileUri(bundlePath);
        if (bundle.isStartAfterInstallation() && !isFragment) {
            int startLevel = getBundleStartLevel(bundle);
            startBundles.putValue(startLevel, bundleUrl);
        } else {
            installBundles.add(bundleUrl);
        }
    }
    for (Integer startLevel : startBundles.keySet()) {
        vmParameters.addProperty("felix.auto.start." + startLevel, StringUtil.join(startBundles.get(startLevel), " "));
    }
    if (!installBundles.isEmpty()) {
        vmParameters.addProperty("felix.auto.install.1", StringUtil.join(installBundles, " "));
    }
    int startLevel = getFrameworkStartLevel();
    vmParameters.addProperty("org.osgi.framework.startlevel.beginning", String.valueOf(startLevel));
    int defaultStartLevel = myRunConfiguration.getDefaultStartLevel();
    vmParameters.addProperty("felix.startlevel.bundle", String.valueOf(defaultStartLevel));
    // framework-specific options
    vmParameters.addProperty("org.osgi.framework.storage.clean", "onFirstInit");
    if (GenericRunProperties.isDebugMode(myAdditionalProperties)) {
        vmParameters.addProperty("felix.log.level", "4");
    }
    parameters.setMainClass(MAIN_CLASS);
}
Also used : MultiMap(com.intellij.util.containers.MultiMap) ParametersList(com.intellij.execution.configurations.ParametersList) SelectedBundle(org.osmorc.run.ui.SelectedBundle)

Example 22 with ParametersList

use of com.intellij.execution.configurations.ParametersList in project intellij-community by JetBrains.

the class ProcessProxyFactoryImpl method createCommandLineProxy.

@Override
public ProcessProxy createCommandLineProxy(JavaCommandLine javaCmdLine) throws ExecutionException {
    JavaParameters javaParameters = javaCmdLine.getJavaParameters();
    String mainClass = javaParameters.getMainClass();
    if (ourMayUseLauncher && mainClass != null) {
        String rtJarPath = JavaSdkUtil.getIdeaRtJarPath();
        boolean runtimeJarFile = new File(rtJarPath).isFile() && FileUtil.isAncestor(PathManager.getHomePath(), rtJarPath, true);
        if (runtimeJarFile || javaParameters.getModuleName() == null) {
            try {
                ProcessProxyImpl proxy = new ProcessProxyImpl(StringUtil.getShortName(mainClass));
                String port = String.valueOf(proxy.getPortNumber());
                String binPath = PathManager.getBinPath();
                if (runtimeJarFile && JavaSdkUtil.isJdkAtLeast(javaParameters.getJdk(), JavaSdkVersion.JDK_1_5)) {
                    javaParameters.getVMParametersList().add("-javaagent:" + rtJarPath + '=' + port + ':' + binPath);
                } else {
                    JavaSdkUtil.addRtJar(javaParameters.getClassPath());
                    ParametersList vmParametersList = javaParameters.getVMParametersList();
                    vmParametersList.defineProperty(AppMainV2.LAUNCHER_PORT_NUMBER, port);
                    vmParametersList.defineProperty(AppMainV2.LAUNCHER_BIN_PATH, binPath);
                    javaParameters.getProgramParametersList().prepend(mainClass);
                    javaParameters.setMainClass(AppMainV2.class.getName());
                }
                return proxy;
            } catch (Exception e) {
                Logger.getInstance(ProcessProxy.class).warn(e);
            }
        }
    }
    return null;
}
Also used : ParametersList(com.intellij.execution.configurations.ParametersList) JavaParameters(com.intellij.execution.configurations.JavaParameters) File(java.io.File) AppMainV2(com.intellij.rt.execution.application.AppMainV2) ExecutionException(com.intellij.execution.ExecutionException)

Example 23 with ParametersList

use of com.intellij.execution.configurations.ParametersList in project intellij-community by JetBrains.

the class JdkUtil method setupCommandLine.

private static void setupCommandLine(GeneralCommandLine commandLine, SimpleJavaParameters javaParameters) throws CantRunException {
    final ParametersList vmParameters = javaParameters.getVMParametersList();
    commandLine.withEnvironment(javaParameters.getEnv());
    commandLine.withParentEnvironmentType(javaParameters.isPassParentEnvs() ? ParentEnvironmentType.CONSOLE : ParentEnvironmentType.NONE);
    final Class commandLineWrapper;
    boolean dynamicParameters = false;
    if (javaParameters.isDynamicClasspath() && !explicitClassPath(vmParameters) && javaParameters.getModulePath().isEmpty() && (commandLineWrapper = getCommandLineWrapperClass()) != null) {
        if (isClassPathJarEnabled(javaParameters, PathUtil.getJarPathForClass(ClassPath.class))) {
            dynamicParameters = setClasspathJarParams(javaParameters, commandLine, vmParameters, commandLineWrapper);
        } else {
            dynamicParameters = setCommandLineWrapperParams(javaParameters, commandLine, vmParameters, commandLineWrapper);
        }
    } else {
        appendParamsEncodingClasspath(javaParameters, commandLine, vmParameters);
    }
    final String mainClass = javaParameters.getMainClass();
    final String moduleName = javaParameters.getModuleName();
    final String jarPath = javaParameters.getJarPath();
    if (moduleName != null && mainClass != null) {
        commandLine.addParameter("-m");
        commandLine.addParameter(moduleName + '/' + mainClass);
    } else if (mainClass != null) {
        commandLine.addParameter(mainClass);
    } else if (jarPath != null) {
        commandLine.addParameter("-jar");
        commandLine.addParameter(jarPath);
    } else {
        throw new CantRunException(ExecutionBundle.message("main.class.is.not.specified.error.message"));
    }
    if (!dynamicParameters) {
        commandLine.addParameters(javaParameters.getProgramParametersList().getList());
    }
    commandLine.withWorkDirectory(javaParameters.getWorkingDirectory());
}
Also used : ClassPath(com.intellij.util.lang.ClassPath) CantRunException(com.intellij.execution.CantRunException) ParametersList(com.intellij.execution.configurations.ParametersList)

Example 24 with ParametersList

use of com.intellij.execution.configurations.ParametersList in project intellij-community by JetBrains.

the class ParametersListTest method paramsGroupGroupParams.

@Test
public void paramsGroupGroupParams() {
    ParametersList params = new ParametersList();
    params.add("param1");
    ParamsGroup group1 = params.addParamsGroup("id1");
    group1.addParameter("group1_param1");
    params.add("param2");
    group1.addParameter("group1_param2");
    ParamsGroup group2 = params.addParamsGroup("id2");
    group2.addParameter("group2_param1");
    params.add("param3");
    assertEquals(asList("param1", "param2", "param3"), params.getParameters());
    assertEquals(asList("param1", "param2", "param3", "group1_param1", "group1_param2", "group2_param1"), params.getList());
    assertArrayEquals(new String[] { "param1", "param2", "param3", "group1_param1", "group1_param2", "group2_param1" }, params.getArray());
    assertEquals("param1 param2 param3 group1_param1 group1_param2 group2_param1", params.getParametersString().trim());
    ParametersList group1_params = group1.getParametersList();
    assertEquals(asList("group1_param1", "group1_param2"), group1_params.getParameters());
    assertEquals(asList("group1_param1", "group1_param2"), group1_params.getList());
    assertArrayEquals(new String[] { "group1_param1", "group1_param2" }, group1_params.getArray());
    assertEquals("group1_param1 group1_param2", group1_params.getParametersString().trim());
    ParametersList group2_params = group2.getParametersList();
    assertEquals(asList("group2_param1"), group2_params.getParameters());
    assertEquals(asList("group2_param1"), group2_params.getList());
    assertArrayEquals(new String[] { "group2_param1" }, group2_params.getArray());
    assertEquals("group2_param1", group2_params.getParametersString().trim());
}
Also used : ParamsGroup(com.intellij.execution.configurations.ParamsGroup) ParametersList(com.intellij.execution.configurations.ParametersList) Test(org.junit.Test)

Example 25 with ParametersList

use of com.intellij.execution.configurations.ParametersList in project intellij-community by JetBrains.

the class ParametersListTest method paramsGroupAddAt.

@Test
public void paramsGroupAddAt() {
    ParametersList params = new ParametersList();
    ParamsGroup group1 = params.addParamsGroup("id1");
    ParamsGroup group2 = params.addParamsGroup("id2");
    ParamsGroup group12 = params.addParamsGroupAt(1, "id12");
    ParamsGroup group01 = params.addParamsGroupAt(0, "id01");
    assertEquals(asList(group01, group1, group12, group2), params.getParamsGroups());
}
Also used : ParamsGroup(com.intellij.execution.configurations.ParamsGroup) ParametersList(com.intellij.execution.configurations.ParametersList) Test(org.junit.Test)

Aggregations

ParametersList (com.intellij.execution.configurations.ParametersList)30 ParamsGroup (com.intellij.execution.configurations.ParamsGroup)9 Test (org.junit.Test)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 File (java.io.File)4 SelectedBundle (org.osmorc.run.ui.SelectedBundle)4 CantRunException (com.intellij.execution.CantRunException)3 Sdk (com.intellij.openapi.projectRoots.Sdk)3 MultiMap (com.intellij.util.containers.MultiMap)3 ExecutionException (com.intellij.execution.ExecutionException)2 JavaParameters (com.intellij.execution.configurations.JavaParameters)2 SimpleJavaParameters (com.intellij.execution.configurations.SimpleJavaParameters)2 JavaSdkType (com.intellij.openapi.projectRoots.JavaSdkType)2 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 JavaProjectData (com.intellij.externalSystem.JavaProjectData)1 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)1 PluginId (com.intellij.openapi.extensions.PluginId)1 DataNode (com.intellij.openapi.externalSystem.model.DataNode)1 Module (com.intellij.openapi.module.Module)1 SdkTypeId (com.intellij.openapi.projectRoots.SdkTypeId)1