Java Code Examples for org.gradle.BuildResult#getFailure()

The following examples show how to use org.gradle.BuildResult#getFailure() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExecuteGradleCommandClientProtocol.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * <p>Called when the build is completed. All selected tasks have been executed.</p> <p>We remove our Log4JAppender as well as our task execution listener. Lastly, we report the build
 * results.</p>
 */
public void buildFinished(BuildResult buildResult) {

    boolean wasSuccessful = buildResult.getFailure() == null;
    String output = allOutputText.toString();
    liveOutputTimer.cancel();  //stop our timer and send whatever live output we have
    sendLiveOutput();

    //we can't send the exception itself because it might not be serializable (it can include anything from anywhere inside gradle
    //or one of its dependencies). So format it as text.
    String details = GradlePluginLord.getGradleExceptionMessage(buildResult.getFailure(), gradle.getStartParameter().getShowStacktrace());
    output += details;

    client.sendMessage(ProtocolConstants.EXECUTION_COMPLETED_TYPE, output, wasSuccessful);

    client.sendMessage(ProtocolConstants.EXITING, null, null);
    client.stop();
}
 
Example 2
Source File: ExecuteGradleCommandClientProtocol.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * <p>Called when the build is completed. All selected tasks have been executed.</p> <p>We remove our Log4JAppender as well as our task execution listener. Lastly, we report the build
 * results.</p>
 */
public void buildFinished(BuildResult buildResult) {

    boolean wasSuccessful = buildResult.getFailure() == null;
    String output = allOutputText.toString();
    liveOutputTimer.cancel();  //stop our timer and send whatever live output we have
    sendLiveOutput();

    //we can't send the exception itself because it might not be serializable (it can include anything from anywhere inside gradle
    //or one of its dependencies). So format it as text.
    String details = GradlePluginLord.getGradleExceptionMessage(buildResult.getFailure(), gradle.getStartParameter().getShowStacktrace());
    output += details;

    client.sendMessage(ProtocolConstants.EXECUTION_COMPLETED_TYPE, output, wasSuccessful);

    client.sendMessage(ProtocolConstants.EXITING, null, null);
    client.stop();
}
 
Example 3
Source File: ExecuteGradleCommandClientProtocol.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * <p>Called when the build is completed. All selected tasks have been executed.</p> <p>We remove our Log4JAppender as well as our task execution listener. Lastly, we report the build
 * results.</p>
 */
public void buildFinished(BuildResult buildResult) {

    boolean wasSuccessful = buildResult.getFailure() == null;
    String output = allOutputText.toString();
    liveOutputTimer.cancel();  //stop our timer and send whatever live output we have
    sendLiveOutput();

    //we can't send the exception itself because it might not be serializable (it can include anything from anywhere inside gradle
    //or one of its dependencies). So format it as text.
    String details = GradlePluginLord.getGradleExceptionMessage(buildResult.getFailure(), gradle.getStartParameter().getShowStacktrace());
    output += details;

    client.sendMessage(ProtocolConstants.EXECUTION_COMPLETED_TYPE, output, wasSuccessful);

    client.sendMessage(ProtocolConstants.EXITING, null, null);
    client.stop();
}
 
Example 4
Source File: ExecuteGradleCommandClientProtocol.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * <p>Called when the build is completed. All selected tasks have been executed.</p> <p>We remove our Log4JAppender as well as our task execution listener. Lastly, we report the build
 * results.</p>
 */
public void buildFinished(BuildResult buildResult) {

    boolean wasSuccessful = buildResult.getFailure() == null;
    String output = allOutputText.toString();
    liveOutputTimer.cancel();  //stop our timer and send whatever live output we have
    sendLiveOutput();

    //we can't send the exception itself because it might not be serializable (it can include anything from anywhere inside gradle
    //or one of its dependencies). So format it as text.
    String details = GradlePluginLord.getGradleExceptionMessage(buildResult.getFailure(), gradle.getStartParameter().getShowStacktrace());
    output += details;

    client.sendMessage(ProtocolConstants.EXECUTION_COMPLETED_TYPE, output, wasSuccessful);

    client.sendMessage(ProtocolConstants.EXITING, null, null);
    client.stop();
}
 
