Search in sources :

Example 1 with TypeValidationProblem

use of org.gradle.internal.reflect.validation.TypeValidationProblem 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;
    }
}
Also used : TypeValidationProblem(org.gradle.internal.reflect.validation.TypeValidationProblem) GeneratedSubclasses(org.gradle.api.internal.GeneratedSubclasses) TypeValidationProblemRenderer.renderMinimalInformationAbout(org.gradle.internal.reflect.validation.TypeValidationProblemRenderer.renderMinimalInformationAbout) WorkValidationContext(org.gradle.internal.execution.WorkValidationContext) List(java.util.List) UserManualReference(org.gradle.internal.reflect.validation.UserManualReference) TypeValidationProblemRenderer.convertToSingleLine(org.gradle.internal.reflect.validation.TypeValidationProblemRenderer.convertToSingleLine) DeprecationLogger(org.gradle.internal.deprecation.DeprecationLogger) Optional(java.util.Optional) TypeValidationContext(org.gradle.internal.reflect.validation.TypeValidationContext) UserManualReference(org.gradle.internal.reflect.validation.UserManualReference) TypeValidationProblem(org.gradle.internal.reflect.validation.TypeValidationProblem) TypeValidationContext(org.gradle.internal.reflect.validation.TypeValidationContext) WorkValidationContext(org.gradle.internal.execution.WorkValidationContext)

Aggregations

List (java.util.List)1 Optional (java.util.Optional)1 GeneratedSubclasses (org.gradle.api.internal.GeneratedSubclasses)1 DeprecationLogger (org.gradle.internal.deprecation.DeprecationLogger)1 WorkValidationContext (org.gradle.internal.execution.WorkValidationContext)1 TypeValidationContext (org.gradle.internal.reflect.validation.TypeValidationContext)1 TypeValidationProblem (org.gradle.internal.reflect.validation.TypeValidationProblem)1 TypeValidationProblemRenderer.convertToSingleLine (org.gradle.internal.reflect.validation.TypeValidationProblemRenderer.convertToSingleLine)1 TypeValidationProblemRenderer.renderMinimalInformationAbout (org.gradle.internal.reflect.validation.TypeValidationProblemRenderer.renderMinimalInformationAbout)1 UserManualReference (org.gradle.internal.reflect.validation.UserManualReference)1