use of org.gradle.api.tasks.TaskExecutionException in project gradle by gradle.
the class VerifyNoInputChangesTaskExecuter method execute.
@Override
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
TaskOutputCachingBuildCacheKey beforeExecution = context.getBuildCacheKey();
delegate.execute(task, state, context);
if (beforeExecution.isValid()) {
TaskOutputCachingBuildCacheKey afterExecution = repository.getStateFor(task).calculateCacheKey();
if (!afterExecution.isValid()) {
throw new TaskExecutionException(task, new GradleException("The build cache key became invalid after the task has been executed!"));
}
if (!beforeExecution.getHashCode().equals(afterExecution.getHashCode())) {
throw new TaskExecutionException(task, new GradleException("The inputs for the task changed during the execution! Check if you have a `doFirst` changing the inputs."));
}
}
}
use of org.gradle.api.tasks.TaskExecutionException in project gradle by gradle.
the class DefaultTaskProperties method resolve.
public static TaskProperties resolve(PropertyWalker propertyWalker, PathToFileResolver resolver, TaskInternal task) {
String beanName = task.toString();
GetInputFilesVisitor inputFilesVisitor = new GetInputFilesVisitor();
GetOutputFilesVisitor outputFilesVisitor = new GetOutputFilesVisitor();
GetInputPropertiesVisitor inputPropertiesVisitor = new GetInputPropertiesVisitor(beanName);
GetLocalStateVisitor localStateVisitor = new GetLocalStateVisitor(beanName, resolver);
GetDestroyablesVisitor destroyablesVisitor = new GetDestroyablesVisitor(beanName, resolver);
ValidationVisitor validationVisitor = new ValidationVisitor();
try {
TaskPropertyUtils.visitProperties(propertyWalker, task, new CompositePropertyVisitor(inputPropertiesVisitor, inputFilesVisitor, outputFilesVisitor, validationVisitor, destroyablesVisitor, localStateVisitor));
} catch (Exception e) {
throw new TaskExecutionException(task, e);
}
return new DefaultTaskProperties(task.toString(), inputPropertiesVisitor.getPropertyValuesFactory(), inputFilesVisitor.getFileProperties(), outputFilesVisitor.getFileProperties(), outputFilesVisitor.hasDeclaredOutputs(), localStateVisitor.getFiles(), destroyablesVisitor.getFiles(), validationVisitor.getTaskPropertySpecs());
}
use of org.gradle.api.tasks.TaskExecutionException in project gradle by gradle.
the class ValidatingTaskExecuter method execute.
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
List<String> messages = Lists.newArrayList();
FileResolver resolver = ((ProjectInternal) task.getProject()).getFileResolver();
final TaskValidationContext validationContext = new DefaultTaskValidationContext(resolver, messages);
try {
context.getTaskProperties().validate(validationContext);
} catch (Exception ex) {
throw new TaskExecutionException(task, ex);
}
if (!messages.isEmpty()) {
List<String> firstMessages = messages.subList(0, Math.min(5, messages.size()));
if (!validationContext.getHighestSeverity().report(task, firstMessages, state)) {
return;
}
}
executer.execute(task, state, context);
}
use of org.gradle.api.tasks.TaskExecutionException in project azure-gradle-plugins by lenala.
the class PackageTask method packageFunction.
@TaskAction
void packageFunction() {
try {
final AnnotationHandler handler = getAnnotationHandler();
final Set<Method> methods = findAnnotatedMethods(handler);
final Map<String, FunctionConfiguration> configMap = getFunctionConfigurations(handler, methods);
validateFunctionConfigurations(configMap);
final ObjectWriter objectWriter = getObjectWriter();
writeEmptyHostJsonFile(objectWriter);
copyLocalSettingsJson();
writeFunctionJsonFiles(objectWriter, configMap);
copyJarsToStageDirectory();
getLogger().quiet(BUILD_SUCCESS);
} catch (Exception ex) {
throw new TaskExecutionException(this, ex);
}
}
use of org.gradle.api.tasks.TaskExecutionException in project azure-gradle-plugins by lenala.
the class DeployTask method deploy.
@TaskAction
void deploy() {
try {
getLogger().quiet(String.format(WEBAPP_DEPLOY_START, azureWebAppExtension.getAppName()));
createOrUpdateWebApp();
deployArtifacts();
getLogger().quiet(String.format(WEBAPP_DEPLOY_SUCCESS, azureWebAppExtension.getAppName()));
} catch (Exception ex) {
throw new TaskExecutionException(this, ex);
}
}
Aggregations