Class DefaultProject
- All Implemented Interfaces:
Project
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the project artifactId.Returns the project artifacts as immutable list.Returns the project base directory, i.e.Returns all active profiles for the current project build.Returns all profiles defined in this project.Returns the project direct dependencies (directly specified or inherited).Returns all active profiles for this project and all of its parent projects.Returns all profiles defined in this project and all of its parent projects.Returns the project groupId.Returns the project managed dependencies (directly specified or inherited).getModel()
Returns the project model.Returns the project packaging.Returns project parent project, if any.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 theProject.getRootDirectory()
andProject.getBasedir()
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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.maven.api.Project
getBuild, getId, getLanguage, getMainArtifact, getPomArtifact
-
Constructor Details
-
DefaultProject
-
-
Method Details
-
getSession
-
getProject
-
getGroupId
Description copied from interface:Project
Returns the project groupId..- Specified by:
getGroupId
in interfaceProject
- Returns:
- the project groupId
-
getArtifactId
Description copied from interface:Project
Returns the project artifactId..- Specified by:
getArtifactId
in interfaceProject
- Returns:
- the project artifactId
-
getVersion
Description copied from interface:Project
Returns the project version..- Specified by:
getVersion
in interfaceProject
- Returns:
- the project version
-
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 interfaceProject
- Returns:
- the project artifacts as immutable list
- See Also:
-
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 methodProject.getArtifacts()
to gain access to POM or build artifact.- Specified by:
getPackaging
in interfaceProject
- Returns:
- the project packaging
- See Also:
-
getModel
Description copied from interface:Project
Returns the project model.. -
getPomPath
Description copied from interface:Project
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.
- Specified by:
getPomPath
in interfaceProject
- Returns:
- the path of the pom
- See Also:
-
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 interfaceProject
- Returns:
- the path of the directory containing the project
-
getDependencies
Description copied from interface:Project
Returns the project direct dependencies (directly specified or inherited)..- Specified by:
getDependencies
in interfaceProject
- Returns:
- the project direct dependencies (directly specified or inherited)
-
getManagedDependencies
Description copied from interface:Project
Returns the project managed dependencies (directly specified or inherited)..- Specified by:
getManagedDependencies
in interfaceProject
- Returns:
- the project managed dependencies (directly specified or inherited)
-
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 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.- Specified by:
isTopProject
in interfaceProject
- 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 theProject.getRootDirectory()
andProject.getBasedir()
points to the same directory, and that eitherModel.isRoot()
istrue
or thatbasedir
contains a.mvn
child directory.- Specified by:
isRootProject
in interfaceProject
- Returns:
true
if the project is the root project- See Also:
-
getRootDirectory
Description copied from interface:Project
Gets the root directory of the project, which is the parent directory containing the.mvn
directory or flagged withroot="true"
.- Specified by:
getRootDirectory
in interfaceProject
- Returns:
- the root directory of the project
- See Also:
-
getParent
Description copied from interface:Project
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. -
getDeclaredProfiles
Description copied from interface:Project
Returns all profiles defined in this project.This method returns only the profiles defined directly in the current project's POM and does not include profiles from parent projects.
- Specified by:
getDeclaredProfiles
in interfaceProject
- Returns:
- a non-null, possibly empty list of profiles defined in this project
- See Also:
-
getEffectiveProfiles
Description copied from interface:Project
Returns all profiles defined in this project and all of its parent projects.This method traverses the parent hierarchy and includes profiles defined in parent POMs. The returned list contains profiles from the current project and all of its ancestors in the project inheritance chain.
- Specified by:
getEffectiveProfiles
in interfaceProject
- Returns:
- a non-null, possibly empty list of all profiles from this project and its parents
- See Also:
-
getDeclaredActiveProfiles
Description copied from interface:Project
Returns all active profiles for the current project build.Active profiles are those that have been explicitly activated through one of the following means:
- Command line activation using the -P flag
- Maven settings activation in settings.xml via <activeProfiles>
- Automatic activation via <activation> conditions
- The default active profile (marked with <activeByDefault>true</activeByDefault>)
The active profiles control various aspects of the build configuration including but not limited to dependencies, plugins, properties, and build resources.
- Specified by:
getDeclaredActiveProfiles
in interfaceProject
- Returns:
- a non-null, possibly empty list of active profiles for this project
- See Also:
-
getEffectiveActiveProfiles
Description copied from interface:Project
Returns all active profiles for this project and all of its parent projects.This method traverses the parent hierarchy and collects all active profiles from the current project and its ancestors. Active profiles are those that meet the activation criteria through explicit activation or automatic conditions.
The combined set of active profiles from the entire project hierarchy affects the effective build configuration.
- Specified by:
getEffectiveActiveProfiles
in interfaceProject
- Returns:
- a non-null, possibly empty list of all active profiles from this project and its parents
- See Also:
-