Example 5
Source File: GradleBuildMetricsCollector.java    From gradle-metrics-plugin with Apache License 2.0 6 votes vote down vote up
public void buildFinishedClosure(BuildResult buildResult) {
    Throwable failure = buildResult.getFailure();
    Result result = failure == null ? Result.success() : Result.failure(failure);
    logger.info("Build finished with result " + result);
    MetricsDispatcher dispatcher = dispatcherSupplier.get();
    dispatcher.result(result);

    Map<String,Object> infoBrokerPluginReports = getNebulaInfoBrokerPluginReports(buildResult.getGradle().getRootProject());
    if (infoBrokerPluginReports != null) {
        for (Map.Entry<String, Object> report : infoBrokerPluginReports.entrySet()) {
            dispatcher.report(report.getKey(), report.getValue());
        }
    }

    buildResultComplete.getAndSet(true);
    shutdownIfComplete();
}
 
Example 6
Source File: InProcessBuildActionExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private GradleInternal check(BuildResult buildResult) {
    state = State.Completed;
    if (buildResult.getFailure() != null) {
        throw new ReportedException(buildResult.getFailure());
    }
    return (GradleInternal) buildResult.getGradle();
}
 
Example 7
Source File: TaskListClientProtocol.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * <p>Called when the build is completed. All selected tasks have been executed.</p>
 *
 * @param buildResult The result of the build. Never null.
 */
@Override
public void buildFinished(BuildResult buildResult) {
    boolean wasSuccessful = buildResult.getFailure() == null;
    String output = allOutputText.toString();

    if (!wasSuccessful) //if we fail, send the results, otherwise, we'll send the projects.
    {
        //we can't send the exception itself because it might not be serializable (it can include anything from anywhere inside gradle
        //or one of its dependencies). So format it as text.
        String details = GradlePluginLord.getGradleExceptionMessage(buildResult.getFailure(), gradle.getStartParameter().getShowStacktrace());
        output += details;

        client.sendMessage(ProtocolConstants.TASK_LIST_COMPLETED_WITH_ERRORS_TYPE, output, wasSuccessful);
    } else {
        ProjectConverter buildExecuter = new ProjectConverter();
        List<ProjectView> projects = new ArrayList<ProjectView>();
        projects.addAll(buildExecuter.convertProjects(buildResult.getGradle().getRootProject()));

        client.sendMessage(ProtocolConstants.TASK_LIST_COMPLETED_SUCCESSFULLY_TYPE, output, (Serializable) projects);
    }

    //tell the server we're going to exit.
    client.sendMessage(ProtocolConstants.EXITING, null, null);

    client.stop();
}
 
Example 8
Source File: TaskListClientProtocol.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * <p>Called when the build is completed. All selected tasks have been executed.</p>
 *
 * @param buildResult The result of the build. Never null.
 */
@Override
public void buildFinished(BuildResult buildResult) {
    boolean wasSuccessful = buildResult.getFailure() == null;
    String output = allOutputText.toString();

    if (!wasSuccessful) //if we fail, send the results, otherwise, we'll send the projects.
    {
        //we can't send the exception itself because it might not be serializable (it can include anything from anywhere inside gradle
        //or one of its dependencies). So format it as text.
        String details = GradlePluginLord.getGradleExceptionMessage(buildResult.getFailure(), gradle.getStartParameter().getShowStacktrace());
        output += details;

        client.sendMessage(ProtocolConstants.TASK_LIST_COMPLETED_WITH_ERRORS_TYPE, output, wasSuccessful);
    } else {
        ProjectConverter buildExecuter = new ProjectConverter();
        List<ProjectView> projects = new ArrayList<ProjectView>();
        projects.addAll(buildExecuter.convertProjects(buildResult.getGradle().getRootProject()));

        client.sendMessage(ProtocolConstants.TASK_LIST_COMPLETED_SUCCESSFULLY_TYPE, output, (Serializable) projects);
    }

    //tell the server we're going to exit.
    client.sendMessage(ProtocolConstants.EXITING, null, null);

    client.stop();
}
 
