Class MavenProject
- All Implemented Interfaces:
Cloneable
The values in the model remain untouched but during the process of building a project notions like inheritance and interpolation can be added. This allows to have an entity which is useful in a runtime while preserving the model so that it can be marshalled and unmarshalled without being tainted by runtime requirements.
With changes during 3.2.2 release MavenProject is closer to being immutable after construction with the removal of
all components from this class, and the upfront construction taken care of entirely by the ProjectBuilder
.
There is still the issue of having to run the lifecycle in order to find all the compile source roots and resource
directories but I hope to take care of this during the Maven 4.0 release (jvz).
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMavenProject
(org.apache.maven.api.model.Model model) MavenProject
(Model model) MavenProject
(MavenProject project) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttachedArtifact
(Artifact artifact) Deprecated.void
addCompileSourceRoot
(String path) void
addContributor
(Contributor contributor) void
addDeveloper
(Developer developer) void
addLicense
(License license) void
addLifecyclePhase
(String lifecyclePhase) Warning: This is an internal utility method that is only public for technical reasons, it is not part of the public API.void
addMailingList
(MailingList mailingList) void
addProjectReference
(MavenProject project) void
addResource
(Resource resource) void
addScriptSourceRoot
(String path) Deprecated.void
void
addTestResource
(Resource testResource) void
attachArtifact
(String type, String classifier, File file) Deprecated.Use MavenProjectHelper.attachArtifact(..) instead.clone()
createArtifacts
(ArtifactFactory artifactFactory, String inheritedScope, ArtifactFilter filter) Deprecated.boolean
All dependencies that this project has, including transitive ones.Returns a read-only list of the attached artifacts to this project.getBuild()
org.codehaus.plexus.classworlds.realm.ClassRealm
Gets the project's class realm.Deprecated.Deprecated.getContextValue
(String key) Returns context value of this project associated with the given key or null if this project has no such value.Deprecated.Deprecated.Deprecated.org.eclipse.aether.graph.DependencyFilter
Gets the dependency filter used to exclude shared extension artifacts from plugin realms.getFile()
getGoalConfiguration
(String pluginGroupId, String pluginArtifactId, String executionId, String goalId) getId()
Gets the identifiers of all profiles that contributed to this project's effective model.getModel()
getModulePathAdjustment
(MavenProject moduleProject) Deprecated.getName()
Returns the project corresponding to a declared parent.Deprecated.protected ArtifactRepository
List<org.eclipse.aether.repository.RemoteRepository>
List<org.eclipse.aether.repository.RemoteRepository>
Deprecated.Deprecated.getReportConfiguration
(String pluginGroupId, String pluginArtifactId, String reportSetId) Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.getScm()
Deprecated.protected ArtifactRepository
Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.getUrl()
int
hashCode()
boolean
hasLifecyclePhase
(String phase) Warning: This is an internal utility method that is only public for technical reasons, it is not part of the public API.boolean
boolean
replaceWithActiveArtifact
(Artifact pluginArtifact) Deprecated.void
setActiveProfiles
(List<Profile> activeProfiles) void
setArtifact
(Artifact artifact) void
setArtifactFilter
(ArtifactFilter artifactFilter) Sets the scope filter to select the artifacts being exposed to the currently executed mojo.void
setArtifactId
(String artifactId) void
setArtifacts
(Set<Artifact> artifacts) protected void
setAttachedArtifacts
(List<Artifact> attachedArtifacts) void
void
setCiManagement
(CiManagement ciManagement) void
setClassRealm
(org.codehaus.plexus.classworlds.realm.ClassRealm classRealm) Sets the project's class realm.void
setCollectedProjects
(List<MavenProject> collectedProjects) protected void
setCompileSourceRoots
(List<String> compileSourceRoots) void
setContextValue
(String key, Object value) Sets the value of the context value of this project identified by the given key.void
setContributors
(List<Contributor> contributors) void
setDependencies
(List<Dependency> dependencies) void
setDependencyArtifacts
(Set<Artifact> dependencyArtifacts) Deprecated.void
setDescription
(String description) void
setDevelopers
(List<Developer> developers) void
setDistributionManagement
(DistributionManagement distributionManagement) void
setExecutionProject
(MavenProject executionProject) void
setExecutionRoot
(boolean executionRoot) void
setExtensionArtifacts
(Set<Artifact> extensionArtifacts) Deprecated.void
setExtensionDependencyFilter
(org.eclipse.aether.graph.DependencyFilter extensionDependencyFilter) Sets the artifact filter used to exclude shared extension artifacts from plugin realms.void
void
setGroupId
(String groupId) void
setInceptionYear
(String inceptionYear) void
setInjectedProfileIds
(String source, List<String> injectedProfileIds) void
setIssueManagement
(IssueManagement issueManagement) void
setLicenses
(List<License> licenses) void
setMailingLists
(List<MailingList> mailingLists) void
void
void
setModelVersion
(String pomVersion) void
void
setOrganization
(Organization organization) void
setOriginalModel
(Model originalModel) void
setPackaging
(String packaging) void
setParent
(MavenProject parent) void
setParentArtifact
(Artifact parentArtifact) void
setParentFile
(File parentFile) void
setPluginArtifactRepositories
(List<ArtifactRepository> pluginArtifactRepositories) void
setPluginArtifacts
(Set<Artifact> pluginArtifacts) void
setPomFile
(File file) Sets projectfile
without changing projectbasedir
.void
setProjectBuildingRequest
(ProjectBuildingRequest projectBuildingRequest) Deprecated.void
setReleaseArtifactRepository
(ArtifactRepository releaseArtifactRepository) void
setRemoteArtifactRepositories
(List<ArtifactRepository> remoteArtifactRepositories) void
setReportArtifacts
(Set<Artifact> reportArtifacts) Deprecated.void
setReporting
(Reporting reporting) Deprecated.void
setResolvedArtifacts
(Set<Artifact> artifacts) Sets the transitive dependency artifacts that have been resolved/collected for this project.void
protected void
setScriptSourceRoots
(List<String> scriptSourceRoots) Deprecated.void
setSnapshotArtifactRepository
(ArtifactRepository snapshotArtifactRepository) protected void
setTestCompileSourceRoots
(List<String> testCompileSourceRoots) void
void
setVersion
(String version) toString()
Default toStringvoid
writeModel
(Writer writer) Deprecated.UseModelWriter
.void
writeOriginalModel
(Writer writer) Deprecated.UseModelWriter
.
-
Field Details
-
EMPTY_PROJECT_GROUP_ID
- See Also:
-
EMPTY_PROJECT_ARTIFACT_ID
- See Also:
-
EMPTY_PROJECT_VERSION
- See Also:
-
-
Constructor Details
-
MavenProject
public MavenProject() -
MavenProject
public MavenProject(org.apache.maven.api.model.Model model) -
MavenProject
-
MavenProject
-
-
Method Details
-
getParentFile
-
setParentFile
-
getArtifact
-
setArtifact
-
getModel
-
getParent
Returns the project corresponding to a declared parent.- Returns:
- the parent, or null if no parent is declared or there was an error building it
-
setParent
-
hasParent
public boolean hasParent() -
getFile
-
setFile
-
setPomFile
Sets projectfile
without changing projectbasedir
.- Since:
- 3.2.4
-
getBasedir
-
setDependencies
-
getDependencies
-
getDependencyManagement
-
addCompileSourceRoot
-
addTestCompileSourceRoot
-
getCompileSourceRoots
-
getTestCompileSourceRoots
-
getCompileClasspathElements
-
getTestClasspathElements
-
getRuntimeClasspathElements
-
setModelVersion
-
getModelVersion
-
getId
-
setGroupId
-
getGroupId
-
setArtifactId
-
getArtifactId
-
setName
-
getName
-
setVersion
-
getVersion
-
getPackaging
-
setPackaging
-
setInceptionYear
-
getInceptionYear
-
setUrl
-
getUrl
-
getPrerequisites
-
setIssueManagement
-
getCiManagement
-
setCiManagement
-
getIssueManagement
-
setDistributionManagement
-
getDistributionManagement
-
setDescription
-
getDescription
-
setOrganization
-
getOrganization
-
setScm
-
getScm
-
setMailingLists
-
getMailingLists
-
addMailingList
-
setDevelopers
-
getDevelopers
-
addDeveloper
-
setContributors
-
getContributors
-
addContributor
-
setBuild
-
getBuild
-
getResources
-
getTestResources
-
addResource
-
addTestResource
-
setLicenses
-
getLicenses
-
addLicense
-
setArtifacts
-
getArtifacts
All dependencies that this project has, including transitive ones. Contents are lazily populated, so depending on what phases have run dependencies in some scopes won't be included. e.g. if only compile phase has run, dependencies with scope test won't be included. -
getArtifactMap
-
setPluginArtifacts
-
getPluginArtifacts
-
getPluginArtifactMap
-
setParentArtifact
-
getParentArtifact
-
getRepositories
-
getBuildPlugins
-
getModules
-
getPluginManagement
-
setRemoteArtifactRepositories
-
getRemoteArtifactRepositories
-
setPluginArtifactRepositories
-
getPluginArtifactRepositories
- Returns:
- a list of ArtifactRepository objects constructed from the Repository objects returned by getPluginRepositories.
-
getDistributionManagementArtifactRepository
-
getPluginRepositories
-
getRemoteProjectRepositories
-
getRemotePluginRepositories
-
setActiveProfiles
-
getActiveProfiles
-
setInjectedProfileIds
-
getInjectedProfileIds
Gets the identifiers of all profiles that contributed to this project's effective model. This includes active profiles from the project's POM and all its parent POMs as well as from external sources like thesettings.xml
. The profile identifiers are grouped by the identifier of their source, e.g.<groupId>:<artifactId>:<version>
for a POM profile orexternal
for profiles from thesettings.xml
.- Returns:
- The identifiers of all injected profiles, indexed by the source from which the profiles originated, never
null
.
-
addAttachedArtifact
Deprecated.Please useMavenProjectHelper
Add or replace an artifact. This method is now deprecated. Use the @{MavenProjectHelper} to attach artifacts to a project. In spite of the 'throws' declaration on this API, this method has never thrown an exception since Maven 3.0.x. Historically, it logged and ignored a second addition of the same g/a/v/c/t. Now it replaces the file for the artifact, so that plugins (e.g. shade) can change the pathname of the file for a particular set of coordinates.- Parameters:
artifact
- the artifact to add or replace.- Throws:
DuplicateArtifactAttachmentException
- will never happen but leave it for backward compatibility
-
getAttachedArtifacts
Returns a read-only list of the attached artifacts to this project.- Returns:
- the attached artifacts of this project
-
getGoalConfiguration
-
getExecutionProject
-
setExecutionProject
-
getCollectedProjects
-
setCollectedProjects
-
getDependencyArtifacts
Deprecated.Direct dependencies that this project has. -
setDependencyArtifacts
Deprecated. -
setReleaseArtifactRepository
-
setSnapshotArtifactRepository
-
setOriginalModel
-
getOriginalModel
-
setManagedVersionMap
-
getManagedVersionMap
-
equals
-
hashCode
public int hashCode() -
getBuildExtensions
-
addProjectReference
-
getProperties
-
getFilters
-
getProjectReferences
-
isExecutionRoot
public boolean isExecutionRoot() -
setExecutionRoot
public void setExecutionRoot(boolean executionRoot) -
getDefaultGoal
-
getPlugin
-
toString
Default toString -
clone
-
setModel
-
setAttachedArtifacts
-
setCompileSourceRoots
-
setTestCompileSourceRoots
-
getReleaseArtifactRepository
-
getSnapshotArtifactRepository
-
setContextValue
Sets the value of the context value of this project identified by the given key. If the supplied value isnull
, the context value is removed from this project. Context values are intended to allow core extensions to associate derived state with project instances. -
getContextValue
Returns context value of this project associated with the given key or null if this project has no such value. -
setClassRealm
public void setClassRealm(org.codehaus.plexus.classworlds.realm.ClassRealm classRealm) Sets the project's class realm. Warning: This is an internal utility method that is only public for technical reasons, it is not part of the public API. In particular, this method can be changed or deleted without prior notice and must not be used by plugins.- Parameters:
classRealm
- The class realm hosting the build extensions of this project, may benull
.
-
getClassRealm
public org.codehaus.plexus.classworlds.realm.ClassRealm getClassRealm()Gets the project's class realm. This class realm hosts the build extensions of the project. Warning: This is an internal utility method that is only public for technical reasons, it is not part of the public API. In particular, this method can be changed or deleted without prior notice and must not be used by plugins.- Returns:
- The project's class realm or
null
.
-
setExtensionDependencyFilter
public void setExtensionDependencyFilter(org.eclipse.aether.graph.DependencyFilter extensionDependencyFilter) Sets the artifact filter used to exclude shared extension artifacts from plugin realms. Warning: This is an internal utility method that is only public for technical reasons, it is not part of the public API. In particular, this method can be changed or deleted without prior notice and must not be used by plugins.- Parameters:
extensionDependencyFilter
- The dependency filter to apply to plugins, may benull
.
-
getExtensionDependencyFilter
public org.eclipse.aether.graph.DependencyFilter getExtensionDependencyFilter()Gets the dependency filter used to exclude shared extension artifacts from plugin realms. Warning: This is an internal utility method that is only public for technical reasons, it is not part of the public API. In particular, this method can be changed or deleted without prior notice and must not be used by plugins.- Returns:
- The dependency filter or
null
.
-
setResolvedArtifacts
Sets the transitive dependency artifacts that have been resolved/collected for this project. Warning: This is an internal utility method that is only public for technical reasons, it is not part of the public API. In particular, this method can be changed or deleted without prior notice and must not be used by plugins.- Parameters:
artifacts
- The set of artifacts, may benull
.
-
setArtifactFilter
Sets the scope filter to select the artifacts being exposed to the currently executed mojo. Warning: This is an internal utility method that is only public for technical reasons, it is not part of the public API. In particular, this method can be changed or deleted without prior notice and must not be used by plugins.- Parameters:
artifactFilter
- The artifact filter, may benull
to exclude all artifacts.
-
hasLifecyclePhase
Warning: This is an internal utility method that is only public for technical reasons, it is not part of the public API. In particular, this method can be changed or deleted without prior notice and must not be used by plugins.- Parameters:
phase
- The phase to check for, must not benull
.- Returns:
true
if the phase has been seen.
-
addLifecyclePhase
Warning: This is an internal utility method that is only public for technical reasons, it is not part of the public API. In particular, this method can be changed or deleted without prior notice and must not be used by plugins.- Parameters:
lifecyclePhase
- The lifecycle phase to add, must not benull
.
-
getModulePathAdjustment
Deprecated.- Throws:
IOException
-
createArtifacts
@Deprecated public Set<Artifact> createArtifacts(ArtifactFactory artifactFactory, String inheritedScope, ArtifactFilter filter) throws InvalidDependencyVersionException Deprecated. -
setScriptSourceRoots
Deprecated. -
addScriptSourceRoot
Deprecated. -
getScriptSourceRoots
Deprecated. -
getCompileArtifacts
Deprecated. -
getCompileDependencies
Deprecated. -
getTestArtifacts
Deprecated. -
getTestDependencies
Deprecated. -
getRuntimeDependencies
Deprecated. -
getRuntimeArtifacts
Deprecated. -
getSystemClasspathElements
@Deprecated public List<String> getSystemClasspathElements() throws DependencyResolutionRequiredExceptionDeprecated. -
getSystemArtifacts
Deprecated. -
getSystemDependencies
Deprecated. -
setReporting
Deprecated. -
getReporting
Deprecated. -
setReportArtifacts
Deprecated. -
getReportArtifacts
Deprecated. -
getReportArtifactMap
Deprecated. -
setExtensionArtifacts
Deprecated. -
getExtensionArtifacts
Deprecated. -
getExtensionArtifactMap
Deprecated. -
getReportPlugins
Deprecated. -
getReportConfiguration
@Deprecated public Xpp3Dom getReportConfiguration(String pluginGroupId, String pluginArtifactId, String reportSetId) Deprecated. -
attachArtifact
Deprecated.Use MavenProjectHelper.attachArtifact(..) instead. -
writeModel
Deprecated.UseModelWriter
.- Throws:
IOException
-
writeOriginalModel
Deprecated.UseModelWriter
.- Throws:
IOException
-
replaceWithActiveArtifact
Deprecated. -
getProjectBuildingRequest
Deprecated.Gets the project building request from which this project instance was created. Warning: This is a utility method that is meant to assist integrators of Maven, it must not be used by Maven plugins.- Returns:
- The project building request or
null
. - Since:
- 2.1
-
setProjectBuildingRequest
Deprecated.Sets the project building request from which this project instance was created. Warning: This is a utility method that is meant to assist integrators of Maven, it must not be used by Maven plugins.- Parameters:
projectBuildingRequest
- The project building request, may benull
.- Since:
- 2.1
-
MavenProjectHelper