matlab.buildtool.TaskGroup Class
R2026bNamespace: matlab.buildtool
Superclasses: matlab.buildtool.PlanElement
Description
The matlab.buildtool.TaskGroup class provides a way to group tasks into a
single unit of work in a build. For example, you can create a TaskGroup object
to group all the tasks in your project that build binary MEX files. Then, you can run all
these tasks by running the task group. For more information about task groups, see Create Groups of Tasks.
Creation
You can create a task group by adding a task whose name contains a colon to a build plan.
For example, this code adds a task named "mygroup:task1" to the plan.
Because the task name includes a colon, the assignment also creates a task group named
"mygroup" in the plan. In this example, the "mygroup"
task group contains a single task named "mygroup:task1".
import matlab.buildtool.Task plan = buildplan; plan("mygroup:task1") = Task;
To add a task to an existing task group, start the task name with the task group name
followed by a colon. For example, add the "mygroup:task2" task to the
"mygroup" task group.
plan("mygroup:task2") = Task;For another example of creating a task group by adding tasks to a plan, see Build MEX Files Using Task Group.
Alternatively, you can first group your tasks and then add the task group to the plan. To
create a task group without directly adding its tasks to the plan, create a
TaskGroup instance using the constructor syntaxes in this section.
Description
group = matlab.buildtool.TaskGroup(
creates a task group from the specified tasks. The constructor names the tasks in the
group as tasks)"task1", "task2", …,
"taskN".
group = matlab.buildtool.TaskGroup(
specifies options using one or more name-value arguments. For example, tasks,Name=Value)group =
matlab.buildtool.TaskGroup([mexTask1 mexTask2],Description="Build MEX files")
creates a group of two tasks with the specified description.
Input Arguments
Name-Value Arguments
Properties
Examples
Tips
Operating on a task group affects all the tasks in the group. For example:
If you run or skip a task group, the build tool runs or skips all the tasks in the group.
If you operate on a task group using a
matlab.buildtool.tasks.CleanTaskinstance, theCleanTaskinstance deletes the outputs of all the tasks in the group.If you add a dependency to a task group, all the tasks in the group observe that dependency.
You can create nested task groups by including more than one colon in a task name. For example, this code creates the
"g1"task group that contains the"g1:t1"task as well as the"g1:g2"task group. (The"g1:g2"task group contains the"g1:g2:t2"and"g1:g2:t3"tasks.)import matlab.buildtool.Task plan = buildplan; plan("g1:t1") = Task; plan("g1:g2:t2") = Task; plan("g1:g2:t3") = Task;
When tasks in a task group have no dependencies or other constraints, the tasks run serially in the order in which you add them to the task group. During parallel execution, task order is not guaranteed unless you specify dependencies. If a task depends on the outcome of another task, express that relationship using a dependency.