Class MavenProject

java.lang.Object
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 Details

    • EMPTY_PROJECT_GROUP_ID

      public static final String EMPTY_PROJECT_GROUP_ID
      See Also:
    • EMPTY_PROJECT_ARTIFACT_ID

      public static final String EMPTY_PROJECT_ARTIFACT_ID
      See Also:
    • EMPTY_PROJECT_VERSION

      public static final String EMPTY_PROJECT_VERSION
      See Also:
    • model

      private Model model
    • parent

      private MavenProject parent
    • file

      private File file
    • artifacts

      private Set artifacts
    • parentArtifact

      private Artifact parentArtifact
    • pluginArtifacts

      private Set pluginArtifacts
    • remoteArtifactRepositories

      private List remoteArtifactRepositories
    • collectedProjects

      private List collectedProjects
    • attachedArtifacts

      private List attachedArtifacts
    • executionProject

      private MavenProject executionProject
    • compileSourceRoots

      private List compileSourceRoots
    • testCompileSourceRoots

      private List testCompileSourceRoots
    • scriptSourceRoots

      private List scriptSourceRoots
    • pluginArtifactRepositories

      private List pluginArtifactRepositories
    • releaseArtifactRepository

      private ArtifactRepository releaseArtifactRepository
    • snapshotArtifactRepository

      private ArtifactRepository snapshotArtifactRepository
    • activeProfiles

      private List activeProfiles
    • dependencyArtifacts

      private Set dependencyArtifacts
    • artifact

      private Artifact artifact
    • artifactMap

      private Map artifactMap
    • originalModel

      private Model originalModel
    • pluginArtifactMap

      private Map pluginArtifactMap
    • reportArtifacts

      private Set reportArtifacts
    • reportArtifactMap

      private Map reportArtifactMap
    • extensionArtifacts

      private Set extensionArtifacts
    • extensionArtifactMap

      private Map extensionArtifactMap
    • managedVersionMap

      private Map managedVersionMap
    • projectReferences

      private Map projectReferences
    • executionRoot

      private boolean executionRoot
    • moduleAdjustments

      private Map moduleAdjustments
    • basedir

      private File basedir
    • logger

      private org.codehaus.plexus.logging.Logger logger
    • projectBuilderConfiguration

      private ProjectBuilderConfiguration projectBuilderConfiguration
    • dynamicBuild

      private Build dynamicBuild
    • originalInterpolatedBuild

      private Build originalInterpolatedBuild
    • dynamicCompileSourceRoots

      private List dynamicCompileSourceRoots
    • originalInterpolatedCompileSourceRoots

      private List originalInterpolatedCompileSourceRoots
    • dynamicTestCompileSourceRoots

      private List dynamicTestCompileSourceRoots
    • originalInterpolatedTestCompileSourceRoots

      private List originalInterpolatedTestCompileSourceRoots
    • dynamicScriptSourceRoots

      private List dynamicScriptSourceRoots
    • originalInterpolatedScriptSourceRoots

      private List originalInterpolatedScriptSourceRoots
    • isConcrete

      private boolean isConcrete
    • preservedProperties

      private Properties preservedProperties
    • preservedBasedir

      private File preservedBasedir
  • Constructor Details

    • MavenProject

      public MavenProject()
    • MavenProject

      public MavenProject(Model model)
    • MavenProject

      public MavenProject(Model model, org.codehaus.plexus.logging.Logger logger)
    • MavenProject

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

    • deepCopy

      private final void deepCopy(MavenProject project)
    • 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)
    • setBasedir

      public void setBasedir(File basedir)
    • 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:
    • 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()
    • getModelBuild

      private Build getModelBuild()
    • 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:
    • 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)
    • getProjectReferenceId

      public static String getProjectReferenceId(String groupId, String artifactId, String version)
    • 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()
    • resolveActiveArtifacts

      public void resolveActiveArtifacts()
    • replaceWithActiveArtifact

      public Artifact replaceWithActiveArtifact(Artifact pluginArtifact)
    • findMatchingArtifact

      private Artifact findMatchingArtifact(List artifacts, Artifact requestedArtifact)
      Tries to resolve the specified artifact from the given collection of attached project artifacts.
      Parameters:
      artifacts - The attached artifacts, may be null.
      requestedArtifact - The artifact to resolve, must not be null.
      Returns:
      The matching artifact or null if not found.
    • getRepositoryConflictId

      private String getRepositoryConflictId(Artifact artifact)
      Gets the repository conflict id of the specified artifact. Unlike the dependency conflict id, the repository conflict id uses the artifact file extension instead of the artifact type. Hence, the repository conflict id more closely reflects the identity of artifacts as perceived by a repository.
      Parameters:
      artifact - The artifact, must not be null.
      Returns:
      The repository conflict id, never null.
    • logMissingSiblingProjectArtifact

      private void logMissingSiblingProjectArtifact(Artifact artifact)
    • addArtifactPath

      private void addArtifactPath(Artifact a, List list) throws DependencyResolutionRequiredException
      Throws:
      DependencyResolutionRequiredException
    • 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
    • isConcrete

      public boolean isConcrete()
    • setConcrete

      public void setConcrete(boolean concrete)
    • getDynamicBuild

      public Build getDynamicBuild()
    • getOriginalInterpolatedBuild

      public Build getOriginalInterpolatedBuild()
    • getDynamicCompileSourceRoots

      public List getDynamicCompileSourceRoots()
    • getOriginalInterpolatedCompileSourceRoots

      public List getOriginalInterpolatedCompileSourceRoots()
    • getDynamicTestCompileSourceRoots

      public List getDynamicTestCompileSourceRoots()
    • getOriginalInterpolatedTestCompileSourceRoots

      public List getOriginalInterpolatedTestCompileSourceRoots()
    • getDynamicScriptSourceRoots

      public List getDynamicScriptSourceRoots()
    • getOriginalInterpolatedScriptSourceRoots

      public List getOriginalInterpolatedScriptSourceRoots()
    • clearRestorableRoots

      public void clearRestorableRoots()
    • clearRestorableBuild

      public void clearRestorableBuild()
    • preserveCompileSourceRoots

      public void preserveCompileSourceRoots(List originalInterpolatedCompileSourceRoots)
    • preserveTestCompileSourceRoots

      public void preserveTestCompileSourceRoots(List originalInterpolatedTestCompileSourceRoots)
    • preserveScriptSourceRoots

      public void preserveScriptSourceRoots(List originalInterpolatedScriptSourceRoots)
    • preserveBuild

      public void preserveBuild(Build originalInterpolatedBuild)
    • setDynamicBuild

      protected void setDynamicBuild(Build dynamicBuild)
    • setOriginalInterpolatedBuild

      protected void setOriginalInterpolatedBuild(Build originalInterpolatedBuild)
    • setDynamicCompileSourceRoots

      protected void setDynamicCompileSourceRoots(List dynamicCompileSourceRoots)
    • setOriginalInterpolatedCompileSourceRoots

      protected void setOriginalInterpolatedCompileSourceRoots(List originalInterpolatedCompileSourceRoots)
    • setDynamicTestCompileSourceRoots

      protected void setDynamicTestCompileSourceRoots(List dynamicTestCompileSourceRoots)
    • setOriginalInterpolatedTestCompileSourceRoots

      protected void setOriginalInterpolatedTestCompileSourceRoots(List originalInterpolatedTestCompileSourceRoots)
    • setDynamicScriptSourceRoots

      protected void setDynamicScriptSourceRoots(List dynamicScriptSourceRoots)
    • setOriginalInterpolatedScriptSourceRoots

      protected void setOriginalInterpolatedScriptSourceRoots(List originalInterpolatedScriptSourceRoots)
    • getPreservedProperties

      public Properties getPreservedProperties()
    • preserveProperties

      public void preserveProperties()
    • getPreservedBasedir

      public File getPreservedBasedir()
    • preserveBasedir

      public void preserveBasedir()
    • setLogger

      public void setLogger(org.codehaus.plexus.logging.Logger logger)
    • getProjectBuilderConfiguration

      public ProjectBuilderConfiguration getProjectBuilderConfiguration()
      Retrieve the ProjectBuilderConfiguration instance used to construct this MavenProject instance.
    • setProjectBuilderConfiguration

      public void setProjectBuilderConfiguration(ProjectBuilderConfiguration projectBuilderConfiguration)
      Set the ProjectBuilderConfiguration instance used to construct this MavenProject instance.
      Parameters:
      projectBuilderConfiguration -