org.apache.maven.project
Class MavenProject

java.lang.Object
  extended by org.apache.maven.project.MavenProject
All Implemented Interfaces:
Cloneable

public class MavenProject
extends Object
implements Cloneable

The concern of the project is provide runtime values based on the model.

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.

We need to leave the model intact because we don't want the following:

  1. We don't want interpolated values being written back into the model.
  2. We don't want inherited values being written back into the model.


Field Summary
static String EMPTY_PROJECT_ARTIFACT_ID
           
static String EMPTY_PROJECT_GROUP_ID
           
static String EMPTY_PROJECT_VERSION
           
 
Constructor Summary
MavenProject()
           
MavenProject(MavenProject project)
          Deprecated. use clone() so subclasses can provide a copy of the same class
MavenProject(Model model)
           
 
Method Summary
 void addAttachedArtifact(Artifact artifact)
           
 void addCompileSourceRoot(String path)
           
 void addContributor(Contributor contributor)
           
 void addDeveloper(Developer developer)
           
 void addLicense(License license)
           
 void addMailingList(MailingList mailingList)
           
 void addPlugin(Plugin plugin)
           
 void addProjectReference(MavenProject project)
           
 void addResource(Resource resource)
           
 void addScriptSourceRoot(String path)
           
 void addTestCompileSourceRoot(String path)
           
 void addTestResource(Resource testResource)
           
 void attachArtifact(String type, String classifier, File file)
          Deprecated. Use MavenProjectHelper.attachArtifact(..) instead.
 Object clone()
           
 Set createArtifacts(ArtifactFactory artifactFactory, String inheritedScope, ArtifactFilter dependencyFilter)
           
 boolean equals(Object other)
           
 List getActiveProfiles()
           
 Artifact getArtifact()
           
 String getArtifactId()
           
 Map getArtifactMap()
           
 Set getArtifacts()
          All dependencies that this project has, including transitive ones.
 List getAttachedArtifacts()
           
 File getBasedir()
           
 Build getBuild()
           
 List getBuildExtensions()
           
 List getBuildPlugins()
           
 CiManagement getCiManagement()
           
 List getCollectedProjects()
           
 List getCompileArtifacts()
           
 List getCompileClasspathElements()
           
 List getCompileDependencies()
           
 List getCompileSourceRoots()
           
 List getContributors()
           
 String getDefaultGoal()
           
 List getDependencies()
           
 Set getDependencyArtifacts()
          Direct dependencies that this project has.
 DependencyManagement getDependencyManagement()
           
 String getDescription()
           
 List getDevelopers()
           
 DistributionManagement getDistributionManagement()
           
 ArtifactRepository getDistributionManagementArtifactRepository()
           
 MavenProject getExecutionProject()
           
 Map getExtensionArtifactMap()
           
 Set getExtensionArtifacts()
           
 File getFile()
           
 List getFilters()
           
 org.codehaus.plexus.util.xml.Xpp3Dom getGoalConfiguration(String pluginGroupId, String pluginArtifactId, String executionId, String goalId)
           
 String getGroupId()
           
 String getId()
           
 String getInceptionYear()
           
 IssueManagement getIssueManagement()
           
 List getLicenses()
           
 List getMailingLists()
           
 Map getManagedVersionMap()
           
 Model getModel()
           
 String getModelVersion()
           
 String getModulePathAdjustment(MavenProject moduleProject)
           
 List getModules()
           
 String getName()
           
 Organization getOrganization()
           
 Model getOriginalModel()
           
 String getPackaging()
           
 MavenProject getParent()
           
 Artifact getParentArtifact()
           
 Map getPluginArtifactMap()
           
 List getPluginArtifactRepositories()
           
 Set getPluginArtifacts()
           
 PluginManagement getPluginManagement()
           
 List getPluginRepositories()
           
 Prerequisites getPrerequisites()
           
 Map getProjectReferences()
           
 Properties getProperties()
           
protected  ArtifactRepository getReleaseArtifactRepository()
           
 List getRemoteArtifactRepositories()
           
 Map getReportArtifactMap()
           
 Set getReportArtifacts()
           
 org.codehaus.plexus.util.xml.Xpp3Dom getReportConfiguration(String pluginGroupId, String pluginArtifactId, String reportSetId)
           
 Reporting getReporting()
           
 List getReportPlugins()
           
 List getRepositories()
           
 List getResources()
           
 List getRuntimeArtifacts()
           
 List getRuntimeClasspathElements()
           
 List getRuntimeDependencies()
           
 Scm getScm()
           
 List getScriptSourceRoots()
           
