Invoke build tool
buildtool invokes the build tool on the file
buildfile.m in your current folder. It runs the default tasks in the
plan returned by the build file as well as all the tasks on which they depend.
runs the tasks named
taskName1 ... taskNameN
taskName1 ... taskNameN as well as all the tasks
on which they depend. The command runs the tasks in the order specified. It runs each task
at most one time and ignores a task in the list that has already run.
buildtool -tasks lists all the tasks in the build plan. The list
includes task names as well as task descriptions.
List and Run Tasks in Plan
Invoke the build tool to list and run the tasks in the plan returned by a build file.
Open the example and then navigate to the
buildtool_example folder, which contains a build file.
openExample("matlab/ListAndRunTasksInPlanExample") cd buildtool_example
This code shows the contents of the build file.
function plan = buildfile % Create a plan from the task functions plan = buildplan(localfunctions); % 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 checkTask(~) % Identify code issues issues = codeIssues; assert(isempty(issues.Issues),formattedDisplayText(issues.Issues)) end function testTask(~) % Run unit tests results = runtests(IncludeSubfolders=true,OutputDetail="terse"); assertSuccess(results); end function archiveTask(~) % Create archive for sharing zipFileName = "source_" + ... string(datetime("now",Format="yyyyMMdd'T'HHmmss")); zip(zipFileName,"*") end
List the tasks in the plan returned by the main function of the build file.
archive - Create archive for sharing check - Identify code issues test - Run unit 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.
** Starting check ** Finished check ** Starting test ... ** Finished test ** Starting archive ** Finished archive
Now, run only the
buildtool check test
** Starting check ** Finished check ** Starting test ... ** Finished test
taskName1 ... taskNameN — Names of tasks to run
character vectors | string scalars
Names of the tasks to run, specified as one or more character vectors or string scalars.
Introduced in R2022b