mirror of https://github.com/apache/maven.git
Fixing a problem where parent POMs that are not found during model-lineage discovery were not previously stubbed out, and caused the build to fail where it didn't in 2.0.7
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@564299 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
711eb8c416
commit
db3f9be45e
|
@ -156,7 +156,7 @@ public class DefaultMavenProjectBuilder
|
|||
private ModelInheritanceAssembler modelInheritanceAssembler;
|
||||
|
||||
private ModelValidator validator;
|
||||
|
||||
|
||||
// TODO: make it a component
|
||||
private MavenXpp3Reader modelReader;
|
||||
|
||||
|
@ -167,9 +167,9 @@ public class DefaultMavenProjectBuilder
|
|||
private ModelInterpolator modelInterpolator;
|
||||
|
||||
private ModelLineageBuilder modelLineageBuilder;
|
||||
|
||||
|
||||
private ProfileAdvisor profileAdvisor;
|
||||
|
||||
|
||||
private BuildContextManager buildContextManager;
|
||||
|
||||
private MavenTools mavenTools;
|
||||
|
@ -178,7 +178,7 @@ public class DefaultMavenProjectBuilder
|
|||
// I am making this available for use with a new method that takes a
|
||||
// a monitor wagon monitor as a parameter so that tools can use the
|
||||
// methods here and receive callbacks. MNG-1015
|
||||
//
|
||||
//
|
||||
// Probably no longer relevant with wagonManager/wagonManager change - joakime
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
|
@ -223,8 +223,8 @@ public class DefaultMavenProjectBuilder
|
|||
throws ProjectBuildingException
|
||||
{
|
||||
ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
|
||||
|
||||
MavenProject project = (MavenProject) projectBuildCache.getCachedProject( artifact );
|
||||
|
||||
MavenProject project = projectBuildCache.getCachedProject( artifact );
|
||||
|
||||
if ( project != null )
|
||||
{
|
||||
|
@ -252,8 +252,8 @@ public class DefaultMavenProjectBuilder
|
|||
ProfileManager profileManager = new DefaultProfileManager( container );
|
||||
return buildStandaloneSuperProject( localRepository, profileManager );
|
||||
}
|
||||
|
||||
public MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository, ProfileManager profileManager )
|
||||
|
||||
public MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository, ProfileManager profileManager )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
Model superModel = getSuperModel();
|
||||
|
@ -265,27 +265,27 @@ public class DefaultMavenProjectBuilder
|
|||
superModel.setVersion( STANDALONE_SUPERPOM_VERSION );
|
||||
|
||||
MavenProject project = new MavenProject( superModel );
|
||||
|
||||
|
||||
ProjectBuildContext projectContext = ProjectBuildContext.getProjectBuildContext( buildContextManager, true );
|
||||
|
||||
|
||||
projectContext.setCurrentProject( project );
|
||||
projectContext.store( buildContextManager );
|
||||
|
||||
|
||||
String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
|
||||
|
||||
|
||||
project.setManagedVersionMap(createManagedVersionMap(projectId, superModel.getDependencyManagement(), null));
|
||||
|
||||
List activeProfiles = profileAdvisor.applyActivatedProfiles( superModel, null, profileManager.getExplicitlyActivatedIds(), profileManager.getExplicitlyDeactivatedIds() );
|
||||
List activeExternalProfiles = profileAdvisor.applyActivatedExternalProfiles( superModel, null, profileManager );
|
||||
|
||||
|
||||
LinkedHashSet profiles = new LinkedHashSet();
|
||||
|
||||
if ( activeProfiles != null && !activeProfiles.isEmpty() )
|
||||
|
||||
if ( ( activeProfiles != null ) && !activeProfiles.isEmpty() )
|
||||
{
|
||||
profiles.addAll( activeProfiles );
|
||||
}
|
||||
|
||||
if ( activeExternalProfiles != null && !activeExternalProfiles.isEmpty() )
|
||||
|
||||
if ( ( activeExternalProfiles != null ) && !activeExternalProfiles.isEmpty() )
|
||||
{
|
||||
profiles.addAll( activeExternalProfiles );
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ public class DefaultMavenProjectBuilder
|
|||
{
|
||||
Map map = null;
|
||||
List deps;
|
||||
if ( dependencyManagement != null && (deps = dependencyManagement.getDependencies()) != null && deps.size() > 0)
|
||||
if ( ( dependencyManagement != null ) && ( (deps = dependencyManagement.getDependencies()) != null ) && ( deps.size() > 0 ))
|
||||
{
|
||||
map = new ManagedVersionMap( map );
|
||||
|
||||
|
@ -436,7 +436,7 @@ public class DefaultMavenProjectBuilder
|
|||
// If the dependencyManagement section listed exclusions,
|
||||
// add them to the managed artifacts here so that transitive
|
||||
// dependencies will be excluded if necessary.
|
||||
if ( null != d.getExclusions() && !d.getExclusions().isEmpty() )
|
||||
if ( ( null != d.getExclusions() ) && !d.getExclusions().isEmpty() )
|
||||
{
|
||||
List exclusions = new ArrayList();
|
||||
Iterator exclItr = d.getExclusions().iterator();
|
||||
|
@ -479,7 +479,7 @@ public class DefaultMavenProjectBuilder
|
|||
{
|
||||
container.addContextValue("SystemProperties", System.getProperties());
|
||||
}
|
||||
|
||||
|
||||
Model model = readModel( "unknown", projectDescriptor, STRICT_MODEL_PARSING );
|
||||
|
||||
MavenProject project = buildInternal( projectDescriptor.getAbsolutePath(),
|
||||
|
@ -492,7 +492,7 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
if ( checkDistributionManagementStatus )
|
||||
{
|
||||
if ( project.getDistributionManagement() != null && project.getDistributionManagement().getStatus() != null )
|
||||
if ( ( project.getDistributionManagement() != null ) && ( project.getDistributionManagement().getStatus() != null ) )
|
||||
{
|
||||
String projectId = safeVersionlessKey( project.getGroupId(), project.getArtifactId() );
|
||||
|
||||
|
@ -593,7 +593,7 @@ public class DefaultMavenProjectBuilder
|
|||
throws ArtifactNotFoundException
|
||||
{
|
||||
// TODO: configurable actions dependant on status
|
||||
if ( !projectArtifact.isSnapshot() && status.compareTo( ArtifactStatus.DEPLOYED ) < 0 )
|
||||
if ( !projectArtifact.isSnapshot() && ( status.compareTo( ArtifactStatus.DEPLOYED ) < 0 ) )
|
||||
{
|
||||
// use default policy (enabled, daily update, warn on bad checksum)
|
||||
ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy();
|
||||
|
@ -674,12 +674,12 @@ public class DefaultMavenProjectBuilder
|
|||
Model superModel = getSuperModel();
|
||||
|
||||
MavenProject superProject = new MavenProject( superModel );
|
||||
|
||||
|
||||
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
|
||||
|
||||
List explicitlyActive;
|
||||
List explicitlyInactive;
|
||||
|
||||
|
||||
if ( externalProfileManager != null )
|
||||
{
|
||||
// used to trigger the caching of SystemProperties in the container context...
|
||||
|
@ -691,7 +691,7 @@ public class DefaultMavenProjectBuilder
|
|||
{
|
||||
throw new ProjectBuildingException( projectId, "Failed to activate external profiles.", e );
|
||||
}
|
||||
|
||||
|
||||
explicitlyActive = externalProfileManager.getExplicitlyActivatedIds();
|
||||
explicitlyInactive = externalProfileManager.getExplicitlyDeactivatedIds();
|
||||
}
|
||||
|
@ -700,7 +700,7 @@ public class DefaultMavenProjectBuilder
|
|||
explicitlyActive = Collections.EMPTY_LIST;
|
||||
explicitlyInactive = Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
|
||||
superProject.setActiveProfiles( profileAdvisor.applyActivatedProfiles( superModel, null, explicitlyActive, explicitlyInactive ) );
|
||||
|
||||
//noinspection CollectionDeclaredAsConcreteClass
|
||||
|
@ -710,7 +710,7 @@ public class DefaultMavenProjectBuilder
|
|||
parentSearchRepositories,
|
||||
projectDir, explicitlyActive,
|
||||
explicitlyInactive );
|
||||
|
||||
|
||||
Model originalModel = ModelUtils.cloneModel( model );
|
||||
|
||||
MavenProject project = null;
|
||||
|
@ -754,8 +754,12 @@ public class DefaultMavenProjectBuilder
|
|||
getLogger().debug( "Cannot determine whether " + currentProject.getId() + " is a module of " + previousProject.getId() + ". Reason: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
getLogger().debug( "[buildInternal] Assembling model-inheritance: child=" + current.getId() + ", parent=" + previous.getId() );
|
||||
|
||||
modelInheritanceAssembler.assembleModelInheritance( current, previous, pathAdjustment );
|
||||
|
||||
getLogger().debug( "[buildInternal] Assembled model-inheritance for child=" + current.getId() );
|
||||
|
||||
previous = current;
|
||||
previousProject = currentProject;
|
||||
}
|
||||
|
@ -810,13 +814,13 @@ public class DefaultMavenProjectBuilder
|
|||
// Only track the file of a POM in the source tree
|
||||
project.setFile( projectDescriptor );
|
||||
}
|
||||
|
||||
|
||||
MavenProject rawParent = project.getParent();
|
||||
|
||||
|
||||
if ( rawParent != null )
|
||||
{
|
||||
MavenProject processedParent = (MavenProject) projectBuildCache.getCachedProject( rawParent );
|
||||
|
||||
MavenProject processedParent = projectBuildCache.getCachedProject( rawParent );
|
||||
|
||||
// yeah, this null check might be a bit paranoid, but better safe than sorry...
|
||||
if ( processedParent != null )
|
||||
{
|
||||
|
@ -829,10 +833,10 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
return project;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Order is:
|
||||
*
|
||||
*
|
||||
* 1. model profile repositories
|
||||
* 2. model repositories
|
||||
* 3. superModel profile repositories
|
||||
|
@ -844,16 +848,16 @@ public class DefaultMavenProjectBuilder
|
|||
throws ProjectBuildingException
|
||||
{
|
||||
LinkedHashSet collected = new LinkedHashSet();
|
||||
|
||||
|
||||
collectInitialRepositoriesFromModel( collected, model, projectDir, explicitlyActive, explicitlyInactive );
|
||||
|
||||
collectInitialRepositoriesFromModel( collected, superModel, projectDir, explicitlyActive, explicitlyInactive );
|
||||
|
||||
if ( parentSearchRepositories != null && !parentSearchRepositories.isEmpty() )
|
||||
if ( ( parentSearchRepositories != null ) && !parentSearchRepositories.isEmpty() )
|
||||
{
|
||||
collected.addAll( parentSearchRepositories );
|
||||
}
|
||||
|
||||
|
||||
return collected;
|
||||
}
|
||||
|
||||
|
@ -865,13 +869,13 @@ public class DefaultMavenProjectBuilder
|
|||
explicitlyActive,
|
||||
explicitlyInactive );
|
||||
|
||||
if ( reposFromProfiles != null && !reposFromProfiles.isEmpty() )
|
||||
if ( ( reposFromProfiles != null ) && !reposFromProfiles.isEmpty() )
|
||||
{
|
||||
collected.addAll( reposFromProfiles );
|
||||
}
|
||||
|
||||
List modelRepos = model.getRepositories();
|
||||
if ( modelRepos != null && !modelRepos.isEmpty() )
|
||||
if ( ( modelRepos != null ) && !modelRepos.isEmpty() )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -967,7 +971,7 @@ public class DefaultMavenProjectBuilder
|
|||
MavenProject parentProject = project.getParent();
|
||||
|
||||
Model originalModel = project.getOriginalModel();
|
||||
|
||||
|
||||
Artifact parentArtifact = project.getParentArtifact();
|
||||
|
||||
// We will return a different project object using the new model (hence the need to return a project, not just modify the parameter)
|
||||
|
@ -1049,17 +1053,17 @@ public class DefaultMavenProjectBuilder
|
|||
{
|
||||
ModelLineage modelLineage = new DefaultModelLineage();
|
||||
modelLineage.setOrigin( model, new File( projectDir, "pom.xml" ), new ArrayList( aggregatedRemoteWagonRepositories ) );
|
||||
|
||||
|
||||
modelLineageBuilder.resumeBuildingModelLineage( modelLineage, localRepository, externalProfileManager );
|
||||
|
||||
|
||||
ProjectBuildContext projectContext = ProjectBuildContext.getProjectBuildContext( buildContextManager, true );
|
||||
|
||||
|
||||
projectContext.setModelLineage( modelLineage );
|
||||
projectContext.store( buildContextManager );
|
||||
|
||||
|
||||
List explicitlyActive;
|
||||
List explicitlyInactive;
|
||||
|
||||
|
||||
if ( externalProfileManager != null )
|
||||
{
|
||||
explicitlyActive = externalProfileManager.getExplicitlyActivatedIds();
|
||||
|
@ -1070,50 +1074,53 @@ public class DefaultMavenProjectBuilder
|
|||
explicitlyActive = Collections.EMPTY_LIST;
|
||||
explicitlyInactive = Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
|
||||
MavenProject lastProject = null;
|
||||
for ( ModelLineageIterator it = modelLineage.lineageIterator(); it.hasNext(); )
|
||||
{
|
||||
Model currentModel = (Model) it.next();
|
||||
|
||||
getLogger().debug( "[assembleLineage] Assembling MavenProject instance for: " + currentModel.getId() );
|
||||
|
||||
File currentPom = it.getPOMFile();
|
||||
|
||||
|
||||
MavenProject project = new MavenProject( currentModel );
|
||||
project.setFile( currentPom );
|
||||
|
||||
|
||||
projectContext.setCurrentProject( project );
|
||||
projectContext.store( buildContextManager );
|
||||
|
||||
project.setActiveProfiles( profileAdvisor.applyActivatedProfiles( currentModel, projectDir, explicitlyActive,
|
||||
explicitlyInactive ) );
|
||||
|
||||
|
||||
if ( lastProject != null )
|
||||
{
|
||||
lastProject.setParent( project );
|
||||
|
||||
|
||||
lastProject.setParentArtifact( artifactFactory.createParentArtifact( project.getGroupId(), project
|
||||
.getArtifactId(), project.getVersion() ) );
|
||||
}
|
||||
|
||||
|
||||
lineage.addFirst( project );
|
||||
|
||||
|
||||
lastProject = project;
|
||||
}
|
||||
|
||||
MavenProject result = (MavenProject) lineage.getLast();
|
||||
|
||||
|
||||
if ( externalProfileManager != null )
|
||||
{
|
||||
LinkedHashSet active = new LinkedHashSet();
|
||||
|
||||
|
||||
List existingActiveProfiles = result.getActiveProfiles();
|
||||
if ( existingActiveProfiles != null && !existingActiveProfiles.isEmpty() )
|
||||
if ( ( existingActiveProfiles != null ) && !existingActiveProfiles.isEmpty() )
|
||||
{
|
||||
active.addAll( existingActiveProfiles );
|
||||
}
|
||||
|
||||
|
||||
profileAdvisor.applyActivatedExternalProfiles( result.getModel(), projectDir, externalProfileManager );
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1343,6 +1350,6 @@ public class DefaultMavenProjectBuilder
|
|||
public void contextualize( Context context )
|
||||
throws ContextException
|
||||
{
|
||||
this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
||||
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class DefaultModelLineageBuilder
|
|||
private MavenTools mavenTools;
|
||||
|
||||
private ProfileAdvisor profileAdvisor;
|
||||
|
||||
|
||||
private BuildContextManager buildContextManager;
|
||||
|
||||
private Logger logger;
|
||||
|
@ -78,7 +78,7 @@ public class DefaultModelLineageBuilder
|
|||
|
||||
public DefaultModelLineageBuilder( ArtifactResolver resolver, ArtifactFactory artifactFactory, BuildContextManager buildContextManager )
|
||||
{
|
||||
this.artifactResolver = resolver;
|
||||
artifactResolver = resolver;
|
||||
this.artifactFactory = artifactFactory;
|
||||
this.buildContextManager = buildContextManager;
|
||||
}
|
||||
|
@ -91,30 +91,28 @@ public class DefaultModelLineageBuilder
|
|||
throws ProjectBuildingException
|
||||
{
|
||||
ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
|
||||
|
||||
|
||||
ModelLineage lineage = new DefaultModelLineage();
|
||||
|
||||
File pomFile = pom;
|
||||
List currentRemoteRepositories = remoteRepositories == null ? new ArrayList()
|
||||
: new ArrayList( remoteRepositories );
|
||||
|
||||
while ( pomFile != null )
|
||||
{
|
||||
Model model = readModel( pomFile, projectBuildCache );
|
||||
ModelAndFile current = new ModelAndFile( readModel( pom, projectBuildCache ), pom );
|
||||
|
||||
while ( current != null )
|
||||
{
|
||||
if ( lineage.size() == 0 )
|
||||
{
|
||||
lineage.setOrigin( model, pomFile, currentRemoteRepositories );
|
||||
lineage.setOrigin( current.model, current.file, currentRemoteRepositories );
|
||||
}
|
||||
else
|
||||
{
|
||||
lineage.addParent( model, pomFile, currentRemoteRepositories );
|
||||
lineage.addParent( current.model, current.file, currentRemoteRepositories );
|
||||
}
|
||||
|
||||
currentRemoteRepositories = updateRepositorySet( model, currentRemoteRepositories, pomFile, profileManager );
|
||||
currentRemoteRepositories = updateRepositorySet( current.model, currentRemoteRepositories, current.file, profileManager );
|
||||
|
||||
pomFile = resolveParentPom( model, currentRemoteRepositories, localRepository, pomFile,
|
||||
projectBuildCache );
|
||||
current = resolveParentPom( current, currentRemoteRepositories, localRepository, projectBuildCache );
|
||||
}
|
||||
|
||||
return lineage;
|
||||
|
@ -125,8 +123,7 @@ public class DefaultModelLineageBuilder
|
|||
throws ProjectBuildingException
|
||||
{
|
||||
ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
|
||||
|
||||
File pomFile = lineage.getDeepestFile();
|
||||
|
||||
List currentRemoteRepositories = lineage.getDeepestArtifactRepositoryList();
|
||||
|
||||
if ( currentRemoteRepositories == null )
|
||||
|
@ -134,28 +131,25 @@ public class DefaultModelLineageBuilder
|
|||
currentRemoteRepositories = new ArrayList();
|
||||
}
|
||||
|
||||
Model model = lineage.getDeepestModel();
|
||||
ModelAndFile current = new ModelAndFile( lineage.getDeepestModel(), lineage.getDeepestFile() );
|
||||
|
||||
// use the above information to re-bootstrap the resolution chain...
|
||||
pomFile = resolveParentPom( model, currentRemoteRepositories, localRepository, pomFile, projectBuildCache );
|
||||
current = resolveParentPom( current, currentRemoteRepositories, localRepository, projectBuildCache );
|
||||
|
||||
while ( pomFile != null )
|
||||
while ( current != null )
|
||||
{
|
||||
model = readModel( pomFile, projectBuildCache );
|
||||
|
||||
if ( lineage.size() == 0 )
|
||||
{
|
||||
lineage.setOrigin( model, pomFile, currentRemoteRepositories );
|
||||
lineage.setOrigin( current.model, current.file, currentRemoteRepositories );
|
||||
}
|
||||
else
|
||||
{
|
||||
lineage.addParent( model, pomFile, currentRemoteRepositories );
|
||||
lineage.addParent( current.model, current.file, currentRemoteRepositories );
|
||||
}
|
||||
|
||||
currentRemoteRepositories = updateRepositorySet( model, currentRemoteRepositories, pomFile, profileManager );
|
||||
currentRemoteRepositories = updateRepositorySet( current.model, currentRemoteRepositories, current.file, profileManager );
|
||||
|
||||
pomFile = resolveParentPom( model, currentRemoteRepositories, localRepository, pomFile,
|
||||
projectBuildCache );
|
||||
current = resolveParentPom( current, currentRemoteRepositories, localRepository, projectBuildCache );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,7 +164,7 @@ public class DefaultModelLineageBuilder
|
|||
}
|
||||
|
||||
/**
|
||||
* Read the Model instance from the given POM file, and cache it in the given Map before
|
||||
* Read the Model instance from the given POM file, and cache it in the given Map before
|
||||
* returning it.
|
||||
*/
|
||||
private Model readModel( File pomFile, ProjectBuildCache projectBuildCache )
|
||||
|
@ -193,7 +187,7 @@ public class DefaultModelLineageBuilder
|
|||
pomFile = new File( pom, "pom.xml" );
|
||||
// getLogger().debug( "readModel(..): POM: " + pom + " is a directory. Trying: " + pomFile + " instead." );
|
||||
}
|
||||
|
||||
|
||||
Model model;
|
||||
FileReader reader = null;
|
||||
|
||||
|
@ -225,10 +219,10 @@ public class DefaultModelLineageBuilder
|
|||
}
|
||||
|
||||
/**
|
||||
* Update the remote repository set used to resolve parent POMs, by adding those declared in
|
||||
* Update the remote repository set used to resolve parent POMs, by adding those declared in
|
||||
* the given model to the HEAD of a new list, then appending the old remote repositories list.
|
||||
* The specified pomFile is used for error reporting.
|
||||
* @param profileManager
|
||||
* @param profileManager
|
||||
*/
|
||||
private List updateRepositorySet( Model model, List oldArtifactRepositories, File pomFile,
|
||||
ProfileManager externalProfileManager )
|
||||
|
@ -236,7 +230,9 @@ public class DefaultModelLineageBuilder
|
|||
{
|
||||
List repositories = model.getRepositories();
|
||||
|
||||
loadActiveProfileRepositories( repositories, model, externalProfileManager, pomFile.getParentFile() );
|
||||
File projectDir = pomFile == null ? null : pomFile.getParentFile();
|
||||
|
||||
loadActiveProfileRepositories( repositories, model, externalProfileManager, projectDir );
|
||||
|
||||
Set artifactRepositories = null;
|
||||
|
||||
|
@ -293,36 +289,57 @@ public class DefaultModelLineageBuilder
|
|||
/**
|
||||
* Pull the parent specification out of the given model, construct an Artifact instance, and
|
||||
* resolve that artifact...then, return the resolved POM file for the parent.
|
||||
* @param projectBuildCache
|
||||
* @param projectBuildCache
|
||||
*/
|
||||
private File resolveParentPom( Model model, List remoteRepositories, ArtifactRepository localRepository,
|
||||
File modelPomFile, ProjectBuildCache projectBuildCache )
|
||||
private ModelAndFile resolveParentPom( ModelAndFile child, List remoteRepositories, ArtifactRepository localRepository,
|
||||
ProjectBuildCache projectBuildCache )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
Model model = child.model;
|
||||
File modelPomFile = child.file;
|
||||
|
||||
Parent modelParent = model.getParent();
|
||||
|
||||
File pomFile = null;
|
||||
ModelAndFile result = null;
|
||||
|
||||
if ( modelParent != null )
|
||||
{
|
||||
validateParentDeclaration( modelParent, model );
|
||||
|
||||
// getLogger().debug( "Looking for cached parent POM under: " + cacheKey );
|
||||
|
||||
pomFile = (File) projectBuildCache.getCachedModelFile( modelParent );
|
||||
|
||||
if ( pomFile == null )
|
||||
File parentPomFile = projectBuildCache.getCachedModelFile( modelParent );
|
||||
|
||||
if ( parentPomFile == null )
|
||||
{
|
||||
pomFile = resolveParentWithRelativePath( modelParent, modelPomFile );
|
||||
parentPomFile = resolveParentWithRelativePath( modelParent, modelPomFile );
|
||||
}
|
||||
|
||||
if ( pomFile == null )
|
||||
if ( parentPomFile == null )
|
||||
{
|
||||
pomFile = resolveParentFromRepositories( modelParent, localRepository, remoteRepositories, modelPomFile );
|
||||
parentPomFile = resolveParentFromRepositories( modelParent, localRepository, remoteRepositories, modelPomFile );
|
||||
}
|
||||
|
||||
Model parent;
|
||||
if ( parentPomFile == null )
|
||||
{
|
||||
getLogger().warn( "Cannot find parent POM: " + modelParent.getId() + " for child: " + model.getId() + ". Using stub model instead." );
|
||||
|
||||
parent = new Model();
|
||||
|
||||
parent.setGroupId( modelParent.getGroupId() );
|
||||
parent.setArtifactId( modelParent.getArtifactId() );
|
||||
parent.setVersion( modelParent.getVersion() );
|
||||
}
|
||||
else
|
||||
{
|
||||
parent = readModel( parentPomFile );
|
||||
}
|
||||
|
||||
result = new ModelAndFile( parent, parentPomFile );
|
||||
}
|
||||
|
||||
return pomFile;
|
||||
return result;
|
||||
}
|
||||
|
||||
private void validateParentDeclaration( Parent modelParent, Model model )
|
||||
|
@ -404,9 +421,9 @@ public class DefaultModelLineageBuilder
|
|||
{
|
||||
Model parentModel = readModel( parentPomFile );
|
||||
|
||||
boolean groupsMatch = parentModel.getGroupId() == null
|
||||
boolean groupsMatch = ( parentModel.getGroupId() == null )
|
||||
|| parentModel.getGroupId().equals( modelParent.getGroupId() );
|
||||
boolean versionsMatch = parentModel.getVersion() == null
|
||||
boolean versionsMatch = ( parentModel.getVersion() == null )
|
||||
|| parentModel.getVersion().equals( modelParent.getVersion() );
|
||||
|
||||
if ( groupsMatch && versionsMatch && parentModel.getArtifactId().equals( modelParent.getArtifactId() ) )
|
||||
|
@ -433,4 +450,16 @@ public class DefaultModelLineageBuilder
|
|||
this.logger = logger;
|
||||
}
|
||||
|
||||
private static final class ModelAndFile
|
||||
{
|
||||
private final Model model;
|
||||
private final File file;
|
||||
|
||||
ModelAndFile( Model model, File file )
|
||||
{
|
||||
this.model = model;
|
||||
this.file = file;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue