Package org.apache.maven.api.services
Interface ProjectManager
- All Superinterfaces:
Service
- All Known Implementing Classes:
DefaultProjectManager
Interface to manage the project during its lifecycle.
- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCompileSourceRoot
(Project project, ProjectScope scope, Path sourceRoot) Add a compilation source root to the given project for the given scope.void
addResource
(Project project, ProjectScope scope, Resource resource) Add a resource set to the given project for the given scope.void
attachArtifact
(Project project, Artifact artifact, Path path) default void
attachArtifact
(Session session, Project project, String type, Path path) default void
attachArtifact
(Session session, Project project, Path path) getAllArtifacts
(Project project) Returns project's all artifacts as immutable collection.getAttachedArtifacts
(Project project) Returns an immutable collection of attached artifacts for given project.getCompileSourceRoots
(Project project, ProjectScope scope) Obtain an immutable list of compile source roots for the given project and scope.getExecutionProject
(Project project) Returns the path to the built project artifact file, if the project has been built.getProperties
(Project project) Returns an immutable map of the project properties.getRemotePluginRepositories
(Project project) Returns an immutable list of project remote plugin repositories (directly specified or inherited).getRemoteProjectRepositories
(Project project) Returns an immutable list of project remote repositories (directly specified or inherited).getResources
(Project project, ProjectScope scope) Get the list of resources for the given project and scopevoid
setProperty
(Project project, String key, String value) Set a given project property.
-
Method Details
-
getPath
Returns the path to the built project artifact file, if the project has been built.- Returns:
- the path of the built project artifact
-
getAttachedArtifacts
Returns an immutable collection of attached artifacts for given project. -
getAllArtifacts
Returns project's all artifacts as immutable collection. The list contains all artifacts, even the attached ones, if any. Hence, the list returned by this method depends on which lifecycle step of the build was it invoked. The head of returned list is result ofProject.getArtifacts()
method, so same applies here: the list can have minimum of one element. The maximum number of elements is in turn dependent on build configuration and lifecycle phase when this method was invoked (i.e. is javadoc jar built and attached, is sources jar built attached, are all the artifact signed, etc.).This method is shorthand for
Project.getArtifacts()
andgetAttachedArtifacts(Project)
methods.- See Also:
-
attachArtifact
-
attachArtifact
-
attachArtifact
-
getCompileSourceRoots
Obtain an immutable list of compile source roots for the given project and scope. Paths are absolute.- Parameters:
project
- the projectscope
- the scope, i.e. usually main or test- Returns:
- the list of compile source roots
-
addCompileSourceRoot
void addCompileSourceRoot(@Nonnull Project project, @Nonnull ProjectScope scope, @Nonnull Path sourceRoot) Add a compilation source root to the given project for the given scope. The path will be transformed into an absolute path and added to the list for the given scope, if not already present.- Parameters:
project
- the projectscope
- the scope, i.e. usually main or testsourceRoot
- the new source root
-
getResources
Get the list of resources for the given project and scope- Parameters:
project
- the projectscope
- the scope, i.e. usually main or test- Returns:
- the list of resources
-
addResource
Add a resource set to the given project for the given scope.- Parameters:
project
- the projectscope
- the scope, i.e. usually main or testresource
- the resource set to add
-
getRemoteProjectRepositories
Returns an immutable list of project remote repositories (directly specified or inherited).- Parameters:
project
- the project
-
getRemotePluginRepositories
Returns an immutable list of project remote plugin repositories (directly specified or inherited).- Parameters:
project
- the project
-
getProperties
Returns an immutable map of the project properties.- See Also:
-
setProperty
Set a given project property.- Parameters:
project
- the project to modifykey
- they property's keyvalue
- the value ornull
to unset the property
-
getExecutionProject
-