Search in sources :

Example 11 with ParametersList

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

the class ParametersListTest method paramsGroupSubGroups.

@Test
public void paramsGroupSubGroups() {
    ParametersList params = new ParametersList();
    ParamsGroup group1 = params.addParamsGroup("id1");
    group1.addParameter("group1_param1");
    group1.addParameter("group1_param2");
    ParamsGroup group2 = params.addParamsGroup("id2");
    group2.addParameter("group2_param1");
    ParamsGroup group1_1 = group1.getParametersList().addParamsGroup("id1_1");
    group1_1.addParameter("group1_1_param1");
    ParamsGroup group1_2 = group1.getParametersList().addParamsGroup("id1_2");
    group1_2.addParameter("group1_2_param1");
    assertEquals(asList("group1_param1", "group1_param2", "group1_1_param1", "group1_2_param1", "group2_param1"), params.getList());
    assertEquals(asList("group1_param1", "group1_param2", "group1_1_param1", "group1_2_param1", "group2_param1"), params.getList());
    assertEquals("group1_param1 group1_param2 group1_1_param1 group1_2_param1 group2_param1", params.getParametersString().trim());
}
Also used : ParamsGroup(com.intellij.execution.configurations.ParamsGroup) ParametersList(com.intellij.execution.configurations.ParametersList) Test(org.junit.Test)

Example 12 with ParametersList

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

the class ParametersListTest method properties.

@Test
public void properties() {
    ParametersList params = new ParametersList();
    params.addProperty("foo.foo", "\"bar bar\" bar");
    assertEquals(1, params.getProperties().size());
    assertEquals("\"bar bar\" bar", params.getProperties().get("foo.foo"));
}
Also used : ParametersList(com.intellij.execution.configurations.ParametersList) Test(org.junit.Test)

Example 13 with ParametersList

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

the class ParametersListTest method joiningParams.

@Test
public void joiningParams() {
    String[] parameters = { "simpleParam", "param with spaces", "withQuote=\"", "param=\"complex quoted\"", "C:\\\"q\"", "C:\\w s\\" };
    ParametersList parametersList = new ParametersList();
    parametersList.addAll(parameters);
    String joined = parametersList.getParametersString();
    assertEquals("simpleParam \"param with spaces\" withQuote=\\\" \"param=\\\"complex quoted\\\"\" C:\\\\\"q\\\" \"C:\\w s\"\\", joined);
    checkTokenizer(joined, parameters);
}
Also used : ParametersList(com.intellij.execution.configurations.ParametersList) Test(org.junit.Test)

Example 14 with ParametersList

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

the class ParametersListTest method paramsGroupEmpty.

@Test
public void paramsGroupEmpty() {
    ParametersList params = new ParametersList();
    assertEquals(0, params.getParamsGroupsCount());
    assertTrue(params.getParamsGroups().isEmpty());
}
Also used : ParametersList(com.intellij.execution.configurations.ParametersList) Test(org.junit.Test)

Example 15 with ParametersList

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

the class AntCommandLineBuilder method setBuildFile.

