matlab.project.Project - Project object - MATLAB (original) (raw)

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:

If no project is currently open, use the openProject function to load an existing project. For example:

proj = openProject("C:/workSpace/project1/");

To create and open a blank project and get the project object, use the matlab.project.createProject function. For example:

proj = matlab.project.createProject;

Properties

expand all

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 ofDefinitionFilesType 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 ofProjectFile 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 ofShortcut 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 ofCategory 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 adigraph 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 ofProjectReference 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

Examples

collapse all

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 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 =

1×13 ProjectFile array with properties:

Path
Revision
SourceControlStatus
Labels

Examine the labels of the 13th file.

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 for class matlab.project.ProjectFile:

addLabel findLabel removeLabel

Methods of matlab.project.ProjectFile inherited from handle.

Version History

Introduced in R2019a