示例#1
0
  private String createDiagnosticsMessage(
      String trailingMessage, GradleExecutionResult gradleExecutionResult) {
    String lineBreak = SystemProperties.getInstance().getLineSeparator();
    StringBuilder message = new StringBuilder();
    message.append(trailingMessage);
    message.append(" in ");
    message.append(getProjectDir().getAbsolutePath());
    message.append(" with arguments ");
    message.append(getArguments());
    message.append(lineBreak).append(lineBreak);
    message.append("Output:");
    message.append(lineBreak);
    message.append(gradleExecutionResult.getStandardOutput());
    message.append(lineBreak);
    message.append(DIAGNOSTICS_MESSAGE_SEPARATOR);
    message.append(lineBreak);
    message.append("Error:");
    message.append(lineBreak);
    message.append(gradleExecutionResult.getStandardError());
    message.append(lineBreak);
    message.append(DIAGNOSTICS_MESSAGE_SEPARATOR);

    if (gradleExecutionResult.getThrowable() != null) {
      message.append(lineBreak);
      message.append("Reason:");
      message.append(lineBreak);
      message.append(determineExceptionMessage(gradleExecutionResult.getThrowable()));
      message.append(lineBreak);
      message.append(DIAGNOSTICS_MESSAGE_SEPARATOR);
    }

    return message.toString();
  }
示例#2
0
  private BuildResult run(Action<GradleExecutionResult> resultVerification) {
    if (projectDirectory == null) {
      throw new InvalidRunnerConfigurationException(
          "Please specify a project directory before executing the build");
    }

    GradleExecutionResult execResult =
        gradleExecutor.run(
            gradleHome, gradleUserHomeDir, projectDirectory, arguments, jvmArguments);

    resultVerification.execute(execResult);

    return new DefaultBuildResult(
        execResult.getStandardOutput(), execResult.getStandardError(), execResult.getTasks());
  }