Class Project

  • All Implemented Interfaces:
    software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable
    Direct Known Subclasses:
    GitHubProject

    @Generated(value="jsii-pacmak/1.96.0 (build 921e240)",
               date="2024-03-28T21:16:42.781Z")
    @Stability(Experimental)
    public class Project
    extends software.constructs.Construct
    (experimental) Base project.
    • Field Detail

      • DEFAULT_TASK

        @Stability(Experimental)
        public static final String DEFAULT_TASK
        (experimental) The name of the default task (the task executed when projen is run without arguments).

        Normally this task should synthesize the project files.

    • Constructor Detail

      • Project

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

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

        @Stability(Experimental)
        public Project​(@NotNull
                       ProjectOptions options)
        Parameters:
        options - This parameter is required.
    • Method Detail

      • isProject

        @Stability(Experimental)
        @NotNull
        public static Boolean isProject​(@NotNull
                                        Object x)
        (experimental) Test whether the given construct is a project.

        Parameters:
        x - This parameter is required.
      • of

        @Stability(Experimental)
        @NotNull
        public static Project of​(@NotNull
                                 software.constructs.IConstruct construct)
        (experimental) Find the closest ancestor project for given construct.

        When given a project, this it the project itself.

        Parameters:
        construct - This parameter is required.
      • addExcludeFromCleanup

        @Stability(Experimental)
        public void addExcludeFromCleanup​(@NotNull
                                          @NotNull String... globs)
        (experimental) Exclude the matching files from pre-synth cleanup.

        Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.

        Parameters:
        globs - The glob patterns to match. This parameter is required.
      • addGitIgnore

        @Stability(Experimental)
        public void addGitIgnore​(@NotNull
                                 String pattern)
        (experimental) Adds a .gitignore pattern.

        Parameters:
        pattern - The glob pattern to ignore. This parameter is required.
      • addPackageIgnore

        @Stability(Experimental)
        public void addPackageIgnore​(@NotNull
                                     String _pattern)
        (experimental) Exclude these files from the bundled package.

        Implemented by project types based on the packaging mechanism. For example, NodeProject delegates this to .npmignore.

        Parameters:
        _pattern - The glob pattern to exclude. This parameter is required.
      • addTask

        @Stability(Experimental)
        @NotNull
        public Task addTask​(@NotNull
                            String name,
                            @Nullable
                            TaskOptions props)
        (experimental) Adds a new task to this project.

        This will fail if the project already has a task with this name.

        Parameters:
        name - The task name to add. This parameter is required.
        props - Task properties.
      • addTask

        @Stability(Experimental)
        @NotNull
        public Task addTask​(@NotNull
                            String name)
        (experimental) Adds a new task to this project.

        This will fail if the project already has a task with this name.

        Parameters:
        name - The task name to add. This parameter is required.
      • addTip

        @Stability(Deprecated)
        @Deprecated
        public void addTip​(@NotNull
                           String message)
        Deprecated.
        • use project.logger.info(message) to show messages during synthesis
        (deprecated) Prints a "tip" message during synthesis.

        Parameters:
        message - The message. This parameter is required.
      • annotateGenerated

        @Stability(Experimental)
        public void annotateGenerated​(@NotNull
                                      String _glob)
        (experimental) Consider a set of files as "generated".

        This method is implemented by derived classes and used for example, to add git attributes to tell GitHub that certain files are generated.

        Parameters:
        _glob - the glob pattern to match (could be a file path). This parameter is required.
      • postSynthesize

        @Stability(Experimental)
        public void postSynthesize()
        (experimental) Called after all components are synthesized.

        Order is not guaranteed.

      • preSynthesize

        @Stability(Experimental)
        public void preSynthesize()
        (experimental) Called before all components are synthesized.
      • removeTask

        @Stability(Experimental)
        @Nullable
        public Task removeTask​(@NotNull
                               String name)
        (experimental) Removes a task from a project.

        Parameters:
        name - The name of the task to remove. This parameter is required.
        Returns:
        The Task that was removed, otherwise undefined.
      • runTaskCommand

        @Stability(Experimental)
        @NotNull
        public String runTaskCommand​(@NotNull
                                     Task task)
        (experimental) Returns the shell command to execute in order to run a task.

        By default, this is npx projen@<version> <task>

        Parameters:
        task - The task for which the command is required. This parameter is required.
      • synth

        @Stability(Experimental)
        public void synth()
        (experimental) Synthesize all project files into outdir.

        1. Call "this.preSynthesize()"
        2. Delete all generated files
        3. Synthesize all subprojects
        4. Synthesize all components of this project
        5. Call "postSynthesize()" for all components of this project
        6. Call "this.postSynthesize()"
      • tryFindFile

        @Stability(Experimental)
        @Nullable
        public FileBase tryFindFile​(@NotNull
                                    String filePath)
        (experimental) Finds a file at the specified relative path within this project and all its subprojects.

        Parameters:
        filePath - The file path. This parameter is required.
        Returns:
        a FileBase or undefined if there is no file in that path
      • tryFindJsonFile

        @Stability(Deprecated)
        @Deprecated
        @Nullable
        public JsonFile tryFindJsonFile​(@NotNull
                                        String filePath)
        Deprecated.
        use tryFindObjectFile
        (deprecated) Finds a json file by name.

        Parameters:
        filePath - The file path. This parameter is required.
      • tryFindObjectFile

        @Stability(Experimental)
        @Nullable
        public ObjectFile tryFindObjectFile​(@NotNull
                                            String filePath)
        (experimental) Finds an object file (like JsonFile, YamlFile, etc.) by name.

        Parameters:
        filePath - The file path. This parameter is required.
      • tryRemoveFile

        @Stability(Experimental)
        @Nullable
        public FileBase tryRemoveFile​(@NotNull
                                      String filePath)
        (experimental) Finds a file at the specified relative path within this project and removes it.

        Parameters:
        filePath - The file path. This parameter is required.
        Returns:
        a FileBase if the file was found and removed, or undefined if the file was not found.
      • getBuildTask

        @Stability(Experimental)
        @NotNull
        public Task getBuildTask()
      • getCommitGenerated

        @Stability(Experimental)
        @NotNull
        public Boolean getCommitGenerated()
        (experimental) Whether to commit the managed files by default.
      • getCompileTask

        @Stability(Experimental)
        @NotNull
        public Task getCompileTask()
      • getComponents

        @Stability(Experimental)
        @NotNull
        public List<Component> getComponents()
        (experimental) Returns all the components within this project.
      • getDeps

        @Stability(Experimental)
        @NotNull
        public Dependencies getDeps()
        (experimental) Project dependencies.
      • getEjected

        @Stability(Experimental)
        @NotNull
        public Boolean getEjected()
        (experimental) Whether or not the project is being ejected.
      • getFiles

        @Stability(Experimental)
        @NotNull
        public List<FileBase> getFiles()
        (experimental) All files in this project.
      • getGitattributes

        @Stability(Experimental)
        @NotNull
        public GitAttributesFile getGitattributes()
        (experimental) The .gitattributes file for this repository.
      • getGitignore

        @Stability(Experimental)
        @NotNull
        public IgnoreFile getGitignore()
        (experimental) .gitignore.
      • getLogger

        @Stability(Experimental)
        @NotNull
        public Logger getLogger()
        (experimental) Logging utilities.
      • getName

        @Stability(Experimental)
        @NotNull
        public String getName()
        (experimental) Project name.
      • getOutdir

        @Stability(Experimental)
        @NotNull
        public String getOutdir()
        (experimental) Absolute output directory of this project.
      • getPackageTask

        @Stability(Experimental)
        @NotNull
        public Task getPackageTask()
      • getPostCompileTask

        @Stability(Experimental)
        @NotNull
        public Task getPostCompileTask()
      • getPreCompileTask

        @Stability(Experimental)
        @NotNull
        public Task getPreCompileTask()
      • getProjectBuild

        @Stability(Experimental)
        @NotNull
        public ProjectBuild getProjectBuild()
        (experimental) Manages the build process of the project.
      • getProjenCommand

        @Stability(Experimental)
        @NotNull
        public String getProjenCommand()
        (experimental) The command to use in order to run the projen CLI.
      • getRoot

        @Stability(Experimental)
        @NotNull
        public Project getRoot()
        (experimental) The root project.
      • getSubprojects

        @Stability(Experimental)
        @NotNull
        public List<Project> getSubprojects()
        (experimental) Returns all the subprojects within this project.
      • getTasks

        @Stability(Experimental)
        @NotNull
        public Tasks getTasks()
        (experimental) Project tasks.
      • getTestTask

        @Stability(Experimental)
        @NotNull
        public Task getTestTask()
      • getDefaultTask

        @Stability(Experimental)
        @Nullable
        public Task getDefaultTask()
        (experimental) This is the "default" task, the one that executes "projen".

        Undefined if the project is being ejected.

      • getInitProject

        @Stability(Experimental)
        @Nullable
        public InitProject getInitProject()
        (experimental) The options used when this project is bootstrapped via projen new.

        It includes the original set of options passed to the CLI and also the JSII FQN of the project type.

      • getParent

        @Stability(Experimental)
        @Nullable
        public Project getParent()
        (experimental) A parent project.

        If undefined, this is the root project.