matlab.project.rootProject

Get root project

Description

example

proj = matlab.project.rootProject gets the root project of the currently loaded project and returns a project object that you can use to manipulate the root project programmatically. If no project is open, MATLAB® returns an empty array. Use matlab.project.rootProject when working with referenced projects.

To get the project which currently has context, for example, if the project is running a shortcut, startup file, or shutdown file for a referenced project, use currentProject instead.

For more information about referenced projects, see Componentize Large Projects

Examples

collapse all

Open the Times Table App example project and get the root project object to manipulate the project at the command line.

matlab.project.example.timesTable
proj = matlab.project.rootProject
proj = 

  Project with properties:

                        Name: "Times Table App"
    SourceControlIntegration: "Git"
          RepositoryLocation: "C:\myProjects\examples\repositories\TimesTableApp"
       SourceControlMessages: [1×3 string]
                    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 for a...
                  RootFolder: "C:\Users\myProjects\examples\TimesTableApp"
        ProjectStartupFolder: "C:\myProjects\examples\TimesTableApp"

Examine the project files.

files = proj.Files
files = 

  1×14 ProjectFile array with properties:

    Path
    Labels
    Revision
    SourceControlStatus

Output Arguments

collapse all

Project, returned as a matlab.project.Project object. Use the matlab.project.Project object to programmatically manipulate the currently open project.

Introduced in R2019a