protected  ArtifactRepository getSnapshotArtifactRepository()
           
 List getSystemArtifacts()
           
 List getSystemClasspathElements()
           
 List getSystemDependencies()
           
 List getTestArtifacts()
           
 List getTestClasspathElements()
           
 List getTestCompileSourceRoots()
           
 List getTestDependencies()
           
 List getTestResources()
           
 String getUrl()
           
 String getVersion()
           
 int hashCode()
           
 boolean hasParent()
           
 void injectPluginManagementInfo(Plugin plugin)
           
 boolean isExecutionRoot()
           
 Artifact replaceWithActiveArtifact(Artifact pluginArtifact)
           
 void setActiveProfiles(List activeProfiles)
           
 void setArtifact(Artifact artifact)
           
 void setArtifactId(String artifactId)
           
 void setArtifacts(Set artifacts)
           
protected  void setAttachedArtifacts(List attachedArtifacts)
           
 void setBuild(Build build)
           
 void setCiManagement(CiManagement ciManagement)
           
 void setCollectedProjects(List collectedProjects)
           
protected  void setCompileSourceRoots(List compileSourceRoots)
           
 void setContributors(List contributors)
           
 void setDependencies(List dependencies)
           
 void setDependencyArtifacts(Set dependencyArtifacts)
           
 void setDescription(String description)
           
 void setDevelopers(List developers)
           
 void setDistributionManagement(DistributionManagement distributionManagement)
           
 void setExecutionProject(MavenProject executionProject)
           
 void setExecutionRoot(boolean executionRoot)
           
 void setExtensionArtifacts(Set extensionArtifacts)
           
 void setFile(File file)
           
 void setGroupId(String groupId)
           
 void setInceptionYear(String inceptionYear)
           
 void setIssueManagement(IssueManagement issueManagement)
           
 void setLicenses(List licenses)
           
 void setMailingLists(List mailingLists)
           
 void setManagedVersionMap(Map map)
           
protected  void setModel(Model model)
           
 void setModelVersion(String pomVersion)
           
 void setName(String name)
           
 void setOrganization(Organization organization)
           
 void setOriginalModel(Model originalModel)
           
 void setPackaging(String packaging)
           
 void setParent(MavenProject parent)
           
 void setParentArtifact(Artifact parentArtifact)
           
 void setPluginArtifactRepositories(List pluginArtifactRepositories)
           
 void setPluginArtifacts(Set pluginArtifacts)
           
 void setReleaseArtifactRepository(ArtifactRepository releaseArtifactRepository)
           
 void setRemoteArtifactRepositories(List remoteArtifactRepositories)
           
 void setReportArtifacts(Set reportArtifacts)
           
 void setReporting(Reporting reporting)
           
 void setScm(Scm scm)
           
protected  void setScriptSourceRoots(List scriptSourceRoots)
           
 void setSnapshotArtifactRepository(ArtifactRepository snapshotArtifactRepository)
           
protected  void setTestCompileSourceRoots(List testCompileSourceRoots)
           
 void setUrl(String url)
           
 void setVersion(String version)
           
 String toString()
          Default toString
 void writeModel(Writer writer)
           
 void writeOriginalModel(Writer writer)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_PROJECT_GROUP_ID

public static final String EMPTY_PROJECT_GROUP_ID
See Also:
Constant Field Values

EMPTY_PROJECT_ARTIFACT_ID

public static final String EMPTY_PROJECT_ARTIFACT_ID
See Also:
Constant Field Values

EMPTY_PROJECT_VERSION

public static final String EMPTY_PROJECT_VERSION
See Also:
Constant Field Values
Constructor Detail

MavenProject

public MavenProject()

MavenProject

public MavenProject(Model model)

MavenProject

public MavenProject(MavenProject project)
Deprecated. use clone() so subclasses can provide a copy of the same class

Method Detail

getModulePathAdjustment

public String getModulePathAdjustment(MavenProject moduleProject)
                               throws IOException
Throws:
IOException

getArtifact

public Artifact getArtifact()

setArtifact

public void setArtifact(Artifact artifact)

getModel

public Model getModel()

getParent

public MavenProject getParent()

setParent

public void setParent(MavenProject parent)

setRemoteArtifactRepositories

public void setRemoteArtifactRepositories(List remoteArtifactRepositories)

getRemoteArtifactRepositories

public List getRemoteArtifactRepositories()

hasParent

public boolean hasParent()

getFile

public File getFile()

setFile

public void setFile(File file)

getBasedir

public File getBasedir()

setDependencies

public void setDependencies(List dependencies)

getDependencies

public List getDependencies()

getDependencyManagement

public DependencyManagement getDependencyManagement()

