Class Dependencies

  • All Implemented Interfaces:
    software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

    @Generated(value="jsii-pacmak/1.96.0 (build 921e240)",
               date="2024-03-28T21:16:42.727Z")
    @Stability(Experimental)
    public class Dependencies
    extends Component
    (experimental) The Dependencies component is responsible to track the list of dependencies a project has, and then used by project types as the model for rendering project-specific dependency manifests such as the dependencies section package.json files.

    To add a dependency you can use a project-type specific API such as nodeProject.addDeps() or use the generic API of project.deps:

    • Field Detail

      • MANIFEST_FILE

        @Stability(Experimental)
        public static final String MANIFEST_FILE
        (experimental) The project-relative path of the deps manifest file.
    • Constructor Detail

      • Dependencies

        protected Dependencies​(software.amazon.jsii.JsiiObjectRef objRef)
      • Dependencies

        protected Dependencies​(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
      • Dependencies

        @Stability(Experimental)
        public Dependencies​(@NotNull
                            Project project)
        (experimental) Adds a dependencies component to the project.

        Parameters:
        project - The parent project. This parameter is required.
    • Method Detail

      • parseDependency

        @Stability(Experimental)
        @NotNull
        public static DependencyCoordinates parseDependency​(@NotNull
                                                            String spec)
        (experimental) Returns the coordinates of a dependency spec.

        Given foo@^3.4.0 returns { name: "foo", version: "^3.4.0" }. Given bar@npm:@bar/legacy returns { name: "bar", version: "npm:@bar/legacy" }.

        Parameters:
        spec - This parameter is required.
      • addDependency

        @Stability(Experimental)
        @NotNull
        public Dependency addDependency​(@NotNull
                                        String spec,
                                        @NotNull
                                        DependencyType type,
                                        @Nullable
                                        Map<String,​Object> metadata)
        (experimental) Adds a dependency to this project.

        Parameters:
        spec - The dependency spec in the format MODULE[@VERSION] where MODULE is the package-manager-specific module name and VERSION is an optional semantic version requirement (e.g. ^3.4.0). This parameter is required.
        type - The type of the dependency. This parameter is required.
        metadata -
      • addDependency

        @Stability(Experimental)
        @NotNull
        public Dependency addDependency​(@NotNull
                                        String spec,
                                        @NotNull
                                        DependencyType type)
        (experimental) Adds a dependency to this project.

        Parameters:
        spec - The dependency spec in the format MODULE[@VERSION] where MODULE is the package-manager-specific module name and VERSION is an optional semantic version requirement (e.g. ^3.4.0). This parameter is required.
        type - The type of the dependency. This parameter is required.
      • getDependency

        @Stability(Experimental)
        @NotNull
        public Dependency getDependency​(@NotNull
                                        String name,
                                        @Nullable
                                        DependencyType type)
        (experimental) Returns a dependency by name.

        Fails if there is no dependency defined by that name or if type is not provided and there is more then one dependency type for this dependency.

        Parameters:
        name - The name of the dependency. This parameter is required.
        type - The dependency type.
        Returns:
        a copy (cannot be modified)
      • getDependency

        @Stability(Experimental)
        @NotNull
        public Dependency getDependency​(@NotNull
                                        String name)
        (experimental) Returns a dependency by name.

        Fails if there is no dependency defined by that name or if type is not provided and there is more then one dependency type for this dependency.

        Parameters:
        name - The name of the dependency. This parameter is required.
        Returns:
        a copy (cannot be modified)
      • removeDependency

        @Stability(Experimental)
        public void removeDependency​(@NotNull
                                     String name,
                                     @Nullable
                                     DependencyType type)
        (experimental) Removes a dependency.

        Parameters:
        name - The name of the module to remove (without the version). This parameter is required.
        type - The dependency type.
      • removeDependency

        @Stability(Experimental)
        public void removeDependency​(@NotNull
                                     String name)
        (experimental) Removes a dependency.

        Parameters:
        name - The name of the module to remove (without the version). This parameter is required.
      • tryGetDependency

        @Stability(Experimental)
        @Nullable
        public Dependency tryGetDependency​(@NotNull
                                           String name,
                                           @Nullable
                                           DependencyType type)
        (experimental) Returns a dependency by name.

        Returns undefined if there is no dependency defined by that name or if type is not provided and there is more then one dependency type for this dependency.

        Parameters:
        name - The name of the dependency. This parameter is required.
        type - The dependency type.
        Returns:
        a copy (cannot be modified) or undefined if there is no match
      • tryGetDependency

        @Stability(Experimental)
        @Nullable
        public Dependency tryGetDependency​(@NotNull
                                           String name)
        (experimental) Returns a dependency by name.

        Returns undefined if there is no dependency defined by that name or if type is not provided and there is more then one dependency type for this dependency.

        Parameters:
        name - The name of the dependency. This parameter is required.
        Returns:
        a copy (cannot be modified) or undefined if there is no match
      • getAll

        @Stability(Experimental)
        @NotNull
        public List<Dependency> getAll()
        (experimental) A copy of all dependencies recorded for this project.

        The list is sorted by type->name->version