use of org.gradle.internal.execution.WorkValidationContext in project gradle by gradle.
the class DefaultNodeValidator method hasValidationProblems.
@Override
public boolean hasValidationProblems(Node node) {
if (node instanceof LocalTaskNode) {
LocalTaskNode taskNode = (LocalTaskNode) node;
WorkValidationContext validationContext = taskNode.getValidationContext();
Class<?> taskType = GeneratedSubclasses.unpackType(taskNode.getTask());
// We don't know whether the task is cacheable or not, so we ignore cacheability problems for scheduling
TypeValidationContext taskValidationContext = validationContext.forType(taskType, false);
taskNode.getTaskProperties().validateType(taskValidationContext);
List<TypeValidationProblem> problems = validationContext.getProblems();
problems.stream().filter(problem -> problem.getSeverity().isWarning()).forEach(problem -> {
Optional<UserManualReference> userManualReference = problem.getUserManualReference();
String docId = "more_about_tasks";
String section = "sec:up_to_date_checks";
if (userManualReference.isPresent()) {
UserManualReference docref = userManualReference.get();
docId = docref.getId();
section = docref.getSection();
}
// Because our deprecation warning system doesn't support multiline strings (bummer!) both in rendering
// **and** testing (no way to capture multiline deprecation warnings), we have to resort to removing details
// and rendering
String warning = convertToSingleLine(renderMinimalInformationAbout(problem, false, false));
DeprecationLogger.deprecateBehaviour(warning).withContext("Execution optimizations are disabled to ensure correctness.").willBeRemovedInGradle8().withUserManual(docId, section).nagUser();
});
return !problems.isEmpty();
} else {
return false;
}
}
use of org.gradle.internal.execution.WorkValidationContext in project gradle by gradle.
the class ResolveCachingStateStep method execute.
@Override
public CachingResult execute(UnitOfWork work, C context) {
CachingState cachingState;
if (!buildCache.isEnabled() && !buildScansEnabled) {
cachingState = BUILD_CACHE_DISABLED_STATE;
} else if (context.getValidationProblems().isPresent()) {
cachingState = VALIDATION_FAILED_STATE;
} else {
cachingState = context.getBeforeExecutionState().map(beforeExecutionState -> calculateCachingState(work, beforeExecutionState)).orElseGet(() -> calculateCachingStateWithNoCapturedInputs(work));
}
cachingState.apply(enabled -> logCacheKey(enabled.getKey(), work), disabled -> logDisabledReasons(disabled.getDisabledReasons(), work));
UpToDateResult result = delegate.execute(work, new CachingContext() {
@Override
public CachingState getCachingState() {
return cachingState;
}
@Override
public Optional<String> getNonIncrementalReason() {
return context.getNonIncrementalReason();
}
@Override
public WorkValidationContext getValidationContext() {
return context.getValidationContext();
}
@Override
public ImmutableSortedMap<String, ValueSnapshot> getInputProperties() {
return context.getInputProperties();
}
@Override
public ImmutableSortedMap<String, CurrentFileCollectionFingerprint> getInputFileProperties() {
return context.getInputFileProperties();
}
@Override
public UnitOfWork.Identity getIdentity() {
return context.getIdentity();
}
@Override
public File getWorkspace() {
return context.getWorkspace();
}
@Override
public Optional<ExecutionHistoryStore> getHistory() {
return context.getHistory();
}
@Override
public Optional<PreviousExecutionState> getPreviousExecutionState() {
return context.getPreviousExecutionState();
}
@Override
public Optional<ValidationResult> getValidationProblems() {
return context.getValidationProblems();
}
@Override
public Optional<BeforeExecutionState> getBeforeExecutionState() {
return context.getBeforeExecutionState();
}
});
return new CachingResult() {
@Override
public CachingState getCachingState() {
return cachingState;
}
@Override
public ImmutableList<String> getExecutionReasons() {
return result.getExecutionReasons();
}
@Override
public Optional<AfterExecutionState> getAfterExecutionState() {
return result.getAfterExecutionState();
}
@Override
public Optional<OriginMetadata> getReusedOutputOriginMetadata() {
return result.getReusedOutputOriginMetadata();
}
@Override
public Try<ExecutionResult> getExecutionResult() {
return result.getExecutionResult();
}
@Override
public Duration getDuration() {
return result.getDuration();
}
};
}
use of org.gradle.internal.execution.WorkValidationContext in project gradle by gradle.
the class ValidateStep method execute.
@Override
public R execute(UnitOfWork work, C context) {
WorkValidationContext validationContext = context.getValidationContext();
work.validate(validationContext);
context.getBeforeExecutionState().ifPresent(beforeExecutionState -> validateImplementations(work, beforeExecutionState, validationContext));
Map<Severity, List<String>> problems = validationContext.getProblems().stream().collect(groupingBy(BaseProblem::getSeverity, mapping(ValidateStep::renderedMessage, toList())));
ImmutableCollection<String> warnings = ImmutableList.copyOf(problems.getOrDefault(Severity.WARNING, ImmutableList.of()));
ImmutableCollection<String> errors = ImmutableList.copyOf(problems.getOrDefault(Severity.ERROR, ImmutableList.of()));
if (!warnings.isEmpty()) {
warningReporter.recordValidationWarnings(work, warnings);
}
if (!errors.isEmpty()) {
int maxErrCount = Integer.getInteger(MAX_NB_OF_ERRORS, 5);
ImmutableSortedSet<String> uniqueSortedErrors = ImmutableSortedSet.copyOf(errors);
throw WorkValidationException.forProblems(uniqueSortedErrors).limitTo(maxErrCount).withSummary(helper -> String.format("%s found with the configuration of %s (%s).", helper.size() == 1 ? "A problem was" : "Some problems were", work.getDisplayName(), describeTypesChecked(validationContext.getValidatedTypes()))).get();
}
if (!warnings.isEmpty()) {
LOGGER.info("Invalidating VFS because {} failed validation", work.getDisplayName());
virtualFileSystem.invalidateAll();
}
return delegate.execute(work, new ValidationFinishedContext() {
@Override
public Optional<BeforeExecutionState> getBeforeExecutionState() {
return context.getBeforeExecutionState();
}
@Override
public Optional<ValidationResult> getValidationProblems() {
return warnings.isEmpty() ? Optional.empty() : Optional.of(() -> warnings);
}
@Override
public Optional<PreviousExecutionState> getPreviousExecutionState() {
return context.getPreviousExecutionState();
}
@Override
public File getWorkspace() {
return context.getWorkspace();
}
@Override
public Optional<ExecutionHistoryStore> getHistory() {
return context.getHistory();
}
@Override
public ImmutableSortedMap<String, ValueSnapshot> getInputProperties() {
return context.getInputProperties();
}
@Override
public ImmutableSortedMap<String, CurrentFileCollectionFingerprint> getInputFileProperties() {
return context.getInputFileProperties();
}
@Override
public UnitOfWork.Identity getIdentity() {
return context.getIdentity();
}
@Override
public Optional<String> getNonIncrementalReason() {
return context.getNonIncrementalReason();
}
@Override
public WorkValidationContext getValidationContext() {
return context.getValidationContext();
}
});
}
use of org.gradle.internal.execution.WorkValidationContext in project gradle by gradle.
the class LoadPreviousExecutionStateStep method execute.
@Override
public R execute(UnitOfWork work, C context) {
Identity identity = context.getIdentity();
Optional<PreviousExecutionState> previousExecutionState = context.getHistory().flatMap(history -> history.load(identity.getUniqueId()));
return delegate.execute(work, new PreviousExecutionContext() {
@Override
public Optional<PreviousExecutionState> getPreviousExecutionState() {
return previousExecutionState;
}
@Override
public Optional<String> getNonIncrementalReason() {
return context.getNonIncrementalReason();
}
@Override
public WorkValidationContext getValidationContext() {
return context.getValidationContext();
}
@Override
public ImmutableSortedMap<String, ValueSnapshot> getInputProperties() {
return context.getInputProperties();
}
@Override
public ImmutableSortedMap<String, CurrentFileCollectionFingerprint> getInputFileProperties() {
return context.getInputFileProperties();
}
@Override
public Identity getIdentity() {
return context.getIdentity();
}
@Override
public File getWorkspace() {
return context.getWorkspace();
}
@Override
public Optional<ExecutionHistoryStore> getHistory() {
return context.getHistory();
}
});
}
Aggregations