private CompletableFuture<Void> waitForEnvironmentInitialization( BuildExecutionSession buildExecutionSession, StartedEnvironment startedEnvironment) { CompletableFuture<Void> waitToCompleteFuture = new CompletableFuture<>(); try { Consumer<RunningEnvironment> onComplete = (runningEnvironment) -> { buildExecutionSession.setRunningEnvironment(runningEnvironment); buildExecutionSession.setStatus(BuildExecutionStatus.BUILD_ENV_SETUP_COMPLETE_SUCCESS); waitToCompleteFuture.complete(null); }; Consumer<Exception> onError = (e) -> { buildExecutionSession.setStatus( BuildExecutionStatus.BUILD_ENV_SETUP_COMPLETE_WITH_ERROR); waitToCompleteFuture.completeExceptionally( new BuildProcessException(e, startedEnvironment)); }; buildExecutionSession.setStatus(BuildExecutionStatus.BUILD_ENV_WAITING); startedEnvironment.monitorInitialization(onComplete, onError); } catch (Throwable e) { waitToCompleteFuture.completeExceptionally(new BuildProcessException(e, startedEnvironment)); } return waitToCompleteFuture; }
private Void retrieveRepositoryManagerResults(BuildExecutionSession buildExecutionSession) { try { buildExecutionSession.setStatus( BuildExecutionStatus.COLLECTING_RESULTS_FROM_REPOSITORY_NAMAGER); RunningEnvironment runningEnvironment = buildExecutionSession.getRunningEnvironment(); buildExecutionSession.setRunningEnvironment(runningEnvironment); RepositorySession repositorySession = runningEnvironment.getRepositorySession(); RepositoryManagerResult repositoryManagerResult = repositorySession.extractBuildArtifacts(); buildExecutionSession.setRepositoryManagerResult(repositoryManagerResult); } catch (Throwable e) { throw new BuildProcessException(e, buildExecutionSession.getRunningEnvironment()); } return null; }