private void populateSharedModel( RepositorySession repositorySession, MetadataResolver metadataResolver,
Collection<String> selectedRepos, Collection<String> projectVersions )
{
sharedModel = new ProjectVersionMetadata();
MavenProjectFacet mavenFacet = new MavenProjectFacet();
mavenFacet.setGroupId( groupId );
mavenFacet.setArtifactId( artifactId );
sharedModel.addFacet( mavenFacet );
boolean isFirstVersion = true;
for ( String version : projectVersions )
{
ProjectVersionMetadata versionMetadata = null;
for ( String repoId : selectedRepos )
{
if ( versionMetadata == null )
{
try
{
versionMetadata =
metadataResolver.resolveProjectVersion( repositorySession, repoId, groupId, artifactId,
version );
}
catch ( MetadataResolutionException e )
{
log.error(
"Skipping invalid metadata while compiling shared model for " + groupId + ":" + artifactId
+ " in repo " + repoId + ": " + e.getMessage() );
}
}
}
if ( versionMetadata == null )
{
continue;
}
if ( isFirstVersion )
{
sharedModel = versionMetadata;
sharedModel.setId( null );
}
else
{
MavenProjectFacet versionMetadataMavenFacet =
(MavenProjectFacet) versionMetadata.getFacet( MavenProjectFacet.FACET_ID );
if ( versionMetadataMavenFacet != null )
{
if ( mavenFacet.getPackaging() != null && !StringUtils.equalsIgnoreCase( mavenFacet.getPackaging(),
versionMetadataMavenFacet.getPackaging() ) )
{
mavenFacet.setPackaging( null );
}
}