Main Content

matlab.project.convertDefinitionFiles

R2026b

Change definition file type of project

    Description

    matlab.project.convertDefinitionFiles(projectRoot,definitionType) converts the definition file type of the project stored in projectRoot to a new type specified by definitionType. matlab.project.convertDefinitionFiles preserves the source control history of your project.

    Warning

    To avoid merge issues, ensure that no work is being done on other branches before converting the definition file type for a project.

    example

    matlab.project.convertDefinitionFiles(projectRoot,definitionType,Name=Value) converts the definition file type of the project with additional options specified as name-value arguments. Use this syntax to conserve project labels when you convert the project.

    example

    Examples

    collapse all

    Check which definition file management your project uses currently.

    projectRoot = "C:/projects/myproject";
    proj = openProject(projectRoot);
    currentDefinitionFileType = proj.DefinitionFilesType
    currentDefinitionFileType = 
    
      DefinitionFiles enumeration
    
        MultiFile

    Close your project before converting the project definition file management.

    close(proj);

    Programmatically convert the project definition file management to use the TOML format.

    matlab.project.convertDefinitionFiles(projectRoot,matlab.project.DefinitionFiles.Toml)

    If you are converting a project that uses one of the XML definition file formats (SingleFile, MultiFile or FixedPathMultiFile) to the TOML definition file format, the conversion conserves project built-in labels only if you set the KeepBuiltinLabels argument to true. For more information, see Convert to TOML Project and Conserve Labels.

    Check the new project definition file management.

    proj = openProject(projectRoot);
    newDefinitionFileType = proj.DefinitionFilesType
    newDefinitionFileType = 
    
      DefinitionFiles enumeration
    
        Toml

    Check which definition file management your project uses currently.

    projectRoot = "C:/projects/myproject";
    proj = openProject(projectRoot);
    currentDefinitionFileType = proj.DefinitionFilesType
    currentDefinitionFileType = 
    
      DefinitionFiles enumeration
    
        MultiFile

    Close your project before converting the project definition file management.

    close(proj);

    Programmatically convert the project definition file management to use the TOML format and conserve existing built-in labels.

    matlab.project.convertDefinitionFiles(projectRoot,matlab.project.DefinitionFiles.Toml,KeepBuiltinLabels=true)

    Input Arguments

    collapse all

    Full path to project root folder, specified as a character vector or string scalar.

    Example: "C:/projects/myproject"

    Data Types: char | string

    Definition file type, specified as matlab.project.DefinitionFiles.SingleFile, matlab.project.DefinitionFiles.MultiFile, matlab.project.DefinitionFiles.FixedPathMultiFile, or matlab.project.DefinitionFiles.Toml.

    Choose a definition file type based on your use case:

    • MultiFile - Helps to avoid file conflicts when performing merge on shared projects

    • SingleFile - Is faster but is likely to cause merge issues when two users submit changes in the same project to a source control tool

    • FixedPathMultiFile - Is better if you need to work with long paths

    • Toml - Is user-readable and easy to compare and merge

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: matlab.project.convertDefinitionFiles(projectRoot,matlab.project.DefinitionFiles.Toml,KeepBuiltinLabels=true)

    Option to conserve project built-in labels during project conversion, specified as a numeric or logical 1 (true) or 0 (false).

    If you are converting a project that uses one of the XML definition file formats (SingleFile, MultiFile or FixedPathMultiFile) to the TOML definition file format, the conversion conserves project built-in labels only if you set the KeepBuiltinLabels argument to true.

    If you are converting a project from an XML definition file format to another XML definition file format (SingleFile, MultiFile or FixedPathMultiFile), by default, the conversion conserves project labels.

    If the project has no references, the option does not apply.

    Data Types: logical

    Version History

    Introduced in R2020b

    expand all