主要内容

matlab.buildtool.diagnostics.TaskSkipReason Class

Namespace: matlab.buildtool.diagnostics

Reason for skipping a task

Since R2026a

Description

matlab.buildtool.diagnostics.TaskSkipReason is an enumeration class that specifies the reason for skipping a task. When the build runner creates a matlab.buildtool.TaskResult object, the SkipReason property of the object is a TaskSkipReason enumeration object.

Enumeration Members

Enumeration Member NameDescription
UpToDate

Task is up to date.

DependencyFailed

Build environment setup or task dependency failed.

UserRequested

Task was requested to be skipped.

Examples

collapse all

Run the tasks in a plan and access the build result.

Open the example and then navigate to the run_plan_example folder, which contains a build file.

cd run_plan_example

This code shows the contents of the build file.

function plan = buildfile
import matlab.buildtool.tasks.CodeIssuesTask
import matlab.buildtool.tasks.TestTask

% Create a plan from task functions
plan = buildplan(localfunctions);

% Add the "check" task to identify code issues
plan("check") = CodeIssuesTask;

% Add the "test" task to run tests
plan("test") = TestTask;

% Make the "archive" task the default task in the plan
plan.DefaultTasks = "archive";

% Make the "archive" task dependent on the "check" and "test" tasks
plan("archive").Dependencies = ["check" "test"];
end

function archiveTask(~)
% Create ZIP file
filename = "source_" + ...
    string(datetime("now",Format="yyyyMMdd'T'HHmmss"));
zip(filename,"*")
end

Load the plan from the build file.

plan = buildfile
plan = 
  Plan with tasks:

    archive - Create ZIP file
    check   - Identify code issues
    test    - Run tests

Run the default task in the plan. The build tool runs the "archive" task as well as both the tasks on which it depends. In this example, the tasks run successfully.

result1 = run(plan);
** Starting check

Analysis Summary:
    Total Files: 3
         Errors: 0 (Threshold: 0)
       Warnings: 0 (Threshold: Inf)
           Info: 0 (Threshold: Inf)
** Finished check

** Starting test
...

Test Summary:
    Total Tests: 3
         Passed: 3
         Failed: 0
     Incomplete: 0
       Duration: 0.02063 seconds testing time.
                 
** Finished test

** Starting archive
** Finished archive

Build Successful:
    3 Tasks: 0 Failed, 0 Skipped
    1.8397 sec total build time

Now, run only the "check" and "test" tasks.

result2 = run(plan,["check" "test"]);
** Starting check

Analysis Summary:
    Total Files: 3
         Errors: 0 (Threshold: 0)
       Warnings: 0 (Threshold: Inf)
           Info: 0 (Threshold: Inf)
** Finished check

** Starting test
...

Test Summary:
    Total Tests: 3
         Passed: 3
         Failed: 0
     Incomplete: 0
       Duration: 0.01037 seconds testing time.
                 
** Finished test

Build Successful:
    2 Tasks: 0 Failed, 0 Skipped
    1.4596 sec total build time

Run the default task and its dependencies, excluding the "check" task.

result3 = run(plan,Skip="check");
** Skipped check (user requested)

** Starting test
...

Test Summary:
    Total Tests: 3
         Passed: 3
         Failed: 0
     Incomplete: 0
       Duration: 0.0087511 seconds testing time.
                 
** Finished test

** Starting archive
** Finished archive

Build Successful:
    3 Tasks: 0 Failed, 1 Skipped
    1.1644 sec total build time

Display the most recent build result.

disp(result3)
  BuildResult with properties:

         Failed: 0
       Duration: 1.1644 sec
    TaskResults: [1×3 matlab.buildtool.TaskResult]

Return the result for the "check" task by accessing the TaskResults property of the build result. The Skipped property of the corresponding TaskResult object indicates that the task was skipped, and the SkipReason property specifies the reason for skipping the task.

result3.TaskResults(1)
ans = 
  TaskResult with properties:

          Name: "check"
        Failed: 0
      UpToDate: 0
       Skipped: 1
    SkipReason: UserRequested
      Duration: 00:00:00

Version History

Introduced in R2026a