Package org.apache.maven.project
Class DefaultMavenProjectBuilder
java.lang.Object
org.codehaus.plexus.logging.AbstractLogEnabled
org.apache.maven.project.DefaultMavenProjectBuilder
- All Implemented Interfaces:
MavenProjectBuilder
,org.codehaus.plexus.logging.LogEnabled
,org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
,org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
public class DefaultMavenProjectBuilder
extends org.codehaus.plexus.logging.AbstractLogEnabled
implements MavenProjectBuilder, org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable, org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
- Version:
- $Id: DefaultMavenProjectBuilder.java 788791 2009-06-26 17:55:26Z jdcasey $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ProjectArtifactFactory
protected ArtifactMetadataSource
private ArtifactRepositoryFactory
protected ArtifactResolver
private org.codehaus.plexus.PlexusContainer
static final String
private ModelDefaultsInjector
private ModelInheritanceAssembler
private ModelInterpolator
private MavenXpp3Reader
private PathTranslator
private Map
private ProfileInjector
protected MavenProfilesBuilder
private Map
private ModelValidator
private WagonManager
Fields inherited from interface org.apache.maven.project.MavenProjectBuilder
ROLE, STANDALONE_SUPERPOM_ARTIFACTID, STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_VERSION
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate MavenProject
assembleLineage
(Model model, LinkedList lineage, ProjectBuilderConfiguration config, File projectDescriptor, List parentSearchRepositories, Set aggregatedRemoteWagonRepositories, boolean strict) build
(File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager) build
(File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager, boolean checkDistributionManagementStatus) build
(File pom, ProjectBuilderConfiguration config) build
(File pom, ProjectBuilderConfiguration config, boolean checkDistributionManagementStatus) private List
buildArtifactRepositories
(Model model) buildFromRepository
(Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository) Build the artifact from the local repository, resolving it if necessary.buildFromRepository
(Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository, boolean allowStubModel) Build the artifact from the local repository, resolving it if necessary.private MavenProject
buildFromSourceFileInternal
(File projectDescriptor, ProjectBuilderConfiguration config, boolean checkDistributionManagementStatus) private MavenProject
buildInternal
(String pomLocation, Model model, ProjectBuilderConfiguration config, List parentSearchRepositories, File projectDescriptor, boolean strict) buildStandaloneSuperProject
(ArtifactRepository localRepository) buildStandaloneSuperProject
(ArtifactRepository localRepository, ProfileManager profileManager) need to pass a profilemanager with correct context (eg.buildWithDependencies
(File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager) buildWithDependencies
(File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager, org.apache.maven.wagon.events.TransferListener transferListener) private void
calculateConcreteProjectReferences
(MavenProject project, ProjectBuilderConfiguration config, Set processedProjects) void
calculateConcreteState
(MavenProject project, ProjectBuilderConfiguration config) Variant ofMavenProjectBuilder.calculateConcreteState(MavenProject, ProjectBuilderConfiguration, boolean)
which assumes that project references should be processed.void
calculateConcreteState
(MavenProject project, ProjectBuilderConfiguration config, boolean processProjectReferences) Up to this point, the build section of the POM remains uninterpolated except for the artifact coordinates it contains.private void
calculateConcreteStateInternal
(MavenProject project, ProjectBuilderConfiguration config, boolean processProjectReferences, Set processedProjects) private void
checkStatusAndUpdate
(Artifact projectArtifact, ArtifactStatus status, File file, List remoteArtifactRepositories, ArtifactRepository localRepository) private List
collectRestoredListOfPatterns
(List patterns, List originalPatterns, List originalInterpolatedPatterns) void
contextualize
(org.codehaus.plexus.context.Context context) private static String
createCacheKey
(String groupId, String artifactId, String version) protected Set
createExtensionArtifacts
(String projectId, List extensions) private Map
createManagedVersionMap
(String projectId, DependencyManagement dependencyManagement, MavenProject parent) protected Set
createPluginArtifacts
(String projectId, List plugins) protected Set
createReportArtifacts
(String projectId, List reports) private Model
createStubModel
(Artifact projectArtifact) private void
private Model
findModelFromRepository
(Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository, boolean allowStubModel) private Model
void
private void
initResourceMergeIds
(List resources) private List
injectActiveProfiles
(ProfileManager profileManager, Model model) private List
interpolateListOfStrings
(List originalStrings, Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugMessages) private void
loadProjectExternalProfiles
(ProfileManager profileManager, File projectDir) private void
mergeDeterministicBuildElements
(Build interpolatedBuild, Build dynamicBuild) private void
mergeDeterministicPluginElements
(List iPlugins, List dPlugins) private void
mergeManagedDependencies
(Model model, ArtifactRepository localRepository, List parentSearchRepositories) private List
normalizeToArtifactRepositories
(List remoteArtifactRepositories, String projectId) private boolean
objectEquals
(Object obj1, Object obj2) private MavenProject
processProjectLogic
(String pomLocation, MavenProject project, ProjectBuilderConfiguration config, File projectDir, List remoteRepositories, boolean strict, boolean isSuperPom) private boolean
projectWasChanged
(MavenProject project) private void
propagateNewPlugins
(MavenProject project) private Model
private Model
private Model
private void
restoreBuildRoots
(MavenProject project, ProjectBuilderConfiguration config, boolean debugMessages) private void
restoreDynamicProjectReferences
(MavenProject project, ProjectBuilderConfiguration config, Set processedProjects) void
restoreDynamicState
(MavenProject project, ProjectBuilderConfiguration config) void
restoreDynamicState
(MavenProject project, ProjectBuilderConfiguration config, boolean processProjectReferences) private void
restoreDynamicStateInternal
(MavenProject project, ProjectBuilderConfiguration config, boolean processProjectReferences, Set processedProjects) private List
restoreListOfStrings
(List originalStrings, List originalInterpolatedStrings, List changedStrings, MavenProject project, ProjectBuilderConfiguration config, boolean debugMessages) private void
restoreModelBuildSection
(MavenProject project, ProjectBuilderConfiguration config, boolean debugMessages) private List
restoreResources
(List originalResources, List originalInterpolatedResources, List changedResources, MavenProject project, ProjectBuilderConfiguration config, boolean debugMessages) private String
restoreString
(String originalString, String originalInterpolatedString, String changedString, MavenProject project, ProjectBuilderConfiguration config, boolean debugMessages) private String
safeVersionlessKey
(String groupId, String artifactId) private List
translateListOfPaths
(List paths, File basedir) Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
container
private org.codehaus.plexus.PlexusContainer container -
profilesBuilder
-
artifactResolver
-
artifactMetadataSource
-
artifactFactory
-
modelInheritanceAssembler
-
profileInjector
-
validator
-
rawProjectCache
-
processedProjectCache
-
modelReader
-
pathTranslator
-
modelDefaultsInjector
-
modelInterpolator
-
artifactRepositoryFactory
-
wagonManager
-
MAVEN_MODEL_VERSION
- See Also:
-
-
Constructor Details
-
DefaultMavenProjectBuilder
public DefaultMavenProjectBuilder()
-
-
Method Details
-
initialize
public void initialize()- Specified by:
initialize
in interfaceorg.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
-
build
public MavenProject build(File pom, ProjectBuilderConfiguration config) throws ProjectBuildingException - Specified by:
build
in interfaceMavenProjectBuilder
- Throws:
ProjectBuildingException
-
build
public MavenProject build(File pom, ProjectBuilderConfiguration config, boolean checkDistributionManagementStatus) throws ProjectBuildingException - Specified by:
build
in interfaceMavenProjectBuilder
- Throws:
ProjectBuildingException
-
build
public MavenProject build(File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager) throws ProjectBuildingException - Specified by:
build
in interfaceMavenProjectBuilder
- Throws:
ProjectBuildingException
-
build
public MavenProject build(File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager, boolean checkDistributionManagementStatus) throws ProjectBuildingException - Specified by:
build
in interfaceMavenProjectBuilder
- Throws:
ProjectBuildingException
-
buildFromRepository
public MavenProject buildFromRepository(Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository, boolean allowStubModel) throws ProjectBuildingException Description copied from interface:MavenProjectBuilder
Build the artifact from the local repository, resolving it if necessary.- Specified by:
buildFromRepository
in interfaceMavenProjectBuilder
- Parameters:
artifact
- the artifact descriptionremoteArtifactRepositories
- the remote repository listlocalRepository
- the local repositoryallowStubModel
- return a stub if the POM is not found- Returns:
- the built project
- Throws:
ProjectBuildingException
-
buildFromRepository
public MavenProject buildFromRepository(Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository) throws ProjectBuildingException Description copied from interface:MavenProjectBuilder
Build the artifact from the local repository, resolving it if necessary.- Specified by:
buildFromRepository
in interfaceMavenProjectBuilder
- Parameters:
artifact
- the artifact descriptionremoteArtifactRepositories
- the remote repository listlocalRepository
- the local repository- Returns:
- the built project
- Throws:
ProjectBuildingException
-
buildStandaloneSuperProject
public MavenProject buildStandaloneSuperProject(ArtifactRepository localRepository) throws ProjectBuildingException - Specified by:
buildStandaloneSuperProject
in interfaceMavenProjectBuilder
- Throws:
ProjectBuildingException
-
buildStandaloneSuperProject
public MavenProject buildStandaloneSuperProject(ArtifactRepository localRepository, ProfileManager profileManager) throws ProjectBuildingException Description copied from interface:MavenProjectBuilder
need to pass a profilemanager with correct context (eg. with execution properties)- Specified by:
buildStandaloneSuperProject
in interfaceMavenProjectBuilder
- Throws:
ProjectBuildingException
-
buildStandaloneSuperProject
public MavenProject buildStandaloneSuperProject(ProjectBuilderConfiguration config) throws ProjectBuildingException - Specified by:
buildStandaloneSuperProject
in interfaceMavenProjectBuilder
- Throws:
ProjectBuildingException
-
buildWithDependencies
public MavenProject buildWithDependencies(File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException - Specified by:
buildWithDependencies
in interfaceMavenProjectBuilder
- Throws:
ProjectBuildingException
ArtifactResolutionException
ArtifactNotFoundException
-
buildWithDependencies
public MavenProject buildWithDependencies(File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager, org.apache.maven.wagon.events.TransferListener transferListener) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException - Specified by:
buildWithDependencies
in interfaceMavenProjectBuilder
- Throws:
ProjectBuildingException
ArtifactResolutionException
ArtifactNotFoundException
-
ensureMetadataSourceIsInitialized
- Throws:
ProjectBuildingException
-
createManagedVersionMap
private Map createManagedVersionMap(String projectId, DependencyManagement dependencyManagement, MavenProject parent) throws ProjectBuildingException - Throws:
ProjectBuildingException
-
buildFromSourceFileInternal
private MavenProject buildFromSourceFileInternal(File projectDescriptor, ProjectBuilderConfiguration config, boolean checkDistributionManagementStatus) throws ProjectBuildingException - Throws:
ProjectBuildingException
-
findModelFromRepository
private Model findModelFromRepository(Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository, boolean allowStubModel) throws ProjectBuildingException - Throws:
ProjectBuildingException
-
normalizeToArtifactRepositories
private List normalizeToArtifactRepositories(List remoteArtifactRepositories, String projectId) throws ProjectBuildingException - Throws:
ProjectBuildingException
-
checkStatusAndUpdate
private void checkStatusAndUpdate(Artifact projectArtifact, ArtifactStatus status, File file, List remoteArtifactRepositories, ArtifactRepository localRepository) throws ArtifactNotFoundException - Throws:
ArtifactNotFoundException
-
createStubModel
-
buildInternal
private MavenProject buildInternal(String pomLocation, Model model, ProjectBuilderConfiguration config, List parentSearchRepositories, File projectDescriptor, boolean strict) throws ProjectBuildingException - Throws:
ProjectBuildingException
-
safeVersionlessKey
-
buildArtifactRepositories
- Throws:
ProjectBuildingException
-
processProjectLogic
private MavenProject processProjectLogic(String pomLocation, MavenProject project, ProjectBuilderConfiguration config, File projectDir, List remoteRepositories, boolean strict, boolean isSuperPom) throws ProjectBuildingException, ModelInterpolationException, InvalidRepositoryException -
mergeDeterministicBuildElements
-
mergeDeterministicPluginElements
-
assembleLineage
private MavenProject assembleLineage(Model model, LinkedList lineage, ProjectBuilderConfiguration config, File projectDescriptor, List parentSearchRepositories, Set aggregatedRemoteWagonRepositories, boolean strict) throws ProjectBuildingException, InvalidRepositoryException -
mergeManagedDependencies
private void mergeManagedDependencies(Model model, ArtifactRepository localRepository, List parentSearchRepositories) throws ProjectBuildingException - Throws:
ProjectBuildingException
-
injectActiveProfiles
private List injectActiveProfiles(ProfileManager profileManager, Model model) throws ProjectBuildingException - Throws:
ProjectBuildingException
-
loadProjectExternalProfiles
private void loadProjectExternalProfiles(ProfileManager profileManager, File projectDir) throws ProfileActivationException - Throws:
ProfileActivationException
-
readModel
private Model readModel(String projectId, File file, boolean strict) throws ProjectBuildingException - Throws:
ProjectBuildingException
-
readModel
private Model readModel(String projectId, String pomLocation, Reader reader, boolean strict) throws IOException, InvalidProjectModelException -
readModel
- Throws:
ProjectBuildingException
-
createCacheKey
-
createPluginArtifacts
- Throws:
ProjectBuildingException
-
createReportArtifacts
- Throws:
ProjectBuildingException
-
createExtensionArtifacts
protected Set createExtensionArtifacts(String projectId, List extensions) throws ProjectBuildingException - Throws:
ProjectBuildingException
-
getSuperModel
- Throws:
ProjectBuildingException
-
contextualize
public void contextualize(org.codehaus.plexus.context.Context context) throws org.codehaus.plexus.context.ContextException - Specified by:
contextualize
in interfaceorg.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
- Throws:
org.codehaus.plexus.context.ContextException
-
calculateConcreteState
public void calculateConcreteState(MavenProject project, ProjectBuilderConfiguration config) throws ModelInterpolationException Variant ofMavenProjectBuilder.calculateConcreteState(MavenProject, ProjectBuilderConfiguration, boolean)
which assumes that project references should be processed. This is provided for performance reasons, for cases where you know all projects in the reactor will be processed, making traversal of project references unnecessary.- Specified by:
calculateConcreteState
in interfaceMavenProjectBuilder
- Throws:
ModelInterpolationException
-
calculateConcreteState
public void calculateConcreteState(MavenProject project, ProjectBuilderConfiguration config, boolean processProjectReferences) throws ModelInterpolationException Up to this point, the build section of the POM remains uninterpolated except for the artifact coordinates it contains. This method will interpolate the build section and associated project-instance data structures. Along with theMavenProjectBuilder#restoreDynamicState(MavenProject, ProjectBuilderConfiguration, boolean)
method, this method allows expressions in these areas of the POM and project instance to be reevaluated in the event that a mojo changes one the build-path values, or a project property.
This method will process the following:- the specified project's parent project (if not null)
- specified project
- its execution project (if not null)
- any project references (iff processReferences == true)
- Specified by:
calculateConcreteState
in interfaceMavenProjectBuilder
- Throws:
ModelInterpolationException
-
calculateConcreteStateInternal
private void calculateConcreteStateInternal(MavenProject project, ProjectBuilderConfiguration config, boolean processProjectReferences, Set processedProjects) throws ModelInterpolationException - Throws:
ModelInterpolationException
-
initResourceMergeIds
-
calculateConcreteProjectReferences
private void calculateConcreteProjectReferences(MavenProject project, ProjectBuilderConfiguration config, Set processedProjects) throws ModelInterpolationException - Throws:
ModelInterpolationException
-
translateListOfPaths
-
restoreDynamicState
public void restoreDynamicState(MavenProject project, ProjectBuilderConfiguration config) throws ModelInterpolationException - Throws:
ModelInterpolationException
-
restoreDynamicState
public void restoreDynamicState(MavenProject project, ProjectBuilderConfiguration config, boolean processProjectReferences) throws ModelInterpolationException - Throws:
ModelInterpolationException
-
restoreDynamicStateInternal
private void restoreDynamicStateInternal(MavenProject project, ProjectBuilderConfiguration config, boolean processProjectReferences, Set processedProjects) throws ModelInterpolationException - Throws:
ModelInterpolationException
-
projectWasChanged
-
objectEquals
-
propagateNewPlugins
-
restoreDynamicProjectReferences
private void restoreDynamicProjectReferences(MavenProject project, ProjectBuilderConfiguration config, Set processedProjects) throws ModelInterpolationException - Throws:
ModelInterpolationException
-
restoreBuildRoots
private void restoreBuildRoots(MavenProject project, ProjectBuilderConfiguration config, boolean debugMessages) throws ModelInterpolationException - Throws:
ModelInterpolationException
-
restoreModelBuildSection
private void restoreModelBuildSection(MavenProject project, ProjectBuilderConfiguration config, boolean debugMessages) throws ModelInterpolationException - Throws:
ModelInterpolationException
-
interpolateListOfStrings
private List interpolateListOfStrings(List originalStrings, Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugMessages) throws ModelInterpolationException - Throws:
ModelInterpolationException
-
restoreString
private String restoreString(String originalString, String originalInterpolatedString, String changedString, MavenProject project, ProjectBuilderConfiguration config, boolean debugMessages) throws ModelInterpolationException - Throws:
ModelInterpolationException
-
restoreListOfStrings
private List restoreListOfStrings(List originalStrings, List originalInterpolatedStrings, List changedStrings, MavenProject project, ProjectBuilderConfiguration config, boolean debugMessages) throws ModelInterpolationException - Throws:
ModelInterpolationException
-
restoreResources
private List restoreResources(List originalResources, List originalInterpolatedResources, List changedResources, MavenProject project, ProjectBuilderConfiguration config, boolean debugMessages) throws ModelInterpolationException - Throws:
ModelInterpolationException
-
collectRestoredListOfPatterns
-