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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMavenProject(org.apache.maven.model.Model model) MavenProject(MavenProject project) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttachedArtifact(org.apache.maven.artifact.Artifact artifact) Deprecated.voidaddCompileSourceRoot(String path) Adds the specified path to the list of compile source roots for this project.voidaddContributor(org.apache.maven.model.Contributor contributor) voidaddDeveloper(org.apache.maven.model.Developer developer) voidaddLicense(org.apache.maven.model.License license) voidaddLifecyclePhase(String lifecyclePhase) Warning: This is an internal utility method that is only public for technical reasons, it is not part of the public API.voidaddMailingList(org.apache.maven.model.MailingList mailingList) voidaddProjectReference(MavenProject project) voidaddResource(org.apache.maven.model.Resource resource) voidaddScriptSourceRoot(String path) Deprecated.voidAdds the specified path to the list of test compile source roots for this project.voidaddTestResource(org.apache.maven.model.Resource testResource) voidattachArtifact(String type, String classifier, File file) Deprecated.Use MavenProjectHelper.attachArtifact(..) instead.clone()Set<org.apache.maven.artifact.Artifact> createArtifacts(ArtifactFactory artifactFactory, String inheritedScope, org.apache.maven.artifact.resolver.filter.ArtifactFilter filter) Deprecated.booleanList<org.apache.maven.model.Profile> org.apache.maven.artifact.ArtifactSet<org.apache.maven.artifact.Artifact> All dependencies that this project has, including transitive ones.List<org.apache.maven.artifact.Artifact> Returns a mutable list of the attached artifacts to this project.org.apache.maven.model.BuildgetBuild()List<org.apache.maven.model.Extension> List<org.apache.maven.model.Plugin> org.apache.maven.model.CiManagementorg.codehaus.plexus.classworlds.realm.ClassRealmGets the project's class realm.List<org.apache.maven.artifact.Artifact> Deprecated.List<org.apache.maven.model.Dependency> Deprecated.Gets the list of compile source roots for this project.getContextValue(String key) Returns context value of this project associated with the given key or null if this project has no such value.List<org.apache.maven.model.Contributor> List<org.apache.maven.model.Dependency> Set<org.apache.maven.artifact.Artifact> Deprecated.org.apache.maven.model.DependencyManagementList<org.apache.maven.model.Developer> org.apache.maven.model.DistributionManagementorg.apache.maven.artifact.repository.ArtifactRepositoryDeprecated.Set<org.apache.maven.artifact.Artifact> Deprecated.org.eclipse.aether.graph.DependencyFilterGets the dependency filter used to exclude shared extension artifacts from plugin realms.getFile()org.codehaus.plexus.util.xml.Xpp3DomgetGoalConfiguration(String pluginGroupId, String pluginArtifactId, String executionId, String goalId) getId()Gets the identifiers of all profiles that contributed to this project's effective model.org.apache.maven.model.IssueManagementList<org.apache.maven.model.License> List<org.apache.maven.model.MailingList> org.apache.maven.model.ModelgetModel()getModulePathAdjustment(MavenProject moduleProject) Deprecated.getName()org.apache.maven.model.Organizationorg.apache.maven.model.ModelReturns the project corresponding to a declared parent.org.apache.maven.artifact.Artifactorg.apache.maven.model.PluginList<org.apache.maven.artifact.repository.ArtifactRepository> Set<org.apache.maven.artifact.Artifact> org.apache.maven.model.PluginManagementList<org.apache.maven.model.Repository> org.apache.maven.model.PrerequisitesDeprecated.protected org.apache.maven.artifact.repository.ArtifactRepositoryList<org.apache.maven.artifact.repository.ArtifactRepository> List<org.eclipse.aether.repository.RemoteRepository> List<org.eclipse.aether.repository.RemoteRepository> Deprecated.Set<org.apache.maven.artifact.Artifact> Deprecated.org.codehaus.plexus.util.xml.Xpp3DomgetReportConfiguration(String pluginGroupId, String pluginArtifactId, String reportSetId) Deprecated.org.apache.maven.model.ReportingDeprecated.List<org.apache.maven.model.ReportPlugin> Deprecated.List<org.apache.maven.model.Repository> List<org.apache.maven.model.Resource> List<org.apache.maven.artifact.Artifact> Deprecated.List<org.apache.maven.model.Dependency> Deprecated.org.apache.maven.model.ScmgetScm()Deprecated.protected org.apache.maven.artifact.repository.ArtifactRepositoryList<org.apache.maven.artifact.Artifact> Deprecated.Deprecated.List<org.apache.maven.model.Dependency> Deprecated.List<org.apache.maven.artifact.Artifact> Deprecated.Gets the list of test compile source roots for this project.List<org.apache.maven.model.Dependency> Deprecated.List<org.apache.maven.model.Resource> getUrl()inthashCode()booleanhasLifecyclePhase(String phase) Warning: This is an internal utility method that is only public for technical reasons, it is not part of the public API.booleanbooleanvoidRemoves the specified path from the list of compile source roots.voidRemoves the specified path from the list of test compile source roots.org.apache.maven.artifact.ArtifactreplaceWithActiveArtifact(org.apache.maven.artifact.Artifact pluginArtifact) Deprecated.voidsetActiveProfiles(List<org.apache.maven.model.Profile> activeProfiles) voidsetArtifact(org.apache.maven.artifact.Artifact artifact) voidsetArtifactFilter(org.apache.maven.artifact.resolver.filter.ArtifactFilter artifactFilter) Sets the scope filter to select the artifacts being exposed to the currently executed mojo.voidsetArtifactId(String artifactId) voidsetArtifacts(Set<org.apache.maven.artifact.Artifact> artifacts) protected voidsetAttachedArtifacts(List<org.apache.maven.artifact.Artifact> attachedArtifacts) voidsetBuild(org.apache.maven.model.Build build) voidsetCiManagement(org.apache.maven.model.CiManagement ciManagement) voidsetClassRealm(org.codehaus.plexus.classworlds.realm.ClassRealm classRealm) Sets the project's class realm.voidsetCollectedProjects(List<MavenProject> collectedProjects) protected voidsetCompileSourceRoots(List<String> compileSourceRoots) voidsetContextValue(String key, Object value) Sets the value of the context value of this project identified by the given key.voidsetContributors(List<org.apache.maven.model.Contributor> contributors) voidsetDependencies(List<org.apache.maven.model.Dependency> dependencies) voidsetDependencyArtifacts(Set<org.apache.maven.artifact.Artifact> dependencyArtifacts) Deprecated.voidsetDescription(String description) voidsetDevelopers(List<org.apache.maven.model.Developer> developers) voidsetDistributionManagement(org.apache.maven.model.DistributionManagement distributionManagement) voidsetExecutionProject(MavenProject executionProject) voidsetExecutionRoot(boolean executionRoot) voidsetExtensionArtifacts(Set<org.apache.maven.artifact.Artifact> extensionArtifacts) Deprecated.voidsetExtensionDependencyFilter(org.eclipse.aether.graph.DependencyFilter extensionDependencyFilter) Sets the artifact filter used to exclude shared extension artifacts from plugin realms.voidvoidsetGroupId(String groupId) voidsetInceptionYear(String inceptionYear) voidsetInjectedProfileIds(String source, List<String> injectedProfileIds) voidsetIssueManagement(org.apache.maven.model.IssueManagement issueManagement) voidsetLicenses(List<org.apache.maven.model.License> licenses) voidsetMailingLists(List<org.apache.maven.model.MailingList> mailingLists) voidsetManagedVersionMap(Map<String, org.apache.maven.artifact.Artifact> map) voidsetModel(org.apache.maven.model.Model model) voidsetModelVersion(String pomVersion) voidvoidsetOrganization(org.apache.maven.model.Organization organization) voidsetOriginalModel(org.apache.maven.model.Model originalModel) voidsetPackaging(String packaging) voidsetParent(MavenProject parent) voidsetParentArtifact(org.apache.maven.artifact.Artifact parentArtifact) voidsetParentFile(File parentFile) voidsetPluginArtifactRepositories(List<org.apache.maven.artifact.repository.ArtifactRepository> pluginArtifactRepositories) voidsetPluginArtifacts(Set<org.apache.maven.artifact.Artifact> pluginArtifacts) voidsetPomFile(File file) Sets projectfilewithout changing projectbasedir.voidsetProjectBuildingRequest(ProjectBuildingRequest projectBuildingRequest) Deprecated.voidsetReleaseArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository releaseArtifactRepository) voidsetRemoteArtifactRepositories(List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositories) voidsetReportArtifacts(Set<org.apache.maven.artifact.Artifact> reportArtifacts) Deprecated.voidsetReporting(org.apache.maven.model.Reporting reporting) Deprecated.voidsetResolvedArtifacts(Set<org.apache.maven.artifact.Artifact> artifacts) Sets the transitive dependency artifacts that have been resolved/collected for this project.voidsetScm(org.apache.maven.model.Scm scm) protected voidsetScriptSourceRoots(List<String> scriptSourceRoots) Deprecated.voidsetSnapshotArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository snapshotArtifactRepository) protected voidsetTestCompileSourceRoots(List<String> testCompileSourceRoots) voidvoidsetVersion(String version) toString()Default toStringvoidwriteModel(Writer writer) Deprecated.UseModelWriter.voidwriteOriginalModel(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.model.Model model) -
MavenProject
-
-
Method Details
-
getParentFile
-
setParentFile
-
getArtifact
public org.apache.maven.artifact.Artifact getArtifact() -
setArtifact
public void setArtifact(org.apache.maven.artifact.Artifact artifact) -
getModel
public org.apache.maven.model.Model 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
-
getBasedir
-
setDependencies
-
getDependencies
-
getDependencyManagement
public org.apache.maven.model.DependencyManagement getDependencyManagement() -
addCompileSourceRoot
Adds the specified path to the list of compile source roots for this project.- Parameters:
path- the source root to add
-
removeCompileSourceRoot
Removes the specified path from the list of compile source roots.- Parameters:
path- the source root to remove- Since:
- 3.9.10
-
addTestCompileSourceRoot
Adds the specified path to the list of test compile source roots for this project.- Parameters:
path- the test source root to add
-
removeTestCompileSourceRoot
Removes the specified path from the list of test compile source roots.- Parameters:
path- the test source root to remove- Since:
- 3.9.10
-
getCompileSourceRoots
Gets the list of compile source roots for this project.Note: The collection returned by this method should not be modified directly. Use
addCompileSourceRoot(String)andremoveCompileSourceRoot(String)methods instead.- Returns:
- a list of compile source roots
-
getTestCompileSourceRoots
Gets the list of test compile source roots for this project.Note: The collection returned by this method should not be modified directly. Use
addTestCompileSourceRoot(String)andremoveTestCompileSourceRoot(String)methods instead.- Returns:
- a list of test compile source roots
-
getCompileClasspathElements
-
getTestClasspathElements
-
getRuntimeClasspathElements
-
setModelVersion
-
getModelVersion
-
getId
-
setGroupId
-
getGroupId
-
setArtifactId
-
getArtifactId
-
setName
-
getName
-
setVersion
-
getVersion
-
getPackaging
-
setPackaging
-
setInceptionYear
-
getInceptionYear
-
setUrl
-
getUrl
-
getPrerequisites
public org.apache.maven.model.Prerequisites getPrerequisites() -
setIssueManagement
public void setIssueManagement(org.apache.maven.model.IssueManagement issueManagement) -
getCiManagement
public org.apache.maven.model.CiManagement getCiManagement() -
setCiManagement
public void setCiManagement(org.apache.maven.model.CiManagement ciManagement) -
getIssueManagement
public org.apache.maven.model.IssueManagement getIssueManagement() -
setDistributionManagement
public void setDistributionManagement(org.apache.maven.model.DistributionManagement distributionManagement) -
getDistributionManagement
public org.apache.maven.model.DistributionManagement getDistributionManagement() -
setDescription
-
getDescription
-
setOrganization
public void setOrganization(org.apache.maven.model.Organization organization) -
getOrganization
public org.apache.maven.model.Organization getOrganization() -
setScm
public void setScm(org.apache.maven.model.Scm scm) -
getScm
public org.apache.maven.model.Scm getScm() -
setMailingLists
-
getMailingLists
-
addMailingList
public void addMailingList(org.apache.maven.model.MailingList mailingList) -
setDevelopers
-
getDevelopers
-
addDeveloper
public void addDeveloper(org.apache.maven.model.Developer developer) -
setContributors
-
getContributors
-
addContributor
public void addContributor(org.apache.maven.model.Contributor contributor) -
setBuild
public void setBuild(org.apache.maven.model.Build build) -
getBuild
public org.apache.maven.model.Build getBuild() -
getResources
-
getTestResources
-
addResource
public void addResource(org.apache.maven.model.Resource resource) -
addTestResource
public void addTestResource(org.apache.maven.model.Resource testResource) -
setLicenses
-
getLicenses
-
addLicense
public void addLicense(org.apache.maven.model.License license) -
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. eg. if only compile phase has run, dependencies with scope test won't be included.- Returns:
Set<Artifact>- See Also:
-
getArtifactMap
-
setPluginArtifacts
-
getPluginArtifacts
-
getPluginArtifactMap
-
setParentArtifact
public void setParentArtifact(org.apache.maven.artifact.Artifact parentArtifact) -
getParentArtifact
public org.apache.maven.artifact.Artifact getParentArtifact() -
getRepositories
-
getBuildPlugins
-
getModules
-
getPluginManagement
public org.apache.maven.model.PluginManagement getPluginManagement() -
setRemoteArtifactRepositories
public void setRemoteArtifactRepositories(List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositories) -
getRemoteArtifactRepositories
public List<org.apache.maven.artifact.repository.ArtifactRepository> getRemoteArtifactRepositories() -
setPluginArtifactRepositories
public void setPluginArtifactRepositories(List<org.apache.maven.artifact.repository.ArtifactRepository> pluginArtifactRepositories) -
getPluginArtifactRepositories
public List<org.apache.maven.artifact.repository.ArtifactRepository> getPluginArtifactRepositories()- Returns:
- a list of ArtifactRepository objects constructed from the Repository objects returned by getPluginRepositories.
-
getDistributionManagementArtifactRepository
public org.apache.maven.artifact.repository.ArtifactRepository 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 orexternalfor profiles from thesettings.xml.- Returns:
- The identifiers of all injected profiles, indexed by the source from which the profiles originated, never
null.
-
addAttachedArtifact
public void addAttachedArtifact(org.apache.maven.artifact.Artifact artifact) throws DuplicateArtifactAttachmentException Deprecated.Please useMavenProjectHelperAdd 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 mutable list of the attached artifacts to this project. It is highly advised not to modify this list, but rather use theMavenProjectHelper.Note: This list will be made read-only in Maven 4.
- Returns:
- the attached artifacts of this project
-
getGoalConfiguration
-
getExecutionProject
-
setExecutionProject
-
getCollectedProjects
-
setCollectedProjects
-
getDependencyArtifacts
-
setDependencyArtifacts
@Deprecated public void setDependencyArtifacts(Set<org.apache.maven.artifact.Artifact> dependencyArtifacts) Deprecated. -
setReleaseArtifactRepository
public void setReleaseArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository releaseArtifactRepository) -
setSnapshotArtifactRepository
public void setSnapshotArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository snapshotArtifactRepository) -
setOriginalModel
public void setOriginalModel(org.apache.maven.model.Model originalModel) -
getOriginalModel
public org.apache.maven.model.Model getOriginalModel() -
setManagedVersionMap
-
getManagedVersionMap
-
equals
-
hashCode
-
getBuildExtensions
-
addProjectReference
-
getProperties
-
getFilters
-
getProjectReferences
-
isExecutionRoot
public boolean isExecutionRoot() -
setExecutionRoot
public void setExecutionRoot(boolean executionRoot) -
getDefaultGoal
-
getPlugin
-
toString
-
clone
-
setModel
public void setModel(org.apache.maven.model.Model model) -
setAttachedArtifacts
-
setCompileSourceRoots
-
setTestCompileSourceRoots
-
getReleaseArtifactRepository
protected org.apache.maven.artifact.repository.ArtifactRepository getReleaseArtifactRepository() -
getSnapshotArtifactRepository
protected org.apache.maven.artifact.repository.ArtifactRepository 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
-
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
public void setArtifactFilter(org.apache.maven.artifact.resolver.filter.ArtifactFilter artifactFilter) 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 benullto 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:
trueif 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<org.apache.maven.artifact.Artifact> createArtifacts(ArtifactFactory artifactFactory, String inheritedScope, org.apache.maven.artifact.resolver.filter.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 public void setExtensionArtifacts(Set<org.apache.maven.artifact.Artifact> extensionArtifacts) Deprecated. -
getExtensionArtifacts
Deprecated. -
getExtensionArtifactMap
Deprecated. -
getReportPlugins
Deprecated. -
getReportConfiguration
@Deprecated public org.codehaus.plexus.util.xml.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 public org.apache.maven.artifact.Artifact replaceWithActiveArtifact(org.apache.maven.artifact.Artifact pluginArtifact) Deprecated. -
getProjectBuildingRequest
Deprecated.Gets the project building request from which this project instance was created. Warning: This is an 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 an 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