Class MavenProject

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class MavenProject
    extends java.lang.Object
    implements java.lang.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 Detail

      • EMPTY_PROJECT_GROUP_ID

        public static final java.lang.String EMPTY_PROJECT_GROUP_ID
        See Also:
        Constant Field Values
      • EMPTY_PROJECT_ARTIFACT_ID

        public static final java.lang.String EMPTY_PROJECT_ARTIFACT_ID
        See Also:
        Constant Field Values
      • EMPTY_PROJECT_VERSION

        public static final java.lang.String EMPTY_PROJECT_VERSION
        See Also:
        Constant Field Values
      • model

        private Model model
      • file

        private java.io.File file
      • artifacts

        private java.util.Set artifacts
      • parentArtifact

        private Artifact parentArtifact
      • pluginArtifacts

        private java.util.Set pluginArtifacts
      • remoteArtifactRepositories

        private java.util.List remoteArtifactRepositories
      • collectedProjects

        private java.util.List collectedProjects
      • attachedArtifacts

        private java.util.List attachedArtifacts
      • compileSourceRoots

        private java.util.List compileSourceRoots
      • testCompileSourceRoots

        private java.util.List testCompileSourceRoots
      • scriptSourceRoots

        private java.util.List scriptSourceRoots
      • pluginArtifactRepositories

        private java.util.List pluginArtifactRepositories
      • activeProfiles

        private java.util.List activeProfiles
      • dependencyArtifacts

        private java.util.Set dependencyArtifacts
      • artifactMap

        private java.util.Map artifactMap
      • originalModel

        private Model originalModel
      • pluginArtifactMap

        private java.util.Map pluginArtifactMap
      • reportArtifacts

        private java.util.Set reportArtifacts
      • reportArtifactMap

        private java.util.Map reportArtifactMap
      • extensionArtifacts

        private java.util.Set extensionArtifacts
      • extensionArtifactMap

        private java.util.Map extensionArtifactMap
      • managedVersionMap

        private java.util.Map managedVersionMap
      • projectReferences

        private java.util.Map projectReferences
      • executionRoot

        private boolean executionRoot
      • moduleAdjustments

        private java.util.Map moduleAdjustments
      • basedir

        private java.io.File basedir
      • logger

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

        private Build dynamicBuild
      • originalInterpolatedBuild

        private Build originalInterpolatedBuild
      • dynamicCompileSourceRoots

        private java.util.List dynamicCompileSourceRoots
      • originalInterpolatedCompileSourceRoots

        private java.util.List originalInterpolatedCompileSourceRoots
      • dynamicTestCompileSourceRoots

        private java.util.List dynamicTestCompileSourceRoots
      • originalInterpolatedTestCompileSourceRoots

        private java.util.List originalInterpolatedTestCompileSourceRoots
      • dynamicScriptSourceRoots

        private java.util.List dynamicScriptSourceRoots
      • originalInterpolatedScriptSourceRoots

        private java.util.List originalInterpolatedScriptSourceRoots
      • isConcrete

        private boolean isConcrete
      • preservedProperties

        private java.util.Properties preservedProperties
      • preservedBasedir

        private java.io.File preservedBasedir
    • Constructor Detail

      • 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 Detail

      • deepCopy

        private final void deepCopy​(MavenProject project)
      • getModulePathAdjustment

        public java.lang.String getModulePathAdjustment​(MavenProject moduleProject)
                                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • getArtifact

        public Artifact getArtifact()
      • setArtifact

        public void setArtifact​(Artifact artifact)
      • getModel

        public Model getModel()
      • setParent

        public void setParent​(MavenProject parent)
      • setRemoteArtifactRepositories

        public void setRemoteArtifactRepositories​(java.util.List remoteArtifactRepositories)
      • getRemoteArtifactRepositories

        public java.util.List getRemoteArtifactRepositories()
      • hasParent

        public boolean hasParent()
      • getFile

        public java.io.File getFile()
      • setFile

        public void setFile​(java.io.File file)
      • setBasedir

        public void setBasedir​(java.io.File basedir)
      • getBasedir

        public java.io.File getBasedir()
      • setDependencies

        public void setDependencies​(java.util.List dependencies)
      • getDependencies

        public java.util.List getDependencies()
      • addCompileSourceRoot

        public void addCompileSourceRoot​(java.lang.String path)
      • addScriptSourceRoot

        public void addScriptSourceRoot​(java.lang.String path)
      • addTestCompileSourceRoot

        public void addTestCompileSourceRoot​(java.lang.String path)
      • getCompileSourceRoots

        public java.util.List getCompileSourceRoots()
      • getScriptSourceRoots

        public java.util.List getScriptSourceRoots()
      • getTestCompileSourceRoots

        public java.util.List getTestCompileSourceRoots()
      • getCompileArtifacts

        public java.util.List getCompileArtifacts()
      • getCompileDependencies

        public java.util.List getCompileDependencies()
      • getTestArtifacts

        public java.util.List getTestArtifacts()
      • getTestDependencies

        public java.util.List getTestDependencies()
      • getRuntimeArtifacts

        public java.util.List getRuntimeArtifacts()
      • getRuntimeDependencies

        public java.util.List getRuntimeDependencies()
      • getSystemArtifacts

        public java.util.List getSystemArtifacts()
      • getSystemDependencies

        public java.util.List getSystemDependencies()
      • setModelVersion

        public void setModelVersion​(java.lang.String pomVersion)
      • getModelVersion

        public java.lang.String getModelVersion()
      • getId

        public java.lang.String getId()
      • setGroupId

        public void setGroupId​(java.lang.String groupId)
      • getGroupId

        public java.lang.String getGroupId()
      • setArtifactId

        public void setArtifactId​(java.lang.String artifactId)
      • getArtifactId

        public java.lang.String getArtifactId()
      • setName

        public void setName​(java.lang.String name)
      • getName

        public java.lang.String getName()
      • setVersion

        public void setVersion​(java.lang.String version)
      • getVersion

        public java.lang.String getVersion()
      • getPackaging

        public java.lang.String getPackaging()
      • setPackaging

        public void setPackaging​(java.lang.String packaging)
      • setInceptionYear

        public void setInceptionYear​(java.lang.String inceptionYear)
      • getInceptionYear

        public java.lang.String getInceptionYear()
      • setUrl

        public void setUrl​(java.lang.String url)
      • getUrl

        public java.lang.String getUrl()
      • setIssueManagement

        public void setIssueManagement​(IssueManagement issueManagement)
      • setCiManagement

        public void setCiManagement​(CiManagement ciManagement)
      • setDistributionManagement

        public void setDistributionManagement​(DistributionManagement distributionManagement)
      • setDescription

        public void setDescription​(java.lang.String description)
      • getDescription

        public java.lang.String getDescription()
      • setOrganization

        public void setOrganization​(Organization organization)
      • setScm

        public void setScm​(Scm scm)
      • getScm

        public Scm getScm()
      • setMailingLists

        public void setMailingLists​(java.util.List mailingLists)
      • getMailingLists

        public java.util.List getMailingLists()
      • addMailingList

        public void addMailingList​(MailingList mailingList)
      • setDevelopers

        public void setDevelopers​(java.util.List developers)
      • getDevelopers

        public java.util.List getDevelopers()
      • addDeveloper

        public void addDeveloper​(Developer developer)
      • setContributors

        public void setContributors​(java.util.List contributors)
      • getContributors

        public java.util.List getContributors()
      • addContributor

        public void addContributor​(Contributor contributor)
      • setBuild

        public void setBuild​(Build build)
      • getBuild

        public Build getBuild()
      • getResources

        public java.util.List getResources()
      • getTestResources

        public java.util.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​(java.util.List licenses)
      • getLicenses

        public java.util.List getLicenses()
      • addLicense

        public void addLicense​(License license)
      • setArtifacts

        public void setArtifacts​(java.util.Set artifacts)
      • getArtifacts

        public java.util.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 java.util.Map getArtifactMap()
      • setPluginArtifacts

        public void setPluginArtifacts​(java.util.Set pluginArtifacts)
      • getPluginArtifacts

        public java.util.Set getPluginArtifacts()
      • getPluginArtifactMap

        public java.util.Map getPluginArtifactMap()
      • setReportArtifacts

        public void setReportArtifacts​(java.util.Set reportArtifacts)
      • getReportArtifacts

        public java.util.Set getReportArtifacts()
      • getReportArtifactMap

        public java.util.Map getReportArtifactMap()
      • setExtensionArtifacts

        public void setExtensionArtifacts​(java.util.Set extensionArtifacts)
      • getExtensionArtifacts

        public java.util.Set getExtensionArtifacts()
      • getExtensionArtifactMap

        public java.util.Map getExtensionArtifactMap()
      • setParentArtifact

        public void setParentArtifact​(Artifact parentArtifact)
      • getParentArtifact

        public Artifact getParentArtifact()
      • getRepositories

        public java.util.List getRepositories()
      • getReportPlugins

        public java.util.List getReportPlugins()
      • getBuildPlugins

        public java.util.List getBuildPlugins()
      • getModules

        public java.util.List getModules()
      • getModelBuild

        private Build getModelBuild()
      • addPlugin

        public void addPlugin​(Plugin plugin)
      • injectPluginManagementInfo

        public void injectPluginManagementInfo​(Plugin plugin)
      • getCollectedProjects

        public java.util.List getCollectedProjects()
      • setCollectedProjects

        public void setCollectedProjects​(java.util.List collectedProjects)
      • setPluginArtifactRepositories

        public void setPluginArtifactRepositories​(java.util.List pluginArtifactRepositories)
      • getPluginArtifactRepositories

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

        public ArtifactRepository getDistributionManagementArtifactRepository()
      • getPluginRepositories

        public java.util.List getPluginRepositories()
      • setActiveProfiles

        public void setActiveProfiles​(java.util.List activeProfiles)
      • getActiveProfiles

        public java.util.List getActiveProfiles()
      • addAttachedArtifact

        public void addAttachedArtifact​(Artifact artifact)
      • getAttachedArtifacts

        public java.util.List getAttachedArtifacts()
      • getGoalConfiguration

        public org.codehaus.plexus.util.xml.Xpp3Dom getGoalConfiguration​(java.lang.String pluginGroupId,
                                                                         java.lang.String pluginArtifactId,
                                                                         java.lang.String executionId,
                                                                         java.lang.String goalId)
      • getReportConfiguration

        public org.codehaus.plexus.util.xml.Xpp3Dom getReportConfiguration​(java.lang.String pluginGroupId,
                                                                           java.lang.String pluginArtifactId,
                                                                           java.lang.String reportSetId)
      • getExecutionProject

        public MavenProject getExecutionProject()
      • setExecutionProject

        public void setExecutionProject​(MavenProject executionProject)
      • writeModel

        public void writeModel​(java.io.Writer writer)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeOriginalModel

        public void writeOriginalModel​(java.io.Writer writer)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • setDependencyArtifacts

        public void setDependencyArtifacts​(java.util.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​(java.util.Map map)
      • getManagedVersionMap

        public java.util.Map getManagedVersionMap()
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getBuildExtensions

        public java.util.List getBuildExtensions()
      • addProjectReference

        public void addProjectReference​(MavenProject project)
      • getProjectReferenceId

        public static java.lang.String getProjectReferenceId​(java.lang.String groupId,
                                                             java.lang.String artifactId,
                                                             java.lang.String version)
      • attachArtifact

        public void attachArtifact​(java.lang.String type,
                                   java.lang.String classifier,
                                   java.io.File file)
        Deprecated.
        Use MavenProjectHelper.attachArtifact(..) instead.
      • getProperties

        public java.util.Properties getProperties()
      • getFilters

        public java.util.List getFilters()
      • getProjectReferences

        public java.util.Map getProjectReferences()
      • isExecutionRoot

        public boolean isExecutionRoot()
      • setExecutionRoot

        public void setExecutionRoot​(boolean executionRoot)
      • getDefaultGoal

        public java.lang.String getDefaultGoal()
      • setModel

        protected void setModel​(Model model)
      • setAttachedArtifacts

        protected void setAttachedArtifacts​(java.util.List attachedArtifacts)
      • setCompileSourceRoots

        protected void setCompileSourceRoots​(java.util.List compileSourceRoots)
      • setTestCompileSourceRoots

        protected void setTestCompileSourceRoots​(java.util.List testCompileSourceRoots)
      • setScriptSourceRoots

        protected void setScriptSourceRoots​(java.util.List scriptSourceRoots)
      • getReleaseArtifactRepository

        protected ArtifactRepository getReleaseArtifactRepository()
      • getSnapshotArtifactRepository

        protected ArtifactRepository getSnapshotArtifactRepository()
      • resolveActiveArtifacts

        public void resolveActiveArtifacts()
      • replaceWithActiveArtifact

        public Artifact replaceWithActiveArtifact​(Artifact pluginArtifact)
      • findMatchingArtifact

        private Artifact findMatchingArtifact​(java.util.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 java.lang.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)
      • toString

        public java.lang.String toString()
        Default toString
        Overrides:
        toString in class java.lang.Object
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.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 java.util.List getDynamicCompileSourceRoots()
      • getOriginalInterpolatedCompileSourceRoots

        public java.util.List getOriginalInterpolatedCompileSourceRoots()
      • getDynamicTestCompileSourceRoots

        public java.util.List getDynamicTestCompileSourceRoots()
      • getOriginalInterpolatedTestCompileSourceRoots

        public java.util.List getOriginalInterpolatedTestCompileSourceRoots()
      • getDynamicScriptSourceRoots

        public java.util.List getDynamicScriptSourceRoots()
      • getOriginalInterpolatedScriptSourceRoots

        public java.util.List getOriginalInterpolatedScriptSourceRoots()
      • clearRestorableRoots

        public void clearRestorableRoots()
      • clearRestorableBuild

        public void clearRestorableBuild()
      • preserveCompileSourceRoots

        public void preserveCompileSourceRoots​(java.util.List originalInterpolatedCompileSourceRoots)
      • preserveTestCompileSourceRoots

        public void preserveTestCompileSourceRoots​(java.util.List originalInterpolatedTestCompileSourceRoots)
      • preserveScriptSourceRoots

        public void preserveScriptSourceRoots​(java.util.List originalInterpolatedScriptSourceRoots)
      • preserveBuild

        public void preserveBuild​(Build originalInterpolatedBuild)
      • setDynamicBuild

        protected void setDynamicBuild​(Build dynamicBuild)
      • setOriginalInterpolatedBuild

        protected void setOriginalInterpolatedBuild​(Build originalInterpolatedBuild)
      • setDynamicCompileSourceRoots

        protected void setDynamicCompileSourceRoots​(java.util.List dynamicCompileSourceRoots)
      • setOriginalInterpolatedCompileSourceRoots

        protected void setOriginalInterpolatedCompileSourceRoots​(java.util.List originalInterpolatedCompileSourceRoots)
      • setDynamicTestCompileSourceRoots

        protected void setDynamicTestCompileSourceRoots​(java.util.List dynamicTestCompileSourceRoots)
      • setOriginalInterpolatedTestCompileSourceRoots

        protected void setOriginalInterpolatedTestCompileSourceRoots​(java.util.List originalInterpolatedTestCompileSourceRoots)
      • setDynamicScriptSourceRoots

        protected void setDynamicScriptSourceRoots​(java.util.List dynamicScriptSourceRoots)
      • setOriginalInterpolatedScriptSourceRoots

        protected void setOriginalInterpolatedScriptSourceRoots​(java.util.List originalInterpolatedScriptSourceRoots)
      • getPreservedProperties

        public java.util.Properties getPreservedProperties()
      • preserveProperties

        public void preserveProperties()
      • getPreservedBasedir

        public java.io.File getPreservedBasedir()
      • preserveBasedir

        public void preserveBasedir()
      • setLogger

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

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