Main Content

addReference

Add referenced project to project

Description

example

projreference = addReference(proj,referenceFolder) adds a reference to the project specified by referencefolder. The reference is added to the specified project, proj.

example

projreference = addReference(proj,referenceFolder,type) specifies the type of reference to create. Specify the type as either "relative" or "absolute".

Examples

collapse all

Open the Times Table App project. Use currentProject to create a project object from the currently loaded project.

matlab.project.example.timesTable
proj = currentProject;

Create a blank project.

projectToReference = matlab.project.createProject();

Reload the first project and add a reference to the new blank project. Reloading the first project is necessary because since only one project can be open at one time, MATLAB® unloads the first project before creating and opening the new blank project.

reload(proj);
addReference(proj,projectToReference,"absolute");

Input Arguments

collapse all

Project, specified as a matlab.project.Project object. Use currentProject to create a project object from the currently loaded project.

Path of the referenced project folder, specified as a character vector or string scalar. Specify the path relative to the project root folder. The folder must be within the project root folder.

Type of reference, specified as "relative" or "absolute". Specify "relative" if your project hierarchy has a well-defined root relative to your project root, for example, a folder under source control. Specify "absolute" if the project you want to reference is in a location accessible to your computer, for example, a network drive.

Output Arguments

collapse all

Referenced project, returned as a ProjectReference object containing information about the referenced project.

Introduced in R2019a