addCompileSourceRoot

public void addCompileSourceRoot(String path)

addScriptSourceRoot

public void addScriptSourceRoot(String path)

addTestCompileSourceRoot

public void addTestCompileSourceRoot(String path)

getCompileSourceRoots

public List getCompileSourceRoots()

getScriptSourceRoots

public List getScriptSourceRoots()

getTestCompileSourceRoots

public List getTestCompileSourceRoots()

getCompileClasspathElements

public List getCompileClasspathElements()
                                 throws DependencyResolutionRequiredException
Throws:
DependencyResolutionRequiredException

getCompileArtifacts

public List getCompileArtifacts()

getCompileDependencies

public List getCompileDependencies()

getTestClasspathElements

public List getTestClasspathElements()
                              throws DependencyResolutionRequiredException
Throws:
DependencyResolutionRequiredException

getTestArtifacts

public List getTestArtifacts()

getTestDependencies

public List getTestDependencies()

getRuntimeClasspathElements

public List getRuntimeClasspathElements()
                                 throws DependencyResolutionRequiredException
Throws:
DependencyResolutionRequiredException

getRuntimeArtifacts

public List getRuntimeArtifacts()

getRuntimeDependencies

public List getRuntimeDependencies()

getSystemClasspathElements

public List getSystemClasspathElements()
                                throws DependencyResolutionRequiredException
Throws:
DependencyResolutionRequiredException

getSystemArtifacts

public List getSystemArtifacts()

getSystemDependencies

public List getSystemDependencies()

setModelVersion

public void setModelVersion(String pomVersion)

getModelVersion

public String getModelVersion()

getId

public String getId()

setGroupId

public void setGroupId(String groupId)

getGroupId

public String getGroupId()

setArtifactId

public void setArtifactId(String artifactId)

getArtifactId

public String getArtifactId()

setName

public void setName(String name)

getName

public String getName()

setVersion

public void setVersion(String version)

getVersion

public String getVersion()

getPackaging

public String getPackaging()

setPackaging

public void setPackaging(String packaging)

setInceptionYear

public void setInceptionYear(String inceptionYear)

getInceptionYear

public String getInceptionYear()

setUrl

public void setUrl(String url)

getUrl

public String getUrl()

getPrerequisites

public Prerequisites getPrerequisites()

setIssueManagement

public void setIssueManagement(IssueManagement issueManagement)

getCiManagement

public CiManagement getCiManagement()

setCiManagement

public void setCiManagement(CiManagement ciManagement)

getIssueManagement

public IssueManagement getIssueManagement()

setDistributionManagement

public void setDistributionManagement(DistributionManagement distributionManagement)

getDistributionManagement

public DistributionManagement getDistributionManagement()

setDescription

public void setDescription(String description)

getDescription

public String getDescription()

setOrganization

public void setOrganization(Organization organization)

getOrganization

public Organization getOrganization()

setScm

public void setScm(Scm scm)

getScm

public Scm getScm()

setMailingLists

public void setMailingLists(List mailingLists)

getMailingLists

public List getMailingLists()

addMailingList

public void addMailingList(MailingList mailingList)

setDevelopers

public void setDevelopers(List developers)

getDevelopers

public List getDevelopers()

addDeveloper

public void addDeveloper(Developer developer)

setContributors

public void setContributors(List contributors)

getContributors

public List getContributors()

addContributor

public void addContributor(Contributor contributor)

setBuild

public void setBuild(Build build)

getBuild

public Build getBuild()

getResources

public List getResources()

getTestResources

public List getTestResources()

addResource

public void addResource(Resource resource)

addTestResource

public void addTestResource(Resource testResource)

setReporting

public void setReporting(Reporting reporting)

getReporting

public Reporting getReporting()

setLicenses

public void setLicenses(List licenses)

getLicenses

public List getLicenses()

addLicense

public void addLicense(License license)

setArtifacts

public void setArtifacts(Set artifacts)

getArtifacts

public Set 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:
to get only direct dependencies

getArtifactMap

public Map getArtifactMap()

setPluginArtifacts

public void setPluginArtifacts(Set pluginArtifacts)

getPluginArtifacts

public Set getPluginArtifacts()

getPluginArtifactMap

public Map getPluginArtifactMap()

setReportArtifacts

public void setReportArtifacts(Set reportArtifacts)

getReportArtifacts

public Set getReportArtifacts()

getReportArtifactMap

public Map getReportArtifactMap()

setExtensionArtifacts

public void setExtensionArtifacts(Set extensionArtifacts)

getExtensionArtifacts

public Set getExtensionArtifacts()

getExtensionArtifactMap

