if ( parentProject == null )
{
throw new ProjectModelException( "Cannot merge with a null parent project." );
}
ArchivaProjectModel merged = new ArchivaProjectModel();
// Unmerged.
merged.setArtifactId( mainProject.getArtifactId() );
merged.setPackaging( StringUtils.defaultIfEmpty( mainProject.getPackaging(), "jar" ) );
merged.setRelocation( mainProject.getRelocation() );
// Merged
merged.setGroupId( merge( mainProject.getGroupId(), parentProject.getGroupId() ) );
merged.setVersion( merge( mainProject.getVersion(), parentProject.getVersion() ) );
merged.setName( merge( mainProject.getName(), parentProject.getName() ) );
merged.setUrl( merge( mainProject.getUrl(), parentProject.getUrl() ) );
merged.setDescription( merge( mainProject.getDescription(), parentProject.getDescription() ) );
merged.setOrigin( "merged" );
merged.setCiManagement( merge( mainProject.getCiManagement(), parentProject.getCiManagement() ) );
merged.setIndividuals( mergeIndividuals( mainProject.getIndividuals(), parentProject.getIndividuals() ) );
merged.setIssueManagement( merge( mainProject.getIssueManagement(), parentProject.getIssueManagement() ) );
merged.setLicenses( mergeLicenses( mainProject.getLicenses(), parentProject.getLicenses() ) );
merged.setOrganization( merge( mainProject.getOrganization(), parentProject.getOrganization() ) );
merged.setScm( merge( mainProject.getScm(), parentProject.getScm() ) );
merged.setRepositories( mergeRepositories( mainProject.getRepositories(), parentProject.getRepositories() ) );
merged.setDependencies( mergeDependencies( mainProject.getDependencies(), parentProject.getDependencies() ) );
merged.setDependencyManagement( mergeDependencyManagement( mainProject.getDependencyManagement(), parentProject
.getDependencyManagement() ) );
merged.setPlugins( mergePlugins( mainProject.getPlugins(), parentProject.getPlugins() ) );
merged.setReports( mergeReports( mainProject.getReports(), parentProject.getReports() ) );
merged.setProperties( merge( mainProject.getProperties(), parentProject.getProperties() ) );
return merged;
}