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
|
@ -224,7 +224,7 @@ public class DefaultMavenProjectBuilder
|
||||||
{
|
{
|
||||||
ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
|
ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
|
||||||
|
|
||||||
MavenProject project = (MavenProject) projectBuildCache.getCachedProject( artifact );
|
MavenProject project = projectBuildCache.getCachedProject( artifact );
|
||||||
|
|
||||||
if ( project != null )
|
if ( project != null )
|
||||||
{
|
{
|
||||||
|
@ -280,12 +280,12 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
LinkedHashSet profiles = new LinkedHashSet();
|
LinkedHashSet profiles = new LinkedHashSet();
|
||||||
|
|
||||||
if ( activeProfiles != null && !activeProfiles.isEmpty() )
|
if ( ( activeProfiles != null ) && !activeProfiles.isEmpty() )
|
||||||
{
|
{
|
||||||
profiles.addAll( activeProfiles );
|
profiles.addAll( activeProfiles );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( activeExternalProfiles != null && !activeExternalProfiles.isEmpty() )
|
if ( ( activeExternalProfiles != null ) && !activeExternalProfiles.isEmpty() )
|
||||||
{
|
{
|
||||||
profiles.addAll( activeExternalProfiles );
|
profiles.addAll( activeExternalProfiles );
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ public class DefaultMavenProjectBuilder
|
||||||
{
|
{
|
||||||
Map map = null;
|
Map map = null;
|
||||||
List deps;
|
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 );
|
map = new ManagedVersionMap( map );
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ public class DefaultMavenProjectBuilder
|
||||||
// If the dependencyManagement section listed exclusions,
|
// If the dependencyManagement section listed exclusions,
|
||||||
// add them to the managed artifacts here so that transitive
|
// add them to the managed artifacts here so that transitive
|
||||||
// dependencies will be excluded if necessary.
|
// dependencies will be excluded if necessary.
|
||||||
if ( null != d.getExclusions() && !d.getExclusions().isEmpty() )
|
if ( ( null != d.getExclusions() ) && !d.getExclusions().isEmpty() )
|
||||||
{
|
{
|
||||||
List exclusions = new ArrayList();
|
List exclusions = new ArrayList();
|
||||||
Iterator exclItr = d.getExclusions().iterator();
|
Iterator exclItr = d.getExclusions().iterator();
|
||||||
|
@ -492,7 +492,7 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
if ( checkDistributionManagementStatus )
|
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() );
|
String projectId = safeVersionlessKey( project.getGroupId(), project.getArtifactId() );
|
||||||
|
|
||||||
|
@ -593,7 +593,7 @@ public class DefaultMavenProjectBuilder
|
||||||
throws ArtifactNotFoundException
|
throws ArtifactNotFoundException
|
||||||
{
|
{
|
||||||
// TODO: configurable actions dependant on status
|
// 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)
|
// use default policy (enabled, daily update, warn on bad checksum)
|
||||||
ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy();
|
ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy();
|
||||||
|
@ -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( "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 );
|
modelInheritanceAssembler.assembleModelInheritance( current, previous, pathAdjustment );
|
||||||
|
|
||||||
|
getLogger().debug( "[buildInternal] Assembled model-inheritance for child=" + current.getId() );
|
||||||
|
|
||||||
previous = current;
|
previous = current;
|
||||||
previousProject = currentProject;
|
previousProject = currentProject;
|
||||||
}
|
}
|
||||||
|
@ -815,7 +819,7 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
if ( rawParent != null )
|
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...
|
// yeah, this null check might be a bit paranoid, but better safe than sorry...
|
||||||
if ( processedParent != null )
|
if ( processedParent != null )
|
||||||
|
@ -849,7 +853,7 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
collectInitialRepositoriesFromModel( collected, superModel, projectDir, explicitlyActive, explicitlyInactive );
|
collectInitialRepositoriesFromModel( collected, superModel, projectDir, explicitlyActive, explicitlyInactive );
|
||||||
|
|
||||||
if ( parentSearchRepositories != null && !parentSearchRepositories.isEmpty() )
|
if ( ( parentSearchRepositories != null ) && !parentSearchRepositories.isEmpty() )
|
||||||
{
|
{
|
||||||
collected.addAll( parentSearchRepositories );
|
collected.addAll( parentSearchRepositories );
|
||||||
}
|
}
|
||||||
|
@ -865,13 +869,13 @@ public class DefaultMavenProjectBuilder
|
||||||
explicitlyActive,
|
explicitlyActive,
|
||||||
explicitlyInactive );
|
explicitlyInactive );
|
||||||
|
|
||||||
if ( reposFromProfiles != null && !reposFromProfiles.isEmpty() )
|
if ( ( reposFromProfiles != null ) && !reposFromProfiles.isEmpty() )
|
||||||
{
|
{
|
||||||
collected.addAll( reposFromProfiles );
|
collected.addAll( reposFromProfiles );
|
||||||
}
|
}
|
||||||
|
|
||||||
List modelRepos = model.getRepositories();
|
List modelRepos = model.getRepositories();
|
||||||
if ( modelRepos != null && !modelRepos.isEmpty() )
|
if ( ( modelRepos != null ) && !modelRepos.isEmpty() )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1075,6 +1079,9 @@ public class DefaultMavenProjectBuilder
|
||||||
for ( ModelLineageIterator it = modelLineage.lineageIterator(); it.hasNext(); )
|
for ( ModelLineageIterator it = modelLineage.lineageIterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
Model currentModel = (Model) it.next();
|
Model currentModel = (Model) it.next();
|
||||||
|
|
||||||
|
getLogger().debug( "[assembleLineage] Assembling MavenProject instance for: " + currentModel.getId() );
|
||||||
|
|
||||||
File currentPom = it.getPOMFile();
|
File currentPom = it.getPOMFile();
|
||||||
|
|
||||||
MavenProject project = new MavenProject( currentModel );
|
MavenProject project = new MavenProject( currentModel );
|
||||||
|
@ -1106,7 +1113,7 @@ public class DefaultMavenProjectBuilder
|
||||||
LinkedHashSet active = new LinkedHashSet();
|
LinkedHashSet active = new LinkedHashSet();
|
||||||
|
|
||||||
List existingActiveProfiles = result.getActiveProfiles();
|
List existingActiveProfiles = result.getActiveProfiles();
|
||||||
if ( existingActiveProfiles != null && !existingActiveProfiles.isEmpty() )
|
if ( ( existingActiveProfiles != null ) && !existingActiveProfiles.isEmpty() )
|
||||||
{
|
{
|
||||||
active.addAll( existingActiveProfiles );
|
active.addAll( existingActiveProfiles );
|
||||||
}
|
}
|
||||||
|
@ -1343,6 +1350,6 @@ public class DefaultMavenProjectBuilder
|
||||||
public void contextualize( Context context )
|
public void contextualize( Context context )
|
||||||
throws ContextException
|
throws ContextException
|
||||||
{
|
{
|
||||||
this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class DefaultModelLineageBuilder
|
||||||
|
|
||||||
public DefaultModelLineageBuilder( ArtifactResolver resolver, ArtifactFactory artifactFactory, BuildContextManager buildContextManager )
|
public DefaultModelLineageBuilder( ArtifactResolver resolver, ArtifactFactory artifactFactory, BuildContextManager buildContextManager )
|
||||||
{
|
{
|
||||||
this.artifactResolver = resolver;
|
artifactResolver = resolver;
|
||||||
this.artifactFactory = artifactFactory;
|
this.artifactFactory = artifactFactory;
|
||||||
this.buildContextManager = buildContextManager;
|
this.buildContextManager = buildContextManager;
|
||||||
}
|
}
|
||||||
|
@ -94,27 +94,25 @@ public class DefaultModelLineageBuilder
|
||||||
|
|
||||||
ModelLineage lineage = new DefaultModelLineage();
|
ModelLineage lineage = new DefaultModelLineage();
|
||||||
|
|
||||||
File pomFile = pom;
|
|
||||||
List currentRemoteRepositories = remoteRepositories == null ? new ArrayList()
|
List currentRemoteRepositories = remoteRepositories == null ? new ArrayList()
|
||||||
: new ArrayList( remoteRepositories );
|
: new ArrayList( remoteRepositories );
|
||||||
|
|
||||||
while ( pomFile != null )
|
ModelAndFile current = new ModelAndFile( readModel( pom, projectBuildCache ), pom );
|
||||||
{
|
|
||||||
Model model = readModel( pomFile, projectBuildCache );
|
|
||||||
|
|
||||||
|
while ( current != null )
|
||||||
|
{
|
||||||
if ( lineage.size() == 0 )
|
if ( lineage.size() == 0 )
|
||||||
{
|
{
|
||||||
lineage.setOrigin( model, pomFile, currentRemoteRepositories );
|
lineage.setOrigin( current.model, current.file, currentRemoteRepositories );
|
||||||
}
|
}
|
||||||
else
|
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,
|
current = resolveParentPom( current, currentRemoteRepositories, localRepository, projectBuildCache );
|
||||||
projectBuildCache );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return lineage;
|
return lineage;
|
||||||
|
@ -126,7 +124,6 @@ public class DefaultModelLineageBuilder
|
||||||
{
|
{
|
||||||
ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
|
ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
|
||||||
|
|
||||||
File pomFile = lineage.getDeepestFile();
|
|
||||||
List currentRemoteRepositories = lineage.getDeepestArtifactRepositoryList();
|
List currentRemoteRepositories = lineage.getDeepestArtifactRepositoryList();
|
||||||
|
|
||||||
if ( currentRemoteRepositories == null )
|
if ( currentRemoteRepositories == null )
|
||||||
|
@ -134,28 +131,25 @@ public class DefaultModelLineageBuilder
|
||||||
currentRemoteRepositories = new ArrayList();
|
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...
|
// 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 )
|
if ( lineage.size() == 0 )
|
||||||
{
|
{
|
||||||
lineage.setOrigin( model, pomFile, currentRemoteRepositories );
|
lineage.setOrigin( current.model, current.file, currentRemoteRepositories );
|
||||||
}
|
}
|
||||||
else
|
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,
|
current = resolveParentPom( current, currentRemoteRepositories, localRepository, projectBuildCache );
|
||||||
projectBuildCache );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +230,9 @@ public class DefaultModelLineageBuilder
|
||||||
{
|
{
|
||||||
List repositories = model.getRepositories();
|
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;
|
Set artifactRepositories = null;
|
||||||
|
|
||||||
|
@ -295,13 +291,16 @@ public class DefaultModelLineageBuilder
|
||||||
* resolve that artifact...then, return the resolved POM file for the parent.
|
* 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,
|
private ModelAndFile resolveParentPom( ModelAndFile child, List remoteRepositories, ArtifactRepository localRepository,
|
||||||
File modelPomFile, ProjectBuildCache projectBuildCache )
|
ProjectBuildCache projectBuildCache )
|
||||||
throws ProjectBuildingException
|
throws ProjectBuildingException
|
||||||
{
|
{
|
||||||
|
Model model = child.model;
|
||||||
|
File modelPomFile = child.file;
|
||||||
|
|
||||||
Parent modelParent = model.getParent();
|
Parent modelParent = model.getParent();
|
||||||
|
|
||||||
File pomFile = null;
|
ModelAndFile result = null;
|
||||||
|
|
||||||
if ( modelParent != null )
|
if ( modelParent != null )
|
||||||
{
|
{
|
||||||
|
@ -309,20 +308,38 @@ public class DefaultModelLineageBuilder
|
||||||
|
|
||||||
// getLogger().debug( "Looking for cached parent POM under: " + cacheKey );
|
// getLogger().debug( "Looking for cached parent POM under: " + cacheKey );
|
||||||
|
|
||||||
pomFile = (File) projectBuildCache.getCachedModelFile( modelParent );
|
File parentPomFile = projectBuildCache.getCachedModelFile( modelParent );
|
||||||
|
|
||||||
if ( pomFile == null )
|
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 )
|
private void validateParentDeclaration( Parent modelParent, Model model )
|
||||||
|
@ -404,9 +421,9 @@ public class DefaultModelLineageBuilder
|
||||||
{
|
{
|
||||||
Model parentModel = readModel( parentPomFile );
|
Model parentModel = readModel( parentPomFile );
|
||||||
|
|
||||||
boolean groupsMatch = parentModel.getGroupId() == null
|
boolean groupsMatch = ( parentModel.getGroupId() == null )
|
||||||
|| parentModel.getGroupId().equals( modelParent.getGroupId() );
|
|| parentModel.getGroupId().equals( modelParent.getGroupId() );
|
||||||
boolean versionsMatch = parentModel.getVersion() == null
|
boolean versionsMatch = ( parentModel.getVersion() == null )
|
||||||
|| parentModel.getVersion().equals( modelParent.getVersion() );
|
|| parentModel.getVersion().equals( modelParent.getVersion() );
|
||||||
|
|
||||||
if ( groupsMatch && versionsMatch && parentModel.getArtifactId().equals( modelParent.getArtifactId() ) )
|
if ( groupsMatch && versionsMatch && parentModel.getArtifactId().equals( modelParent.getArtifactId() ) )
|
||||||
|
@ -433,4 +450,16 @@ public class DefaultModelLineageBuilder
|
||||||
this.logger = logger;
|
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