public void setBuildFile(AbstractProperty.AbstractPropertyContainer container, File buildFile) throws CantRunException {
    String jdkName = AntBuildFileImpl.CUSTOM_JDK_NAME.get(container);
    Sdk jdk;
    if (jdkName != null && jdkName.length() > 0) {
        jdk = GlobalAntConfiguration.findJdk(jdkName);
    } else {
        jdkName = AntConfigurationImpl.DEFAULT_JDK_NAME.get(container);
        if (jdkName == null || jdkName.length() == 0) {
            throw new CantRunException(AntBundle.message("project.jdk.not.specified.error.message"));
        }
        jdk = GlobalAntConfiguration.findJdk(jdkName);
    }
    if (jdk == null) {
        throw new CantRunException(AntBundle.message("jdk.with.name.not.configured.error.message", jdkName));
    }
    VirtualFile homeDirectory = jdk.getHomeDirectory();
    if (homeDirectory == null) {
        throw new CantRunException(AntBundle.message("jdk.with.name.bad.configured.error.message", jdkName));
    }
    myCommandLine.setJdk(jdk);
    final ParametersList vmParametersList = myCommandLine.getVMParametersList();
    vmParametersList.add("-Xmx" + AntBuildFileImpl.MAX_HEAP_SIZE.get(container) + "m");
    vmParametersList.add("-Xss" + AntBuildFileImpl.MAX_STACK_SIZE.get(container) + "m");
    final AntInstallation antInstallation = AntBuildFileImpl.ANT_INSTALLATION.get(container);
    if (antInstallation == null) {
        throw new CantRunException(AntBundle.message("ant.installation.not.configured.error.message"));
    }
    final String antHome = AntInstallation.HOME_DIR.get(antInstallation.getProperties());
    vmParametersList.add("-Dant.home=" + antHome);
    final String libraryDir = antHome + (antHome.endsWith("/") || antHome.endsWith(File.separator) ? "" : File.separator) + "lib";
    vmParametersList.add("-Dant.library.dir=" + libraryDir);
    String[] urls = jdk.getRootProvider().getUrls(OrderRootType.CLASSES);
    final String jdkHome = homeDirectory.getPath().replace('/', File.separatorChar);
    @NonNls final String pathToJre = jdkHome + File.separator + "jre" + File.separator;
    for (String url : urls) {
        final String path = PathUtil.toPresentableUrl(url);
        if (!path.startsWith(pathToJre)) {
            myCommandLine.getClassPath().add(path);
        }
    }
    myCommandLine.getClassPath().addAllFiles(AntBuildFileImpl.ALL_CLASS_PATH.get(container));
    myCommandLine.getClassPath().addAllFiles(AntBuildFileImpl.getUserHomeLibraries());
    final SdkTypeId sdkType = jdk.getSdkType();
    if (sdkType instanceof JavaSdkType) {
        final String toolsJar = ((JavaSdkType) sdkType).getToolsPath(jdk);
        if (toolsJar != null) {
            myCommandLine.getClassPath().add(toolsJar);
        }
    }
    PathUtilEx.addRtJar(myCommandLine.getClassPath());
    myCommandLine.setMainClass(AntMain2.class.getName());
    final ParametersList programParameters = myCommandLine.getProgramParametersList();
    final String additionalParams = AntBuildFileImpl.ANT_COMMAND_LINE_PARAMETERS.get(container);
    if (additionalParams != null) {
        for (String param : ParametersList.parse(additionalParams)) {
            if (param.startsWith("-J")) {
                final String cutParam = param.substring("-J".length());
                if (cutParam.length() > 0) {
                    vmParametersList.add(cutParam);
                }
            } else {
                programParameters.add(param);
            }
        }
    }
    if (!(programParameters.getList().contains(LOGGER_PARAMETER))) {
        programParameters.add(LOGGER_PARAMETER, IdeaAntLogger2.class.getName());
    }
    if (!programParameters.getList().contains(INPUT_HANDLER_PARAMETER)) {
        programParameters.add(INPUT_HANDLER_PARAMETER, IdeaInputHandler.class.getName());
    }
    myProperties = AntBuildFileImpl.ANT_PROPERTIES.get(container);
    myBuildFilePath = buildFile.getAbsolutePath();
    myCommandLine.setWorkingDirectory(buildFile.getParent());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) NonNls(org.jetbrains.annotations.NonNls) IdeaInputHandler(com.intellij.rt.ant.execution.IdeaInputHandler) AntMain2(com.intellij.rt.ant.execution.AntMain2) JavaSdkType(com.intellij.openapi.projectRoots.JavaSdkType) CantRunException(com.intellij.execution.CantRunException) IdeaAntLogger2(com.intellij.rt.ant.execution.IdeaAntLogger2) ParametersList(com.intellij.execution.configurations.ParametersList) Sdk(com.intellij.openapi.projectRoots.Sdk) SdkTypeId(com.intellij.openapi.projectRoots.SdkTypeId)

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