Interface Project
- All Known Implementing Classes:
DefaultProject
ProjectBuilder
service.
Such objects are immutable and plugin that wish to modify such objects
need to do so using the ProjectManager
service.
Projects are created using the ProjectBuilder
from a POM file
(usually named pom.xml
) on the file system.
The getPomPath()
will point to the POM file and the
getBasedir()
to the directory parent containing the
POM file.
- Since:
- 4.0.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturns the project artifactId.Returns the project artifacts as immutable list.Returns the project base directory, i.e.default Build
getBuild()
Shorthand method.Returns the project direct dependencies (directly specified or inherited).Returns the project groupId.default String
getId()
Returns the project ID, usable as key.default Language
Returns the project language.default Optional
<ProducedArtifact> Returns the project main artifact, which is the artifact produced by this project build, if applicable.Returns the project managed dependencies (directly specified or inherited).getModel()
Returns the project model.Returns the project packaging.Returns project parent project, if any.default ProducedArtifact
Returns the project POM artifact, which is the artifact of the POM of this project.Returns the path to the pom file for this project.Gets the root directory of the project, which is the parent directory containing the.mvn
directory or flagged withroot="true"
.Returns the project version.boolean
Returns a boolean indicating if the project is a root project, meaning that thegetRootDirectory()
andgetBasedir()
points to the same directory, and that eitherModel.isRoot()
istrue
or thatbasedir
contains a.mvn
child directory.boolean
Returns a boolean indicating if the project is the top level project for this reactor build.
-
Method Details
-
getGroupId
Returns the project groupId. -
getArtifactId
Returns the project artifactId. -
getVersion
Returns the project version. -
getPackaging
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 methodgetArtifacts()
to gain access to POM or build artifact.- See Also:
-
getLanguage
Returns the project language. It is by default determined bygetPackaging()
.- See Also:
-
getPomArtifact
Returns the project POM artifact, which is the artifact of the POM of this project. Every project have a POM artifact, even if the existence of backing POM file is NOT a requirement (i.e. for some transient projects).- See Also:
-
getMainArtifact
Returns the project main artifact, which is the artifact produced by this project build, if applicable. This artifact MAY be absent if the project is actually not producing any main artifact (i.e. "pom" packaging).- See Also:
-
getArtifacts
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.
- See Also:
-
getModel
Returns the project model. -
getBuild
Shorthand method. -
getPomPath
Returns the path to the pom file for this project. A project is usually read from a file namedpom.xml
, which contains the model in an XML form. When a customorg.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.
- Returns:
- the path of the pom
- See Also:
-
getBasedir
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.- Returns:
- the path of the directory containing the project
-
getDependencies
Returns the project direct dependencies (directly specified or inherited). -
getManagedDependencies
Returns the project managed dependencies (directly specified or inherited). -
getId
Returns the project ID, usable as key. -
isTopProject
boolean isTopProject()Returns a boolean indicating if the project is the top level project for this reactor build. The top level project may be different from therootDirectory
, especially if a subtree of the project is being built, either because Maven has been launched in a subdirectory or using a-f
option.- Returns:
true
if the project is the top level project for this build
-
isRootProject
boolean isRootProject()Returns a boolean indicating if the project is a root project, meaning that thegetRootDirectory()
andgetBasedir()
points to the same directory, and that eitherModel.isRoot()
istrue
or thatbasedir
contains a.mvn
child directory.- Returns:
true
if the project is the root project- See Also:
-
getRootDirectory
Gets the root directory of the project, which is the parent directory containing the.mvn
directory or flagged withroot="true"
.- Throws:
IllegalStateException
- if the root directory could not be found- See Also:
-
getParent
Returns project parent project, if any.Note that the model may have a parent defined, but an empty parent project may be returned if the parent comes from a remote repository, as a
Project
must refer to a buildable project.- Returns:
- an optional containing the parent project
- See Also:
-