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 SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionMavenProject(Model model) MavenProject(Model model) MavenProject(MavenProject project) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddAttachedArtifact(Artifact artifact) Deprecated.voidaddCompileSourceRoot(String path) voidaddContributor(Contributor contributor) voidaddDeveloper(Developer developer) voidaddLicense(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(MailingList mailingList) voidaddProjectReference(MavenProject project) voidaddResource(Resource resource) voidaddScriptSourceRoot(String path) Deprecated.voidvoidaddTestResource(Resource testResource) voidattachArtifact(String type, String classifier, File file) Deprecated.Use MavenProjectHelper.attachArtifact(..) instead.clone()createArtifacts(ArtifactFactory artifactFactory, String inheritedScope, ArtifactFilter filter) Deprecated.booleanAll 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.ClassRealmGets the project's class realm.Deprecated.Deprecated.This method is unreliable because it does not consider other dependency properties.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.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.getModel()getModulePathAdjustment(MavenProject moduleProject) Deprecated.getName()Returns the project corresponding to a declared parent.Deprecated.protected ArtifactRepositoryList<org.eclipse.aether.repository.RemoteRepository> List<org.eclipse.aether.repository.RemoteRepository> Deprecated.Deprecated.org.codehaus.plexus.util.xml.Xpp3DomgetReportConfiguration(String pluginGroupId, String pluginArtifactId, String reportSetId) Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.This method is unreliable because it does not consider other dependency properties.Deprecated.getScm()Deprecated.protected ArtifactRepositoryDeprecated.Deprecated.Deprecated.Deprecated.Deprecated.This method is unreliable because it does not consider other dependency properties.Deprecated.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.booleanbooleanreplaceWithActiveArtifact(Artifact pluginArtifact) Deprecated.voidsetActiveProfiles(List<Profile> activeProfiles) voidsetArtifact(Artifact artifact) voidsetArtifactFilter(ArtifactFilter artifactFilter) Sets the scope filter to select the artifacts being exposed to the currently executed mojo.voidsetArtifactId(String artifactId) voidsetArtifacts(Set<Artifact> artifacts) protected voidsetAttachedArtifacts(List<Artifact> attachedArtifacts) voidvoidsetCiManagement(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<Contributor> contributors) voidsetDependencies(List<Dependency> dependencies) voidsetDependencyArtifacts(Set<Artifact> dependencyArtifacts) Deprecated.voidsetDescription(String description) voidsetDevelopers(List<Developer> developers) voidsetDistributionManagement(DistributionManagement distributionManagement) voidsetExecutionProject(MavenProject executionProject) voidsetExecutionRoot(boolean executionRoot) voidsetExtensionArtifacts(Set<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(IssueManagement issueManagement) voidsetLicenses(List<License> licenses) voidsetMailingLists(List<MailingList> mailingLists) voidvoidvoidsetModelVersion(String pomVersion) voidvoidsetOrganization(Organization organization) voidsetOriginalModel(Model originalModel) voidsetPackaging(String packaging) voidsetParent(MavenProject parent) voidsetParentArtifact(Artifact parentArtifact) voidsetParentFile(File parentFile) voidsetPluginArtifactRepositories(List<ArtifactRepository> pluginArtifactRepositories) voidsetPluginArtifacts(Set<Artifact> pluginArtifacts) voidsetPomFile(File file) Sets projectfilewithout changing projectbasedir.voidsetProjectBuildingRequest(ProjectBuildingRequest projectBuildingRequest) Deprecated.voidsetReleaseArtifactRepository(ArtifactRepository releaseArtifactRepository) voidsetRemoteArtifactRepositories(List<ArtifactRepository> remoteArtifactRepositories) voidsetReportArtifacts(Set<Artifact> reportArtifacts) Deprecated.voidsetReporting(Reporting reporting) Deprecated.voidsetResolvedArtifacts(Set<Artifact> artifacts) Sets the transitive dependency artifacts that have been resolved/collected for this project.voidsetRootDirectory(Path rootDirectory) voidprotected voidsetScriptSourceRoots(List<String> scriptSourceRoots) Deprecated.voidsetSnapshotArtifactRepository(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- 
MavenProjectpublic MavenProject()
- 
MavenProject
- 
MavenProject
- 
MavenProject
 
- 
- 
Method Details- 
getParentFile
- 
setParentFile
- 
getArtifact
- 
setArtifact
- 
getModel
- 
getParentReturns 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
- 
hasParentpublic boolean hasParent()
- 
getFile
- 
setFile
- 
setPomFileSets projectfilewithout changing projectbasedir.- Since:
- 3.2.4
 
- 
getBasedir
- 
setDependencies
- 
getDependencies
- 
getDependencyManagement
- 
addCompileSourceRoot
- 
addTestCompileSourceRoot
- 
getCompileSourceRoots
- 
getTestCompileSourceRoots
- 
getCompileClasspathElements@Deprecated public List<String> getCompileClasspathElements() throws DependencyResolutionRequiredExceptionDeprecated.This method is unreliable because it does not consider other dependency properties. SeeJavaPathTypeinstead for better analysis.Returns the elements placed on the classpath for compilation. This method can be invoked when the caller does not support module-path.- Throws:
- DependencyResolutionRequiredException- if an artifact file is used, but has not been resolved
 
- 
getTestClasspathElements@Deprecated public List<String> getTestClasspathElements() throws DependencyResolutionRequiredExceptionDeprecated.This method is unreliable because it does not consider other dependency properties. SeeJavaPathTypeinstead for better analysis.Returns the elements placed on the classpath for tests. This method can be invoked when the caller does not support module-path.- Throws:
- DependencyResolutionRequiredException- if an artifact file is used, but has not been resolved
 
- 
getRuntimeClasspathElements@Deprecated public List<String> getRuntimeClasspathElements() throws DependencyResolutionRequiredExceptionDeprecated.This method is unreliable because it does not consider other dependency properties. SeeJavaPathTypeinstead for better analysis.Returns the elements placed on the classpath for runtime. This method can be invoked when the caller does not support module-path.- Throws:
- DependencyResolutionRequiredException- if an artifact file is used, but has not been resolved
 
- 
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
- 
getArtifactsAll 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
- 
getInjectedProfileIdsGets 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.
 
- 
addAttachedArtifactDeprecated.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
 
- 
getAttachedArtifactsReturns a read-only list of the attached artifacts to this project.- Returns:
- the attached artifacts of this project
 
- 
getGoalConfiguration
- 
getExecutionProject
- 
setExecutionProject
- 
getCollectedProjects
- 
setCollectedProjects
- 
getDependencyArtifactsDeprecated.Direct dependencies that this project has.
- 
setDependencyArtifactsDeprecated.
- 
setReleaseArtifactRepository
- 
setSnapshotArtifactRepository
- 
setOriginalModel
- 
getOriginalModel
- 
setManagedVersionMap
- 
getManagedVersionMap
- 
equals
- 
hashCodepublic int hashCode()
- 
getBuildExtensions
- 
addProjectReference
- 
getProperties
- 
getFilters
- 
getProjectReferences
- 
isExecutionRootpublic boolean isExecutionRoot()
- 
setExecutionRootpublic void setExecutionRoot(boolean executionRoot) 
- 
getDefaultGoal
- 
getPlugin
- 
toStringDefault toString
- 
clone
- 
setModel
- 
setAttachedArtifacts
- 
setCompileSourceRoots
- 
setTestCompileSourceRoots
- 
getReleaseArtifactRepository
- 
getSnapshotArtifactRepository
- 
setContextValueSets 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.
- 
getContextValueReturns context value of this project associated with the given key or null if this project has no such value.
- 
setClassRealmpublic 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 be- null.
 
- 
getClassRealmpublic 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.
 
- 
setExtensionDependencyFilterpublic 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 be- null.
 
- 
getExtensionDependencyFilterpublic 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.
 
- 
setResolvedArtifactsSets 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 be- null.
 
- 
setArtifactFilterSets 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 be- nullto exclude all artifacts.
 
- 
hasLifecyclePhaseWarning: 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 be- null.
- Returns:
- trueif the phase has been seen.
 
- 
addLifecyclePhaseWarning: 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 be- null.
 
- 
getModulePathAdjustmentDeprecated.- Throws:
- IOException
 
- 
createArtifacts@Deprecated public Set<Artifact> createArtifacts(ArtifactFactory artifactFactory, String inheritedScope, ArtifactFilter filter) throws InvalidDependencyVersionException Deprecated.
- 
setScriptSourceRootsDeprecated.
- 
addScriptSourceRootDeprecated.
- 
getScriptSourceRootsDeprecated.
- 
getCompileArtifactsDeprecated.
- 
getCompileDependenciesDeprecated.
- 
getTestArtifactsDeprecated.
- 
getTestDependenciesDeprecated.
- 
getRuntimeDependenciesDeprecated.
- 
getRuntimeArtifactsDeprecated.
- 
getSystemClasspathElements@Deprecated public List<String> getSystemClasspathElements() throws DependencyResolutionRequiredExceptionDeprecated.
- 
getSystemArtifactsDeprecated.
- 
getSystemDependenciesDeprecated.
- 
setReportingDeprecated.
- 
getReportingDeprecated.
- 
setReportArtifactsDeprecated.
- 
getReportArtifactsDeprecated.
- 
getReportArtifactMapDeprecated.
- 
setExtensionArtifactsDeprecated.
- 
getExtensionArtifactsDeprecated.
- 
getExtensionArtifactMapDeprecated.
- 
getReportPluginsDeprecated.
- 
getReportConfiguration@Deprecated public org.codehaus.plexus.util.xml.Xpp3Dom getReportConfiguration(String pluginGroupId, String pluginArtifactId, String reportSetId) Deprecated.
- 
attachArtifactDeprecated.Use MavenProjectHelper.attachArtifact(..) instead.
- 
writeModelDeprecated.UseModelWriter.- Throws:
- IOException
 
- 
writeOriginalModelDeprecated.UseModelWriter.- Throws:
- IOException
 
- 
replaceWithActiveArtifactDeprecated.
- 
getProjectBuildingRequestDeprecated.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
 
- 
setProjectBuildingRequestDeprecated.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 be- null.
- Since:
- 2.1
 
- 
getRootDirectory- Returns:
- the rootDirectory for this project
- Throws:
- IllegalStateException- if the rootDirectory cannot be found
- Since:
- 4.0.0
 
- 
setRootDirectory
 
- 
MavenProjectHelper