当前位置: 首页>>代码示例>>Java>>正文


Java CommandLineBuilder类代码示例

本文整理汇总了Java中com.intellij.execution.configurations.CommandLineBuilder的典型用法代码示例。如果您正苦于以下问题:Java CommandLineBuilder类的具体用法?Java CommandLineBuilder怎么用?Java CommandLineBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CommandLineBuilder类属于com.intellij.execution.configurations包,在下文中一共展示了CommandLineBuilder类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import com.intellij.execution.configurations.CommandLineBuilder; //导入依赖的package包/类
public boolean execute(final ProgressIndicator indicator) {
  displayProgress();

  try {
    if (myParameterCreationError != null) {
      throw myParameterCreationError;
    }

    myProcessHandler =
      new OSProcessHandler(CommandLineBuilder.createFromJavaParameters(myJavaParameters)) {
        @Override
        public void notifyTextAvailable(String text, Key outputType) {
          // todo move this logic to ConsoleAdapter class
          if (!myConsole.isSuppressed(text)) {
            super.notifyTextAvailable(text, outputType);
          }
          updateProgress(indicator, text);
        }
      };

    myConsole.attachToProcess(myProcessHandler);
  }
  catch (ExecutionException e) {
    myConsole.systemMessage(MavenServerConsole.LEVEL_FATAL, RunnerBundle.message("external.startup.failed", e.getMessage()), null);
    return false;
  }

  start();
  readProcessOutput();
  stop();

  return printExitSummary();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:MavenExternalExecutor.java

示例2: DefaultJavaProcessHandler

import com.intellij.execution.configurations.CommandLineBuilder; //导入依赖的package包/类
public DefaultJavaProcessHandler(@NotNull JavaParameters javaParameters) throws ExecutionException {
  super(CommandLineBuilder.createFromJavaParameters(javaParameters));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:DefaultJavaProcessHandler.java

示例3: startUploadingProcess

import com.intellij.execution.configurations.CommandLineBuilder; //导入依赖的package包/类
private void startUploadingProcess() {
  final Process process;
  final GeneralCommandLine commandLine;

  try {
    JavaParameters parameters = new JavaParameters();
    parameters.configureByModule(myAppEngineFacet.getModule(), JavaParameters.JDK_ONLY);
    parameters.setMainClass("com.google.appengine.tools.admin.AppCfg");
    parameters.getClassPath().add(mySdk.getToolsApiJarFile().getAbsolutePath());

    final List<KeyValue<String,String>> list = HttpConfigurable.getJvmPropertiesList(false, null);
    if (! list.isEmpty()) {
      final ParametersList parametersList = parameters.getVMParametersList();
      for (KeyValue<String, String> value : list) {
        parametersList.defineProperty(value.getKey(), value.getValue());
      }
    }

    final ParametersList programParameters = parameters.getProgramParametersList();
    if (myAuthData.isOAuth2()) {
      programParameters.add("--oauth2");
    }
    else {
      programParameters.add("--email=" + myAuthData.getEmail());
      programParameters.add("--passin");
      programParameters.add("--no_cookies");
    }
    programParameters.add("update");
    programParameters.add(FileUtil.toSystemDependentName(myArtifact.getOutputPath()));

    commandLine = CommandLineBuilder.createFromJavaParameters(parameters);
    process = commandLine.createProcess();
  }
  catch (ExecutionException e) {
    myCallback.errorOccurred("Cannot start uploading: " + e.getMessage());
    return;
  }

  final ProcessHandler processHandler = new OSProcessHandler(process, commandLine.getCommandLineString());
  processHandler.addProcessListener(new MyProcessListener(processHandler, null, myLoggingHandler));
  myLoggingHandler.attachToProcess(processHandler);
  processHandler.startNotify();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:AppEngineUploader.java

示例4: compile

import com.intellij.execution.configurations.CommandLineBuilder; //导入依赖的package包/类
@NotNull
public static Map<CompilerMessageCategory, List<JFlexMessage>> compile(VirtualFile file, Sdk projectSdk) throws IOException, CantRunException {

    JFlexSettings settings = JFlexSettings.getInstance();

    //Earlier code used jflex.bat or jflex.sh. These files are broken after IDEA went open-source and changed
    //its sdk distribution structure. It's better to call JFlex.Main directly, not using any dumb bat or sh files.
    JavaParameters javaParameters = new JavaParameters();
    javaParameters.setJdk(projectSdk);
    javaParameters.setMainClass(JFLEX_MAIN_CLASS);
    javaParameters.getClassPath().add(JFLEX_JAR_PATH);

    StringBuilder command = new StringBuilder(CommandLineBuilder.createFromJavaParameters(javaParameters).getCommandLineString());

    //That options stuff can be refactored using javaParameters.getProgramParametersList().add(anOption),
    //as it does auto-quoting if necessary.
    String options = MessageFormat.format(" {0} ", settings.COMMAND_LINE_OPTIONS);
    if (!StringUtil.isEmptyOrSpaces(options)) {
        command.append(options);
    }
    if (!StringUtil.isEmptyOrSpaces(settings.SKELETON_PATH) && options.indexOf(OPTION_SKEL) == -1) {
        command.append(OPTION_SKEL).append(QUOT).append(settings.SKELETON_PATH).append(QUOT);
    }
    if (options.indexOf(OPTION_Q) == -1 && options.indexOf(OPTION_QUIET) == -1) {
        command.append(OPTION_QUIET);
    }
    VirtualFile parent = file.getParent();
    if (parent != null) {
        command.append(OPTION_D).append(QUOT).append(parent.getPath()).append(QUOT);
    }
    command.append(SPACE).append(QUOT).append(file.getPath()).append(QUOT);

    String shell = SystemInfo.isWindows ? SystemInfo.isWindows9x ? COMMAND_COM : CMD_EXE : BIN_BASH;
    String[] commands;
    if (SystemInfo.isWindows) {
        commands = new  String[]{shell, SLASH_C, QUOT + command.toString() + QUOT};
    } else {
        commands = new  String[]{shell, HYPHEN_C, command.toString()};
    }
    Process process = Runtime.getRuntime().exec(commands, null, new File(settings.JFLEX_HOME));
    try {
        InputStream out = process.getInputStream();
        try {
            InputStream err = process.getErrorStream();
            try {
                List<JFlexMessage> information = new ArrayList<JFlexMessage>();
                List<JFlexMessage> error = new ArrayList<JFlexMessage>();
                filter(StreamUtil.readText(out), information, error);
                filter(StreamUtil.readText(err), information, error);
                Map<CompilerMessageCategory, List<JFlexMessage>> messages = new HashMap<CompilerMessageCategory, List<JFlexMessage>>();
                messages.put(CompilerMessageCategory.ERROR, error);
                messages.put(CompilerMessageCategory.INFORMATION, information);
                int code = 0;
                try {
                    code = process.waitFor();
                } catch (InterruptedException e) {
                    List<JFlexMessage> warnings = new ArrayList<JFlexMessage>();
                    warnings.add(new JFlexMessage("Interrupted while waiting for Jflex to complete"));
                    messages.put(CompilerMessageCategory.WARNING, warnings);
                }
                if (code == 0) {
                    return messages;
                } else {
                    if (messages.get(CompilerMessageCategory.ERROR).size() > 0) {
                        return messages;
                    }
                    throw new IOException(JFlexBundle.message("command.0.execution.failed.with.exit.code.1", command, code));
                }
            } finally {
                err.close();
            }
        } finally {
            out.close();
        }
    } finally {
        process.destroy();
    }
}
 
开发者ID:jflex-de,项目名称:idea-jflex,代码行数:79,代码来源:JFlex.java

示例5: DefaultJavaProcessHandler

import com.intellij.execution.configurations.CommandLineBuilder; //导入依赖的package包/类
public DefaultJavaProcessHandler(final JavaParameters javaParameters) throws ExecutionException {
  this(CommandLineBuilder.createFromJavaParameters(javaParameters));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:4,代码来源:DefaultJavaProcessHandler.java

示例6: startUploadingProcess

import com.intellij.execution.configurations.CommandLineBuilder; //导入依赖的package包/类
private void startUploadingProcess() {
  final Process process;
  final GeneralCommandLine commandLine;

  try {
    JavaParameters parameters = new JavaParameters();
    parameters.configureByModule(myAppEngineFacet.getModule(), JavaParameters.JDK_ONLY);
    parameters.setMainClass("com.google.appengine.tools.admin.AppCfg");
    parameters.getClassPath().add(mySdk.getToolsApiJarFile().getAbsolutePath());

    final List<KeyValue<String,String>> list = HttpConfigurable.getJvmPropertiesList(false, null);
    if (! list.isEmpty()) {
      final ParametersList parametersList = parameters.getVMParametersList();
      for (KeyValue<String, String> value : list) {
        parametersList.defineProperty(value.getKey(), value.getValue());
      }
    }

    final ParametersList programParameters = parameters.getProgramParametersList();
    programParameters.add("--email=" + myEmail);
    programParameters.add("update");
    programParameters.add(FileUtil.toSystemDependentName(myArtifact.getOutputPath()));

    commandLine = CommandLineBuilder.createFromJavaParameters(parameters);
    process = commandLine.createProcess();
  }
  catch (ExecutionException e) {
    Messages.showErrorDialog(myProject, "Cannot start uploading: " + e.getMessage(), CommonBundle.getErrorTitle());
    return;
  }

  final Executor executor = DefaultRunExecutor.getRunExecutorInstance();
  final ConsoleView console = TextConsoleBuilderFactory.getInstance().createBuilder(myProject).getConsole();
  final RunnerLayoutUi ui = RunnerLayoutUi.Factory.getInstance(myProject).create("Upload", "Upload Application", "Upload Application", myProject);
  final DefaultActionGroup group = new DefaultActionGroup();
  ui.getOptions().setLeftToolbar(group, ActionPlaces.UNKNOWN);
  ui.addContent(ui.createContent("upload", console.getComponent(), "Upload Application", null, console.getPreferredFocusableComponent()));

  final ProcessHandler processHandler = new OSProcessHandler(process, commandLine.getCommandLineString());
  processHandler.addProcessListener(new MyProcessListener(processHandler, console));
  console.attachToProcess(processHandler);
  final RunContentDescriptor contentDescriptor = new RunContentDescriptor(console, processHandler, ui.getComponent(), "Upload Application");
  group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_STOP_PROGRAM));
  group.add(new CloseAction(executor, contentDescriptor, myProject));

  ExecutionManager.getInstance(myProject).getContentManager().showRunContent(executor, contentDescriptor);
  processHandler.startNotify();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:49,代码来源:AppEngineUploader.java


注:本文中的com.intellij.execution.configurations.CommandLineBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。