use of org.gradle.internal.buildtree.BuildActionModelRequirements in project gradle by gradle.
the class BuildTreeLifecycleBuildActionExecutor method execute.
@Override
public BuildActionRunner.Result execute(BuildAction action, BuildSessionContext buildSession) {
BuildActionRunner.Result result = null;
try {
buildLayoutValidator.validate(action.getStartParameter());
BuildActionModelRequirements actionRequirements;
if (action instanceof BuildModelAction && action.isCreateModel()) {
BuildModelAction buildModelAction = (BuildModelAction) action;
actionRequirements = new QueryModelRequirements(action.getStartParameter(), action.isRunTasks(), buildModelAction.getModelName());
} else if (action instanceof ClientProvidedBuildAction) {
actionRequirements = new RunActionRequirements(action.getStartParameter(), action.isRunTasks());
} else if (action instanceof ClientProvidedPhasedAction) {
actionRequirements = new RunPhasedActionRequirements(action.getStartParameter(), action.isRunTasks());
} else {
actionRequirements = new RunTasksRequirements(action.getStartParameter());
}
BuildTreeModelControllerServices.Supplier modelServices = buildTreeModelControllerServices.servicesForBuildTree(actionRequirements);
BuildTreeState buildTree = new BuildTreeState(buildSession.getServices(), modelServices);
try {
result = buildTree.run(context -> context.execute(action));
} finally {
buildTree.close();
}
} catch (Throwable t) {
if (result == null) {
// whereas console failure logging based on the _thrown exception_ happens up outside session scope. It would be better to refactor so that a result can be returned from here
throw UncheckedException.throwAsUncheckedException(t);
} else {
// whereas console failure logging based on the _thrown exception_ happens up outside session scope. It would be better to refactor so that a result can be returned from here
throw UncheckedException.throwAsUncheckedException(result.addFailure(t).getBuildFailure());
}
}
return result;
}
Aggregations