public Map getExtensionArtifactMap()

setParentArtifact

public void setParentArtifact(Artifact parentArtifact)

getParentArtifact

public Artifact getParentArtifact()

getRepositories

public List getRepositories()

getReportPlugins

public List getReportPlugins()

getBuildPlugins

public List getBuildPlugins()

getModules

public List getModules()

getPluginManagement

public PluginManagement getPluginManagement()

addPlugin

public void addPlugin(Plugin plugin)

injectPluginManagementInfo

public void injectPluginManagementInfo(Plugin plugin)

getCollectedProjects

public List getCollectedProjects()

setCollectedProjects

public void setCollectedProjects(List collectedProjects)

setPluginArtifactRepositories

public void setPluginArtifactRepositories(List pluginArtifactRepositories)

getPluginArtifactRepositories

public List getPluginArtifactRepositories()
Returns:
a list of ArtifactRepository objects constructed from the Repository objects returned by getPluginRepositories.

getDistributionManagementArtifactRepository

public ArtifactRepository getDistributionManagementArtifactRepository()

getPluginRepositories

public List getPluginRepositories()

setActiveProfiles

public void setActiveProfiles(List activeProfiles)

getActiveProfiles

public List getActiveProfiles()

addAttachedArtifact

public void addAttachedArtifact(Artifact artifact)

getAttachedArtifacts

public List getAttachedArtifacts()

getGoalConfiguration

public org.codehaus.plexus.util.xml.Xpp3Dom getGoalConfiguration(String pluginGroupId,
                                                                 String pluginArtifactId,
                                                                 String executionId,
                                                                 String goalId)

getReportConfiguration

public org.codehaus.plexus.util.xml.Xpp3Dom getReportConfiguration(String pluginGroupId,
                                                                   String pluginArtifactId,
                                                                   String reportSetId)

getExecutionProject

public MavenProject getExecutionProject()

setExecutionProject

public void setExecutionProject(MavenProject executionProject)

writeModel

public void writeModel(Writer writer)
                throws IOException
Throws:
IOException

writeOriginalModel

public void writeOriginalModel(Writer writer)
                        throws IOException
Throws:
IOException

getDependencyArtifacts

public Set getDependencyArtifacts()
Direct dependencies that this project has.

Returns:
Set < Artifact >
See Also:
to get all transitive dependencies

setDependencyArtifacts

public void setDependencyArtifacts(Set dependencyArtifacts)

setReleaseArtifactRepository

public void setReleaseArtifactRepository(ArtifactRepository releaseArtifactRepository)

setSnapshotArtifactRepository

public void setSnapshotArtifactRepository(ArtifactRepository snapshotArtifactRepository)

setOriginalModel

public void setOriginalModel(Model originalModel)

getOriginalModel

public Model getOriginalModel()

setManagedVersionMap

public void setManagedVersionMap(Map map)

getManagedVersionMap

public Map getManagedVersionMap()

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getBuildExtensions

public List getBuildExtensions()

createArtifacts

public Set createArtifacts(ArtifactFactory artifactFactory,
                           String inheritedScope,
                           ArtifactFilter dependencyFilter)
                    throws InvalidDependencyVersionException
Returns:
Set < Artifact >
Throws:
InvalidDependencyVersionException

addProjectReference

public void addProjectReference(MavenProject project)

attachArtifact

public void attachArtifact(String type,
                           String classifier,
                           File file)
Deprecated. Use MavenProjectHelper.attachArtifact(..) instead.


getProperties

public Properties getProperties()

getFilters

public List getFilters()

getProjectReferences

public Map getProjectReferences()

isExecutionRoot

public boolean isExecutionRoot()

setExecutionRoot

public void setExecutionRoot(boolean executionRoot)

getDefaultGoal

public String getDefaultGoal()

setModel

protected void setModel(Model model)

setAttachedArtifacts

protected void setAttachedArtifacts(List attachedArtifacts)

setCompileSourceRoots

protected void setCompileSourceRoots(List compileSourceRoots)

setTestCompileSourceRoots

protected void setTestCompileSourceRoots(List testCompileSourceRoots)

setScriptSourceRoots

protected void setScriptSourceRoots(List scriptSourceRoots)

getReleaseArtifactRepository

protected ArtifactRepository getReleaseArtifactRepository()

getSnapshotArtifactRepository

protected ArtifactRepository getSnapshotArtifactRepository()

replaceWithActiveArtifact

public Artifact replaceWithActiveArtifact(Artifact pluginArtifact)

toString

public String toString()
Default toString

Overrides:
toString in class Object

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException
Since:
2.0.9


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.