Example 9
Source File: InProcessBuildActionExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private GradleInternal check(BuildResult buildResult) {
    state = State.Completed;
    if (buildResult.getFailure() != null) {
        throw new ReportedException(buildResult.getFailure());
    }
    return (GradleInternal) buildResult.getGradle();
}
 
Example 10
Source File: TaskListClientProtocol.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * <p>Called when the build is completed. All selected tasks have been executed.</p>
 *
 * @param buildResult The result of the build. Never null.
 */
@Override
public void buildFinished(BuildResult buildResult) {
    boolean wasSuccessful = buildResult.getFailure() == null;
    String output = allOutputText.toString();

    if (!wasSuccessful) //if we fail, send the results, otherwise, we'll send the projects.
    {
        //we can't send the exception itself because it might not be serializable (it can include anything from anywhere inside gradle
        //or one of its dependencies). So format it as text.
        String details = GradlePluginLord.getGradleExceptionMessage(buildResult.getFailure(), gradle.getStartParameter().getShowStacktrace());
        output += details;

        client.sendMessage(ProtocolConstants.TASK_LIST_COMPLETED_WITH_ERRORS_TYPE, output, wasSuccessful);
    } else {
        ProjectConverter buildExecuter = new ProjectConverter();
        List<ProjectView> projects = new ArrayList<ProjectView>();
        projects.addAll(buildExecuter.convertProjects(buildResult.getGradle().getRootProject()));

        client.sendMessage(ProtocolConstants.TASK_LIST_COMPLETED_SUCCESSFULLY_TYPE, output, (Serializable) projects);
    }

    //tell the server we're going to exit.
    client.sendMessage(ProtocolConstants.EXITING, null, null);

    client.stop();
}
 
Example 11
Source File: TaskListClientProtocol.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * <p>Called when the build is completed. All selected tasks have been executed.</p>
 *
 * @param buildResult The result of the build. Never null.
 */
@Override
public void buildFinished(BuildResult buildResult) {
    boolean wasSuccessful = buildResult.getFailure() == null;
    String output = allOutputText.toString();

    if (!wasSuccessful) //if we fail, send the results, otherwise, we'll send the projects.
    {
        //we can't send the exception itself because it might not be serializable (it can include anything from anywhere inside gradle
        //or one of its dependencies). So format it as text.
        String details = GradlePluginLord.getGradleExceptionMessage(buildResult.getFailure(), gradle.getStartParameter().getShowStacktrace());
        output += details;

        client.sendMessage(ProtocolConstants.TASK_LIST_COMPLETED_WITH_ERRORS_TYPE, output, wasSuccessful);
    } else {
        ProjectConverter buildExecuter = new ProjectConverter();
        List<ProjectView> projects = new ArrayList<ProjectView>();
        projects.addAll(buildExecuter.convertProjects(buildResult.getGradle().getRootProject()));

        client.sendMessage(ProtocolConstants.TASK_LIST_COMPLETED_SUCCESSFULLY_TYPE, output, (Serializable) projects);
    }

    //tell the server we're going to exit.
    client.sendMessage(ProtocolConstants.EXITING, null, null);

    client.stop();
}
 
Example 12
Source File: InProcessBuildActionExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void check(BuildResult buildResult) {
    if (buildResult.getFailure() != null) {
        throw new ReportedException(buildResult.getFailure());
    }
}
 
Example 13
Source File: InProcessBuildActionExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void check(BuildResult buildResult) {
    if (buildResult.getFailure() != null) {
        throw new ReportedException(buildResult.getFailure());
    }
}