Project object
The matlab.project.Project object represents the currently
loaded project. Use the project object to query the currently loaded project and to
perform various operation on it.
To create a matlab.project.Project object, use the currentProject function to get the currently open project. For
example:
proj = currentProject;
openProject function to load an existing project. For
example:proj = openProject("C:/projects/project1/");Name — Project nameProject name, specified as a string.
Categories — Label categoriesCategory objectsLabel categories for the project, specified as an array of
Category objects.
Shortcuts — Shortcut filesShortcut objectsShortcut files for the project, specified as an array of
Shortcut objects.
ProjectPath — Project path foldersPathFolder objectsProject path folders that are added to the MATLAB® path, specified as an array of PathFolder
objects.
ProjectReferences — Paths of referenced projectsProjectReference objectsPaths of referenced projects, specified as an array of
ProjectReference objects.
Files — Paths of project filesProjectFile objectsPaths of project files, specified as an array of
ProjectFile objects.
RootFolder — Project root folderProject root folder, specified as a string.
RootFolder includes the full path of the project
root.
addFile | Add file or folder to project |
addFolderIncludingChildFiles | Add folder and child files to project |
removeFile | Remove file from project |
addPath | Add folder to project path |
removePath | Remove folder from project path |
addReference | Add referenced project to project |
removeReference | Remove project reference |
addStartupFile | Add startup file to project |
addShutdownFile | Add shutdown file to project |
removeStartupFile | Remove startup file from project startup list |
removeShutdownFile | Remove shutdown file from project shutdown list |
addShortcut | Add shortcut to project |
removeShortcut | Remove shortcut from project |
addLabel | Attach label to project file |
createLabel | Create project label |
removeLabel | Remove label from project |
findLabel | Get project file label |
createCategory | Create category of project labels |
findCategory | Find project category of labels |
removeCategory | Remove project category of labels |
findFile | Find project file by name |
listModifiedFiles | List modified files in project |
listRequiredFiles | Get files required by specified project files |
refreshSourceControl | Update source control status of project files |
updateDependencies | Update project dependencies |
Open the Times Table App project and use
currentProject to get a project object you can
manipulate at the command line.
matlab.project.example.timesTable proj = currentProject
proj =
Project with properties:
Name: "Times Table App"
SourceControlIntegration: "Git"
RepositoryLocation: "C:\myProjects\examples\repositories\TimesTableApp"
SourceControlMessages: ["No remote tracking branch" "Branch status: Normal" ...
ReadOnly: 0
TopLevel: 1
Dependencies: [1×1 digraph]
Categories: [1×1 matlab.project.Category]
Files: [1×14 matlab.project.ProjectFile]
Shortcuts: [1×4 matlab.project.Shortcut]
ProjectPath: [1×3 matlab.project.PathFolder]
ProjectReferences: [1×0 matlab.project.ProjectReference]
StartupFiles: [1×0 string]
ShutdownFiles: [1×0 string]
Description: "This example project contains the source code and tests ...
RootFolder: "C:\myProjects\examples\TimesTableApp"
ProjectStartupFolder: "C:\myProjects\examples\TimesTableApp"Open the Times Table App project and create a project object.
matlab.project.example.timesTable proj = currentProject;
Find the functions you can execute on the project object.
methods(proj)
Methods for class matlab.project.Project: addFile listModifiedFiles addFolderIncludingChildFiles listRequiredFiles addPath refreshSourceControl addReference reload addShortcut removeCategory addShutdownFile removeFile addStartupFile removePath addprop removeReference close removeShortcut createCategory removeShutdownFile export removeStartupFile findCategory updateDependencies findFile isLoaded
Get a project object, and examine its properties.
Open the Times Table App project. Use currentProject
to create a project object from the currently loaded project.
matlab.project.example.timesTable proj = currentProject;
Examine the project files.
files = proj.Files
files =
1×14 ProjectFile array with properties:
Path
Labels
Revision
SourceControlStatusExamine the labels of the 13th file.
proj.Files(13).Labels
ans =
Label with properties:
File: "C:\myProjects\examples\TimesTableApp\utilities\runTheseTests.m"
DataType: 'none'
Data: []
Name: "Design"
CategoryName: "Classification"Get a particular file by name.
myfile = findFile(proj,"source/timesTableGame.m")myfile =
ProjectFile with properties:
Path: "C:\myProjects\examples\TimesTableApp\source\timesTableGame.m"
Labels: [1×1 matlab.project.Label]
Revision: ""
SourceControlStatus: UnmodifiedFind out what you can do with the file.
methods(myfile)
Methods for class matlab.project.ProjectFile: addLabel findLabel removeLabel