org.gradle.BuildResult Java Examples
The following examples show how to use
org.gradle.BuildResult.
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: GradleBuildMetricsCollector.java From gradle-metrics-plugin with Apache License 2.0 | 6 votes |
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 #2
Source File: ExecuteGradleCommandClientProtocol.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
/** * <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 pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
/** * <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 |
/** * <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: ExecuteGradleCommandClientProtocol.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
/** * <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 #6
Source File: DefaultGradleLauncher.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private BuildResult doBuild(Stage upTo) { loggingManager.start(); buildListener.buildStarted(gradle); Throwable failure = null; try { doBuildStages(upTo); } catch (Throwable t) { failure = exceptionAnalyser.transform(t); } BuildResult buildResult = new BuildResult(gradle, failure); buildListener.buildFinished(buildResult); // Switching Logging off is important if the Gradle factory is used to // run multiple Gradle builds (each one requiring a new instances of GradleLauncher). // Switching it off shouldn't be strictly necessary as StandardOutput capturing should // always be closed. But as we expose this functionality to the builds, we can't // guarantee this. loggingManager.stop(); return buildResult; }
Example #7
Source File: DefaultGradleLauncher.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private BuildResult doBuild(Stage upTo) { loggingManager.start(); buildListener.buildStarted(gradle); Throwable failure = null; try { doBuildStages(upTo); } catch (Throwable t) { failure = exceptionAnalyser.transform(t); } BuildResult buildResult = new BuildResult(gradle, failure); buildListener.buildFinished(buildResult); // Switching Logging off is important if the Gradle factory is used to // run multiple Gradle builds (each one requiring a new instances of GradleLauncher). // Switching it off shouldn't be strictly necessary as StandardOutput capturing should // always be closed. But as we expose this functionality to the builds, we can't // guarantee this. loggingManager.stop(); return buildResult; }
Example #8
Source File: InProcessGradleExecuter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected ExecutionResult doRun() { OutputListenerImpl outputListener = new OutputListenerImpl(); OutputListenerImpl errorListener = new OutputListenerImpl(); BuildListenerImpl buildListener = new BuildListenerImpl(); BuildResult result = doRun(outputListener, errorListener, buildListener); try { result.rethrowFailure(); } catch (Exception e) { throw new UnexpectedBuildFailure(e); } return assertResult(new InProcessExecutionResult(buildListener.executedTasks, buildListener.skippedTasks, new OutputScrapingExecutionResult(outputListener.toString(), errorListener.toString()))); }
Example #9
Source File: GradleBuildMetricsCollector.java From gradle-metrics-plugin with Apache License 2.0 | 5 votes |
@Override public void buildFinished(BuildResult result) { if(buildMetrics != null) { buildMetrics.setBuildFinished(clock.getCurrentTime()); buildFinished(buildMetrics); buildMetrics.setSuccessful(result.getFailure() == null); buildMetrics = null; } }
Example #10
Source File: TaskListClientProtocol.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
/** * <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: DefaultGradleLauncher.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private BuildResult doBuild(Stage upTo) { loggingManager.start(); buildListener.buildStarted(gradle); Throwable failure = null; try { doBuildStages(upTo); } catch (Throwable t) { failure = exceptionAnalyser.transform(t); } BuildResult buildResult = new BuildResult(gradle, failure); buildListener.buildFinished(buildResult); return buildResult; }
Example #12
Source File: ProfileEventAdapter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void buildFinished(BuildResult result) { buildProfile.setBuildFinished(timeProvider.getCurrentTime()); buildProfile.setSuccessful(result.getFailure() == null); try { listener.buildFinished(buildProfile); } finally { buildProfile = null; } }
Example #13
Source File: DrainingBuildListener.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
@Override public void buildFinished(BuildResult result) { try { logger.lifecycle("Draining metrics to Stackdriver."); Thread.sleep(sleepDuration); } catch (InterruptedException e) { // Restore the interrupted status Thread.currentThread().interrupt(); } }
Example #14
Source File: InProcessGradleExecuter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected ExecutionResult doRun() { OutputListenerImpl outputListener = new OutputListenerImpl(); OutputListenerImpl errorListener = new OutputListenerImpl(); BuildListenerImpl buildListener = new BuildListenerImpl(); BuildResult result = doRun(outputListener, errorListener, buildListener); try { result.rethrowFailure(); } catch (Exception e) { throw new UnexpectedBuildFailure(e); } return assertResult(new InProcessExecutionResult(buildListener.executedTasks, buildListener.skippedTasks, new OutputScrapingExecutionResult(outputListener.toString(), errorListener.toString()))); }
Example #15
Source File: InProcessGradleExecuter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected ExecutionResult doRun() { OutputListenerImpl outputListener = new OutputListenerImpl(); OutputListenerImpl errorListener = new OutputListenerImpl(); BuildListenerImpl buildListener = new BuildListenerImpl(); BuildResult result = doRun(outputListener, errorListener, buildListener); try { result.rethrowFailure(); } catch (Exception e) { throw new UnexpectedBuildFailure(e); } return assertResult(new InProcessExecutionResult(buildListener.executedTasks, buildListener.skippedTasks, new OutputScrapingExecutionResult(outputListener.toString(), errorListener.toString()))); }
Example #16
Source File: InProcessBuildActionExecuter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private GradleInternal check(BuildResult buildResult) { state = State.Completed; if (buildResult.getFailure() != null) { throw new ReportedException(buildResult.getFailure()); } return (GradleInternal) buildResult.getGradle(); }
Example #17
Source File: TaskListClientProtocol.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
/** * <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 #18
Source File: InProcessGradleExecuter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected ExecutionResult doRun() { OutputListenerImpl outputListener = new OutputListenerImpl(); OutputListenerImpl errorListener = new OutputListenerImpl(); BuildListenerImpl buildListener = new BuildListenerImpl(); BuildResult result = doRun(outputListener, errorListener, buildListener); try { result.rethrowFailure(); } catch (Exception e) { throw new UnexpectedBuildFailure(e); } return assertResult(new InProcessExecutionResult(buildListener.executedTasks, buildListener.skippedTasks, new OutputScrapingExecutionResult(outputListener.toString(), errorListener.toString()))); }
Example #19
Source File: TaskListClientProtocol.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
/** * <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 #20
Source File: DefaultGradleLauncher.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private BuildResult doBuild(Stage upTo) { loggingManager.start(); buildListener.buildStarted(gradle); Throwable failure = null; try { doBuildStages(upTo); } catch (Throwable t) { failure = exceptionAnalyser.transform(t); } BuildResult buildResult = new BuildResult(gradle, failure); buildListener.buildFinished(buildResult); return buildResult; }
Example #21
Source File: ProfileEventAdapter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void buildFinished(BuildResult result) { buildProfile.setBuildFinished(timeProvider.getCurrentTime()); buildProfile.setSuccessful(result.getFailure() == null); try { listener.buildFinished(buildProfile); } finally { buildProfile = null; } }
Example #22
Source File: AbstractMetricsPlugin.java From gradle-metrics-plugin with Apache License 2.0 | 5 votes |
protected void createAndRegisterGradleBuildMetricsCollector(Gradle gradle, BuildMetrics buildMetrics) { //Using internal API to retrieve build start time but still storing it in our own data structure BuildStartedTime buildStartedTime = BuildStartedTime.startingAt(buildInvocationDetails.getBuildStartedTime()); final GradleBuildMetricsCollector gradleCollector = new GradleBuildMetricsCollector(dispatcherSupplier, buildStartedTime, gradle, buildMetrics, clock); gradle.addListener(gradleCollector); gradle.buildFinished(new Closure(null) { protected Object doCall(Object arguments) { gradleCollector.buildFinishedClosure((BuildResult)arguments); return null; } }); }
Example #23
Source File: TaskListClientProtocol.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
/** * <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 #24
Source File: InProcessBuildActionExecuter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private GradleInternal check(BuildResult buildResult) { state = State.Completed; if (buildResult.getFailure() != null) { throw new ReportedException(buildResult.getFailure()); } return (GradleInternal) buildResult.getGradle(); }
Example #25
Source File: InProcessGradleExecuter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
private BuildResult doRun(final OutputListenerImpl outputListener, OutputListenerImpl errorListener, BuildListenerImpl listener) { // Capture the current state of things that we will change during execution InputStream originalStdIn = System.in; Properties originalSysProperties = new Properties(); originalSysProperties.putAll(System.getProperties()); File originalUserDir = new File(originalSysProperties.getProperty("user.dir")); Map<String, String> originalEnv = new HashMap<String, String>(System.getenv()); // Augment the environment for the execution System.setIn(getStdin()); processEnvironment.maybeSetProcessDir(getWorkingDir()); for (Map.Entry<String, String> entry : getEnvironmentVars().entrySet()) { processEnvironment.maybeSetEnvironmentVariable(entry.getKey(), entry.getValue()); } Map<String, String> implicitJvmSystemProperties = getImplicitJvmSystemProperties(); System.getProperties().putAll(implicitJvmSystemProperties); StartParameter parameter = new StartParameter(); parameter.setCurrentDir(getWorkingDir()); parameter.setShowStacktrace(ShowStacktrace.ALWAYS); CommandLineParser parser = new CommandLineParser(); DefaultCommandLineConverter converter = new DefaultCommandLineConverter(); converter.configure(parser); ParsedCommandLine parsedCommandLine = parser.parse(getAllArgs()); BuildLayoutParameters layout = converter.getLayoutConverter().convert(parsedCommandLine); Map<String, String> properties = new HashMap<String, String>(); new LayoutToPropertiesConverter().convert(layout, properties); converter.getSystemPropertiesConverter().convert(parsedCommandLine, properties); new PropertiesToStartParameterConverter().convert(properties, parameter); converter.convert(parsedCommandLine, parameter); DefaultGradleLauncherFactory factory = DeprecationLogger.whileDisabled(new Factory<DefaultGradleLauncherFactory>() { public DefaultGradleLauncherFactory create() { return (DefaultGradleLauncherFactory) GradleLauncher.getFactory(); } }); factory.addListener(listener); GradleLauncher gradleLauncher = factory.newInstance(parameter); gradleLauncher.addStandardOutputListener(outputListener); gradleLauncher.addStandardErrorListener(errorListener); try { return gradleLauncher.run(); } finally { // Restore the environment System.setProperties(originalSysProperties); processEnvironment.maybeSetProcessDir(originalUserDir); for (String envVar: getEnvironmentVars().keySet()) { String oldValue = originalEnv.get(envVar); if (oldValue != null) { processEnvironment.maybeSetEnvironmentVariable(envVar, oldValue); } else { processEnvironment.maybeRemoveEnvironmentVariable(envVar); } } factory.removeListener(listener); System.setIn(originalStdIn); } }
Example #26
Source File: InProcessBuildActionExecuter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
private void check(BuildResult buildResult) { if (buildResult.getFailure() != null) { throw new ReportedException(buildResult.getFailure()); } }
Example #27
Source File: BuildProgressFilter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void buildFinished(BuildResult result) { if (result.getGradle() == gradle) { gradle = null; logger.buildFinished(); } }
Example #28
Source File: ProfileEventAdapter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void buildFinished(BuildResult result) { buildProfile.setSuccessful(result.getFailure() == null); }
Example #29
Source File: NestedBuildTracker.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void buildFinished(BuildResult result) { buildStack.remove(result.getGradle()); }
Example #30
Source File: NestedBuildTracker.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void buildFinished(BuildResult result) { buildStack.remove(result.getGradle()); }