matlab.project.Project
Project object
Description
The matlab.project.Project
object represents the currently
loaded project. Use the project object to programmatically manipulate the project,
interact with source control, and find file dependencies.
Creation
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:/workSpace/project1/");
matlab.project.createProject
function. For
example:proj = matlab.project.createProject;
Properties
Project name, specified as a string scalar.
Project description, specified as a string scalar.
Path of project root folder, specified as a string scalar.
This property is read-only.
Top-level status, stored as a logical 1
(true
) if the project is a top-level project.
This property is read-only.
Project permission status, stored as a logical 1
(true
) if the project has limited permissions when
using add, remove, and create object functions. A referenced project status
is always read-only to prevent modification.
Project definition file types, specified as an array of
DefinitionFilesType
objects. Use matlab.project.convertDefinitionFiles
to change the current
project definition file type programmatically.
This property is read-only.
Project repository location, stored as a string scalar.
This property is read-only.
Source control integration type, stored as a string scalar.
Example: "Git"
Paths of project files, specified as an array of
ProjectFile
objects. This property changes when you add
or remove project files. You can use addFile
, addFolderIncludingChildFiles
, or removeFile
to add or remove project files.
Shortcut files for project, specified as an array of
Shortcut
objects. This property changes when you add or
remove shortcut files. You can use addShortcut
and removeShortcut
to create or
remove shortcut files programmatically.
Label categories for project, specified as an array of
Category
objects. This property changes when you create
or remove label categories. You can use createCategory
and removeCategory
to create and remove label categories
programmatically.
Graph of dependencies between project files, specified as a
digraph
object.
Project startup files, specified as a string array. This property changes
when you add or remove startup files. You can use addStartupFile
and removeStartupFile
to add or remove startup files
programmatically.
Project shutdown files, specified as a string array. This property changes
when you add or remove shutdown files. You can use addShutdownFile
and removeShutdownFile
to add or remove shutdown files
programmatically.
Project path folders that are added to the MATLAB® path, specified as an array of PathFolder
objects.
Paths of referenced projects, specified as an array of
ProjectReference
objects. This property changes when
you add or remove reference projects. You can use addReference
and removeReference
to add or
remove reference projects programmatically.
Path of the project startup folder, specified as a string scalar.
Path of Simulink® cache folder, specified as a string scalar.
Path of Simulink Coder™ code generation folder, specified as a string scalar.
Path of dependency analysis cache file, specified as a string scalar.
Object Functions
currentProject | Get current project |
openProject | Load an existing project |
isLoaded | Determine if project is loaded |
reload | Reload project |
close | Close project |
export | Export project to archive |
matlab.project.createProject | Create blank project |
matlab.project.convertDefinitionFiles | Change definition file type of project |
matlab.project.deleteProject | Stop folder management and delete project definition files |
matlab.project.loadProject | Load project |
matlab.project.rootProject | Get root project |
addFile | Add files or folders to project |
addFolderIncludingChildFiles | Add folders and child files to project |
removeFile | Remove file or folder from project |
addPath | Add folder to project path |
removePath | Remove folder from project path |
addReference | Add referenced project to project |
listAllProjectReferences | List all projects in reference hierarchy of current project |
listShutdownIssues | List all issues that occur when project closes |
listStartupIssues | List all issues that occur when project opens |
removeReference | Remove project reference |
addStartupFile | Add startup file to project |
addShutdownFile | Add shutdown file to project |
removeStartupFile | Remove file from project startup files |
removeShutdownFile | Remove file from project shutdown files |
addShortcut | Add shortcut to project |
removeShortcut | Remove shortcut from project |
addLabel | Attach label to project files |
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 |
findFiles | Find project files by category or label name |
listModifiedFiles | List modified files in project |
listRequiredFiles | Get files required by specified project files |
listImpactedFiles | Get files impacted by changes to specified project files |
listAllProjectReferences | List all projects in reference hierarchy of current project |
refreshSourceControl | Update source control status of project files |
runChecks | Run all project checks |
updateDependencies | Update project dependencies |
matlab.project.isUnderProjectRoot | Determine whether file or folder is under project root folder |
matlab.project.isFileInProject | Determine whether file or folder belongs to project |
Examples
Download the Times Table App project by clicking the button. The example project is under Git source control.
Alternatively, run the following command:
openExample("matlab/TimesTableProjectExample")
Open the Times Table App project and use the currentProject
function to create a project object that you can
manipulate programmatically.
openExample("matlab/TimesTableProjectExample")
proj = currentProject
proj = Project with properties: Name: "Times Table App" Description: "This example project contains the source code and tests for a simple educational app. ↵↵Use the project shortcuts to get started with this project." RootFolder: "C:\Workspace\Projects\TimesTableApp" TopLevel: 1 ReadOnly: 0 DefinitionFilesType: FixedPathMultiFile SourceControlIntegration: "Git" RepositoryLocation: "C:Workspace\Projects\repositories\TimesTableApp" Files: [1×13 matlab.project.ProjectFile] Shortcuts: [1×4 matlab.project.Shortcut] Categories: [1×3 matlab.project.Category] Dependencies: [1×1 digraph] StartupFiles: [1×0 string] ShutdownFiles: [1×0 string] ProjectPath: [1×2 matlab.project.PathFolder] ProjectReferences: [1×0 matlab.project.ProjectReference] SimulinkCacheFolder: "" ProjectStartupFolder: "C:\Workspace\Projects\TimesTableApp" SimulinkCodeGenFolder: "" DependencyCacheFile: ""
Open the Times Table App project and create a project object.
openExample("matlab/TimesTableProjectExample")
proj = currentProject;
Find the functions that you can execute on the project object.
methods(proj)
Methods for class matlab.project.Project: addFile findFiles removeLabel addFolderIncludingChildFiles isLoaded removePath addLabel istAllProjectReferences removeReference addPath listImpactedFiles removeShortcut addReference listModifiedFiles removeShutdownFile addShortcut listRequiredFiles removeStartupFile addShutdownFile listShutdownIssues runChecks addStartupFile listStartupIssues updateDependencies close refreshSourceControl createCategory reload export removeCategory findCategory removeFile Methods of matlab.project.Project inherited from handle.
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.
openExample("matlab/TimesTableProjectExample")
proj = currentProject;
Examine the project files.
files = proj.Files
files = 1×13 ProjectFile array with properties: Path Revision SourceControlStatus Labels
Examine the labels of the 13th file.
proj.Files(13).Labels
ans = Label with properties: File: "C:\Workspace\Projects\TimesTableApp\utilities\runTheseTests.m" DataType: "none" Data: [] Name: "Design" CategoryName: "Classification"
Get a particular file by name.
myfile = findFiles(proj,"source/timesTableGame.m",OutputFormat="ProjectFile")
myfile = ProjectFile with properties: Path: "C:\Workspace\Projects\TimesTableApp\source\timesTableGame.m" Revision: "a089d00d667d39be7940fcdcac18a9ca7a3c6840" SourceControlStatus: Unmodified Labels: [1×1 matlab.project.Label]
Find out what you can do with the file.
methods(myfile)
Methods for class matlab.project.ProjectFile: addLabel findLabel removeLabel Methods of matlab.project.ProjectFile inherited from handle.
Version History
Introduced in R2019a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: United States.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)