Contenido principal

addDependency

Add dependency to package

Since R2024b

    Description

    addDependency(pkg,dep) adds the packages in dep as dependencies to the package pkg and updates the Dependencies property of the package object. The package pkg must be in editable mode.

    example

    Examples

    collapse all

    Create packages named MyPackage and MyOtherPackage.

    pkg = mpmcreate("MyPackage","C:\MyCode\MyPackage");
    dep = mpmcreate("MyOtherPackage","C:\MyCode\MyOtherPackage");

    Make MyOtherPackage a dependency of MyPackage.

    addDependency(pkg,dep)
    pkg.Dependencies
    ans = 
      Dependency with properties:
    
                   Name: "MyOtherPackage"
           VersionRange: ""
                     ID: "89529df1-1fb9-46a5-8ea3-731edb9ab4f8"
        ResolvedVersion: 1.0.0 (1×1 Version)
    
    

    Create a package named MyPackage.

    pkg = mpmcreate("MyPackage","C:\MyCode\MyPackage");

    Use mpmlist to return the installed package, MyOtherPackage, as a package object.

    dep = mpmlist("MyOtherPackage");

    Make MyOtherPackage a dependency of MyPackage.

    addDependency(pkg,dep)
    pkg.Dependencies
    ans = 
      Dependency with properties:
    
                   Name: "MyOtherPackage"
           VersionRange: ""
                     ID: "89529df1-1fb9-46a5-8ea3-731edb9ab4f8"
        ResolvedVersion: 1.0.0 (1×1 Version)
    
    

    Input Arguments

    collapse all

    Package, specified as a matlab.mpm.Package object.

    Package dependencies to add, specified as a string array of package specifiers, a matlab.mpm.PackageSpecifier array, a matlab.mpm.Package array, or a matlab.mpm.Dependency array. If dep is a string array, then each element must contain a package specifier in the format "Name", "Name@VersionRange", or "Name@VersionRange@ID". If you specify a package specifier, then addDependency finds the corresponding package among already installed packages. MATLAB throws an error if the package corresponding to the package specifier is not installed.

    Version History

    Introduced in R2024b