Class DefaultProject

java.lang.Object
org.apache.maven.internal.impl.DefaultProject
All Implemented Interfaces:
Project

public class DefaultProject extends Object implements Project
  • Constructor Details

  • Method Details

    • getSession

      public InternalMavenSession getSession()
    • getProject

      public MavenProject getProject()
    • getGroupId

      @Nonnull public String getGroupId()
      Description copied from interface: Project
      Returns the project groupId.
      Specified by:
      getGroupId in interface Project
    • getArtifactId

      @Nonnull public String getArtifactId()
      Description copied from interface: Project
      Returns the project artifactId.
      Specified by:
      getArtifactId in interface Project
    • getVersion

      @Nonnull public String getVersion()
      Description copied from interface: Project
      Returns the project version.
      Specified by:
      getVersion in interface Project
    • getArtifacts

      @Nonnull public List<Artifact> getArtifacts()
      Description copied from interface: Project
      Returns the project artifacts as immutable list. Elements are the project POM artifact and the artifact produced by this project build, if applicable. Hence, the returned list may have one or two elements (never less than 1, never more than 2), depending on project packaging.

      The list's first element is ALWAYS the project POM artifact. Presence of second element in the list depends solely on the project packaging.

      Specified by:
      getArtifacts in interface Project
      See Also:
    • getPackaging

      @Nonnull public Packaging getPackaging()
      Description copied from interface: Project
      Returns the project packaging.

      Note: unlike in legacy code, logical checks against string representing packaging (returned by this method) are NOT recommended (code like "pom".equals(project.getPackaging) must be avoided). Use method Project.getArtifacts() to gain access to POM or build artifact.

      Specified by:
      getPackaging in interface Project
      See Also:
    • getModel

      @Nonnull public Model getModel()
      Description copied from interface: Project
      Returns the project model.
      Specified by:
      getModel in interface Project
    • getPomPath

      @Nonnull public Path getPomPath()
      Description copied from interface: Project
      Returns the path to the pom file for this project. A project is usually read from a file named pom.xml, which contains the model in an XML form. When a custom org.apache.maven.api.spi.ModelParser is used, the path may point to a non XML file.

      The POM path is also used to define the base directory of the project.

      Specified by:
      getPomPath in interface Project
      Returns:
      the path of the pom
      See Also:
    • getBasedir

      public Path getBasedir()
      Description copied from interface: Project
      Returns the project base directory, i.e. the directory containing the project. A project is usually read from the file system and this will point to the directory containing the POM file.
      Specified by:
      getBasedir in interface Project
      Returns:
      the path of the directory containing the project
    • getDependencies

      @Nonnull public List<DependencyCoordinate> getDependencies()
      Description copied from interface: Project
      Returns the project direct dependencies (directly specified or inherited).
      Specified by:
      getDependencies in interface Project
    • getManagedDependencies

      @Nonnull public List<DependencyCoordinate> getManagedDependencies()
      Description copied from interface: Project
      Returns the project managed dependencies (directly specified or inherited).
      Specified by:
      getManagedDependencies in interface Project
    • isTopProject

      public boolean isTopProject()
      Description copied from interface: Project
      Returns a boolean indicating if the project is the top level project for this reactor build. The top level project may be different from the rootDirectory, especially if a subtree of the project is being built, either because Maven has been launched in a subdirectory or using a -f option.
      Specified by:
      isTopProject in interface Project
      Returns:
      true if the project is the top level project for this build
    • isRootProject

      public boolean isRootProject()
      Description copied from interface: Project
      Returns a boolean indicating if the project is a root project, meaning that the Project.getRootDirectory() and Project.getBasedir() points to the same directory, and that either Model.isRoot() is true or that basedir contains a .mvn child directory.
      Specified by:
      isRootProject in interface Project
      Returns:
      true if the project is the root project
      See Also:
    • getRootDirectory

      public Path getRootDirectory()
      Description copied from interface: Project
      Gets the root directory of the project, which is the parent directory containing the .mvn directory or flagged with root="true".
      Specified by:
      getRootDirectory in interface Project
      See Also:
    • getParent

      public Optional<Project> getParent()
      Description copied from interface: Project
      Returns project parent project, if any.
      Specified by:
      getParent in interface Project