Beispiel #1
0
  /**
   * This executes a task in a background thread. This creates or uses an existing OutputPanel to
   * display the results.
   *
   * @param task the task to execute.
   * @param forceOutputToBeShown overrides the user setting onlyShowOutputOnErrors so that the
   *     output is shown regardless
   */
  public Request addExecutionRequestToQueue(
      final TaskView task, boolean forceOutputToBeShown, String... additionCommandLineOptions) {
    if (task == null) {
      return null;
    }

    String fullCommandLine =
        CommandLineAssistant.appendAdditionalCommandLineOptions(task, additionCommandLineOptions);
    return addExecutionRequestToQueue(
        fullCommandLine, task.getFullTaskName(), forceOutputToBeShown);
  }
  /**
   * Fill in the ExecutionInfo object with information needed to execute the other process.
   *
   * @param serverPort the port the server is listening on. The client should send messages here
   * @return an executionInfo object containing information about what we execute.
   */
  public ExecutionInfo getExecutionInfo(int serverPort) {
    MyExecutionInfo executionInfo = new MyExecutionInfo();

    // set some environment variables that need to be passed to the script.
    executionInfo.addEnvironmentVariable("GRADLE_HOME", getGradleHomeDirectory().getAbsolutePath());
    executionInfo.addEnvironmentVariable("JAVA_HOME", System.getProperty("java.home"));

    executionInfo.setWorkingDirectory(currentDirectory);

    List<String> executionCommandLine = new ArrayList<String>();

    // put the file to execute on the command line
    File gradleExecutableFile = getGradleExecutableFile();
    executionCommandLine.add(gradleExecutableFile.getAbsolutePath());

    // add the port number we're listenening on
    executionCommandLine.add(
        "-D" + ProtocolConstants.PORT_NUMBER_SYSTEM_PROPERTY + "=" + Integer.toString(serverPort));

    CommandLineAssistant commandLineAssistant = new CommandLineAssistant();

    // add whatever the user ran
    String[] individualCommandLineArguments = commandLineAssistant.breakUpCommandLine(commandLine);
    executionCommandLine.addAll(Arrays.asList(individualCommandLineArguments));

    File initStriptPath = getInitScriptFile();
    if (initStriptPath != null) {
      executionCommandLine.add("-" + DefaultCommandLine2StartParameterConverter.INIT_SCRIPT);
      executionCommandLine.add(initStriptPath.getAbsolutePath());
      executionInfo.initStriptPath = initStriptPath;
    }

    // add the log level if its not present
    if (!commandLineAssistant.hasLogLevelDefined(individualCommandLineArguments)) {
      String logLevelText =
          commandLineAssistant
              .getCommandLine2StartParameterConverter()
              .getLogLevelCommandLine(logLevel);
      if (logLevelText != null && !"".equals(logLevelText)) {
        executionCommandLine.add('-' + logLevelText);
      }
    }

    // add the stack trace level if its not present
    if (!commandLineAssistant.hasShowStacktraceDefined(individualCommandLineArguments)) {
      String stackTraceLevelText =
          commandLineAssistant
              .getCommandLine2StartParameterConverter()
              .getShowStacktraceCommandLine(stackTraceLevel);
      if (stackTraceLevelText != null) {
        executionCommandLine.add('-' + stackTraceLevelText);
      }
    }

    executionInfo.setCommandLineArguments(
        executionCommandLine.toArray(new String[executionCommandLine.size()]));
    return executionInfo;
  }
Beispiel #3
0
  /**
   * This executes all the tasks together in a background thread. That is, all tasks are passed to a
   * single gradle call at once. This creates or uses an existing OutputPanel to display the
   * results.
   *
   * @param tasks the tasks to execute
   * @param forceOutputToBeShown overrides the user setting onlyShowOutputOnErrors so that the
   *     output is shown regardless
   * @param additionCommandLineOptions additional command line options to exeucte.
   */
  public Request addExecutionRequestToQueue(
      final List<TaskView> tasks,
      boolean forceOutputToBeShown,
      String... additionCommandLineOptions) {

    if (tasks == null || tasks.isEmpty()) {
      return null;
    }

    if (tasks.size() == 1) { // if there's only 1, just treat it as one
      return addExecutionRequestToQueue(
          tasks.get(0), forceOutputToBeShown, additionCommandLineOptions);
    }

    String singleCommandLine = CommandLineAssistant.combineTasks(tasks, additionCommandLineOptions);
    return addExecutionRequestToQueue(
        singleCommandLine, tasks.get(0).getName() + "...", forceOutputToBeShown);
  }