mirror of https://github.com/apache/maven.git
Resolving: MNG-773
o Separated profile injection logic from the inheritance assembly. While they look similar superficially, the merge-out vs. merge-in semantics make it pretty complex to put this logic together in the same methods. It's easier to understand what's going on if they remain similar but separate code... o Added it0058 to test that application of a profile from settings.xml doesn't transport module lists from POM to POM inside of a reactor build. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@239918 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
22748d4e0d
commit
f437fb5dc2
|
@ -161,6 +161,9 @@ it0056: Test that multiple executions of the compile goal with different
|
||||||
|
|
||||||
it0057: Verify that scope == 'provided' dependencies are available to tests.
|
it0057: Verify that scope == 'provided' dependencies are available to tests.
|
||||||
|
|
||||||
|
it0058: Verify that profiles from settings.xml do not pollute module lists
|
||||||
|
across projects in a reactorized build.
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
- generated sources
|
- generated sources
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
it0058
|
||||||
it0057
|
it0057
|
||||||
it0056
|
it0056
|
||||||
it0055
|
it0055
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
--settings ./settings.xml
|
|
@ -0,0 +1 @@
|
||||||
|
subproject/target/maven-core-it0058-subproject-1.0.jar
|
|
@ -0,0 +1 @@
|
||||||
|
package
|
|
@ -0,0 +1,11 @@
|
||||||
|
<model>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.apache.maven.it</groupId>
|
||||||
|
<artifactId>maven-core-it0058</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0</version>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>subproject</module>
|
||||||
|
</modules>
|
||||||
|
</model>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<settings>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>test-repo</id>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>test-repo</id>
|
||||||
|
<url>file:../../test-repo</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<activeProfiles>
|
||||||
|
<activeProfile>test-repo</activeProfile>
|
||||||
|
</activeProfiles>
|
||||||
|
|
||||||
|
</settings>
|
|
@ -0,0 +1,18 @@
|
||||||
|
<model>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.maven.it</groupId>
|
||||||
|
<artifactId>maven-core-it0058</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>maven-core-it0058-subproject</artifactId>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</model>
|
|
@ -0,0 +1,16 @@
|
||||||
|
package org.apache.maven.it0001;
|
||||||
|
|
||||||
|
public class Person
|
||||||
|
{
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public void setName( String name )
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
name = jason
|
|
@ -0,0 +1,16 @@
|
||||||
|
package org.apache.maven.it0001;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
public class PersonTest
|
||||||
|
extends TestCase
|
||||||
|
{
|
||||||
|
public void testPerson()
|
||||||
|
{
|
||||||
|
Person person = new Person();
|
||||||
|
|
||||||
|
person.setName( "foo" );
|
||||||
|
|
||||||
|
assertEquals( "foo", person.getName() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,30 +16,17 @@ package org.apache.maven.project;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.model.Build;
|
|
||||||
import org.apache.maven.model.BuildBase;
|
|
||||||
import org.apache.maven.model.Dependency;
|
|
||||||
import org.apache.maven.model.DependencyManagement;
|
|
||||||
import org.apache.maven.model.DistributionManagement;
|
|
||||||
import org.apache.maven.model.Goal;
|
import org.apache.maven.model.Goal;
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
import org.apache.maven.model.ModelBase;
|
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.model.PluginContainer;
|
import org.apache.maven.model.PluginContainer;
|
||||||
import org.apache.maven.model.PluginExecution;
|
import org.apache.maven.model.PluginExecution;
|
||||||
import org.apache.maven.model.PluginManagement;
|
|
||||||
import org.apache.maven.model.Profile;
|
|
||||||
import org.apache.maven.model.ReportPlugin;
|
|
||||||
import org.apache.maven.model.ReportSet;
|
|
||||||
import org.apache.maven.model.Reporting;
|
|
||||||
import org.apache.maven.model.Repository;
|
import org.apache.maven.model.Repository;
|
||||||
import org.apache.maven.project.inheritance.DefaultModelInheritanceAssembler;
|
import org.apache.maven.project.inheritance.DefaultModelInheritanceAssembler;
|
||||||
import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
|
import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -258,19 +245,35 @@ public final class ModelUtils
|
||||||
|
|
||||||
private static void mergePluginExecutionDefinitions( PluginExecution child, PluginExecution parent )
|
private static void mergePluginExecutionDefinitions( PluginExecution child, PluginExecution parent )
|
||||||
{
|
{
|
||||||
List parentGoals = parent.getGoals();
|
if ( child.getPhase() == null )
|
||||||
|
|
||||||
// if the supplemental goals are non-existent, then nothing related to goals changes.
|
|
||||||
if ( parentGoals != null && !parentGoals.isEmpty() )
|
|
||||||
{
|
{
|
||||||
List goals = new ArrayList( parentGoals );
|
child.setPhase( parent.getPhase() );
|
||||||
if ( child.getGoals() != null )
|
|
||||||
{
|
|
||||||
goals.addAll( child.getGoals() );
|
|
||||||
}
|
|
||||||
|
|
||||||
child.setGoals( goals );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List parentGoals = parent.getGoals();
|
||||||
|
List childGoals = child.getGoals();
|
||||||
|
|
||||||
|
List goals = new ArrayList();
|
||||||
|
|
||||||
|
if ( childGoals != null && !childGoals.isEmpty() )
|
||||||
|
{
|
||||||
|
goals.addAll( childGoals );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( parentGoals != null )
|
||||||
|
{
|
||||||
|
for ( Iterator goalIterator = parentGoals.iterator(); goalIterator.hasNext(); )
|
||||||
|
{
|
||||||
|
String goal = (String) goalIterator.next();
|
||||||
|
|
||||||
|
if ( !goals.contains( goal ) )
|
||||||
|
{
|
||||||
|
goals.add( goal );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
child.setGoals( goals );
|
||||||
|
|
||||||
Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
|
Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
|
||||||
Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
|
Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
|
||||||
|
@ -280,391 +283,6 @@ public final class ModelUtils
|
||||||
child.setConfiguration( childConfiguration );
|
child.setConfiguration( childConfiguration );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void mergeModelBases( ModelBase dominant, ModelBase recessive, boolean mergePathStructures )
|
|
||||||
{
|
|
||||||
mergeDependencies( dominant, recessive );
|
|
||||||
|
|
||||||
if ( mergePathStructures )
|
|
||||||
{
|
|
||||||
mergeModules( dominant, recessive );
|
|
||||||
}
|
|
||||||
|
|
||||||
dominant.setRepositories( mergeRepositoryLists( dominant.getRepositories(), recessive.getRepositories() ) );
|
|
||||||
dominant.setPluginRepositories( mergeRepositoryLists( dominant.getPluginRepositories(), recessive.getPluginRepositories() ) );
|
|
||||||
|
|
||||||
mergeReporting( dominant, recessive );
|
|
||||||
|
|
||||||
mergeDependencyManagementSections( dominant, recessive );
|
|
||||||
|
|
||||||
mergeDistributionManagementSections( dominant, recessive );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void mergeModules( ModelBase dominant, ModelBase recessive )
|
|
||||||
{
|
|
||||||
List modules = new ArrayList();
|
|
||||||
|
|
||||||
List dominantModules = dominant.getModules();
|
|
||||||
|
|
||||||
if ( dominantModules != null && !dominantModules.isEmpty() )
|
|
||||||
{
|
|
||||||
modules.addAll( dominantModules );
|
|
||||||
}
|
|
||||||
|
|
||||||
List recessiveModules = recessive.getModules();
|
|
||||||
|
|
||||||
if ( recessiveModules != null )
|
|
||||||
{
|
|
||||||
for ( Iterator it = recessiveModules.iterator(); it.hasNext(); )
|
|
||||||
{
|
|
||||||
String module = (String) it.next();
|
|
||||||
|
|
||||||
if ( !modules.contains( module ) )
|
|
||||||
{
|
|
||||||
modules.add( module );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dominant.setModules( modules );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void mergeDistributionManagementSections( ModelBase dominant, ModelBase recessive )
|
|
||||||
{
|
|
||||||
DistributionManagement dDistMgmt = dominant.getDistributionManagement();
|
|
||||||
DistributionManagement rDistMgmt = recessive.getDistributionManagement();
|
|
||||||
|
|
||||||
if ( dDistMgmt == null )
|
|
||||||
{
|
|
||||||
dominant.setDistributionManagement( rDistMgmt );
|
|
||||||
}
|
|
||||||
else if ( rDistMgmt != null )
|
|
||||||
{
|
|
||||||
if ( dDistMgmt.getRepository() == null )
|
|
||||||
{
|
|
||||||
dDistMgmt.setRepository( rDistMgmt.getRepository() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( dDistMgmt.getSnapshotRepository() == null )
|
|
||||||
{
|
|
||||||
dDistMgmt.setSnapshotRepository( rDistMgmt.getSnapshotRepository() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( StringUtils.isEmpty( dDistMgmt.getDownloadUrl() ) )
|
|
||||||
{
|
|
||||||
dDistMgmt.setDownloadUrl( rDistMgmt.getDownloadUrl() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( dDistMgmt.getRelocation() == null )
|
|
||||||
{
|
|
||||||
dDistMgmt.setRelocation( rDistMgmt.getRelocation() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( dDistMgmt.getSite() == null )
|
|
||||||
{
|
|
||||||
dDistMgmt.setSite( rDistMgmt.getSite() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: We SHOULD NOT be inheriting status, since this is an assessment of the POM quality.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List mergeRepositoryLists( List dominantRepositories, List recessiveRepositories )
|
|
||||||
{
|
|
||||||
List repositories = new ArrayList();
|
|
||||||
|
|
||||||
for ( Iterator it = dominantRepositories.iterator(); it.hasNext(); )
|
|
||||||
{
|
|
||||||
Repository repository = (Repository) it.next();
|
|
||||||
|
|
||||||
repositories.add( repository );
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( Iterator it = recessiveRepositories.iterator(); it.hasNext(); )
|
|
||||||
{
|
|
||||||
Repository repository = (Repository) it.next();
|
|
||||||
|
|
||||||
if ( !repositories.contains( repository ) )
|
|
||||||
{
|
|
||||||
repositories.add( repository );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return repositories;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void mergeDependencies( ModelBase dominant, ModelBase recessive )
|
|
||||||
{
|
|
||||||
Map depsMap = new HashMap();
|
|
||||||
|
|
||||||
List deps = recessive.getDependencies();
|
|
||||||
|
|
||||||
if ( deps != null )
|
|
||||||
{
|
|
||||||
for ( Iterator it = deps.iterator(); it.hasNext(); )
|
|
||||||
{
|
|
||||||
Dependency dependency = (Dependency) it.next();
|
|
||||||
depsMap.put( dependency.getManagementKey(), dependency );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
deps = dominant.getDependencies();
|
|
||||||
|
|
||||||
if ( deps != null )
|
|
||||||
{
|
|
||||||
for ( Iterator it = deps.iterator(); it.hasNext(); )
|
|
||||||
{
|
|
||||||
Dependency dependency = (Dependency) it.next();
|
|
||||||
depsMap.put( dependency.getManagementKey(), dependency );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dominant.setDependencies( new ArrayList( depsMap.values() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void mergeReporting( ModelBase dominant, ModelBase recessive )
|
|
||||||
{
|
|
||||||
// Reports :: aggregate
|
|
||||||
Reporting dominantReporting = dominant.getReporting();
|
|
||||||
Reporting modelReporting = recessive.getReporting();
|
|
||||||
|
|
||||||
if ( dominantReporting != null && modelReporting != null )
|
|
||||||
{
|
|
||||||
if ( StringUtils.isEmpty( dominantReporting.getOutputDirectory() ) )
|
|
||||||
{
|
|
||||||
dominantReporting.setOutputDirectory( modelReporting.getOutputDirectory() );
|
|
||||||
}
|
|
||||||
|
|
||||||
Map mergedReportPlugins = new HashMap();
|
|
||||||
|
|
||||||
Map dominantReportersByKey = dominantReporting.getReportPluginsAsMap();
|
|
||||||
|
|
||||||
List parentReportPlugins = modelReporting.getPlugins();
|
|
||||||
|
|
||||||
if ( parentReportPlugins != null )
|
|
||||||
{
|
|
||||||
for ( Iterator it = parentReportPlugins.iterator(); it.hasNext(); )
|
|
||||||
{
|
|
||||||
ReportPlugin recessiveReportPlugin = (ReportPlugin) it.next();
|
|
||||||
|
|
||||||
String inherited = recessiveReportPlugin.getInherited();
|
|
||||||
|
|
||||||
if ( StringUtils.isEmpty( inherited ) || Boolean.valueOf( inherited ).booleanValue() )
|
|
||||||
{
|
|
||||||
ReportPlugin dominantReportPlugin = (ReportPlugin) dominantReportersByKey.get(
|
|
||||||
recessiveReportPlugin.getKey() );
|
|
||||||
|
|
||||||
ReportPlugin mergedReportPlugin = recessiveReportPlugin;
|
|
||||||
|
|
||||||
if ( dominantReportPlugin != null )
|
|
||||||
{
|
|
||||||
mergedReportPlugin = dominantReportPlugin;
|
|
||||||
|
|
||||||
mergeReportPlugins( dominantReportPlugin, recessiveReportPlugin );
|
|
||||||
}
|
|
||||||
else if ( StringUtils.isEmpty( inherited ) )
|
|
||||||
{
|
|
||||||
mergedReportPlugin.unsetInheritanceApplied();
|
|
||||||
}
|
|
||||||
|
|
||||||
mergedReportPlugins.put( mergedReportPlugin.getKey(), mergedReportPlugin );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( Iterator it = dominantReportersByKey.entrySet().iterator(); it.hasNext(); )
|
|
||||||
{
|
|
||||||
Map.Entry entry = (Map.Entry) it.next();
|
|
||||||
|
|
||||||
String key = (String) entry.getKey();
|
|
||||||
|
|
||||||
if ( !mergedReportPlugins.containsKey( key ) )
|
|
||||||
{
|
|
||||||
mergedReportPlugins.put( key, entry.getValue() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dominantReporting.setPlugins( new ArrayList( mergedReportPlugins.values() ) );
|
|
||||||
|
|
||||||
dominantReporting.flushReportPluginMap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void mergeDependencyManagementSections( ModelBase dominant, ModelBase recessive )
|
|
||||||
{
|
|
||||||
DependencyManagement recessiveDepMgmt = recessive.getDependencyManagement();
|
|
||||||
|
|
||||||
DependencyManagement dominantDepMgmt = dominant.getDependencyManagement();
|
|
||||||
|
|
||||||
if ( recessiveDepMgmt != null )
|
|
||||||
{
|
|
||||||
if ( dominantDepMgmt == null )
|
|
||||||
{
|
|
||||||
dominant.setDependencyManagement( recessiveDepMgmt );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
List dominantDeps = dominantDepMgmt.getDependencies();
|
|
||||||
|
|
||||||
Map mappedDominantDeps = new TreeMap();
|
|
||||||
for ( Iterator it = dominantDeps.iterator(); it.hasNext(); )
|
|
||||||
{
|
|
||||||
Dependency dep = (Dependency) it.next();
|
|
||||||
mappedDominantDeps.put( dep.getManagementKey(), dep );
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( Iterator it = recessiveDepMgmt.getDependencies().iterator(); it.hasNext(); )
|
|
||||||
{
|
|
||||||
Dependency dep = (Dependency) it.next();
|
|
||||||
if ( !mappedDominantDeps.containsKey( dep.getManagementKey() ) )
|
|
||||||
{
|
|
||||||
dominantDepMgmt.addDependency( dep );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void mergeReportPlugins( ReportPlugin dominant, ReportPlugin recessive )
|
|
||||||
{
|
|
||||||
if ( StringUtils.isEmpty( dominant.getVersion() ) )
|
|
||||||
{
|
|
||||||
dominant.setVersion( recessive.getVersion() );
|
|
||||||
}
|
|
||||||
|
|
||||||
Xpp3Dom dominantConfig = (Xpp3Dom) dominant.getConfiguration();
|
|
||||||
Xpp3Dom recessiveConfig = (Xpp3Dom) recessive.getConfiguration();
|
|
||||||
|
|
||||||
dominant.setConfiguration( Xpp3Dom.mergeXpp3Dom( dominantConfig, recessiveConfig ) );
|
|
||||||
|
|
||||||
Map mergedReportSets = new HashMap();
|
|
||||||
|
|
||||||
Map dominantReportSetsById = dominant.getReportSetsAsMap();
|
|
||||||
|
|
||||||
for ( Iterator it = recessive.getReportSets().iterator(); it.hasNext(); )
|
|
||||||
{
|
|
||||||
ReportSet recessiveReportSet = (ReportSet) it.next();
|
|
||||||
|
|
||||||
String inherited = recessiveReportSet.getInherited();
|
|
||||||
|
|
||||||
if ( StringUtils.isEmpty( inherited ) || Boolean.valueOf( inherited ).booleanValue() )
|
|
||||||
{
|
|
||||||
ReportSet dominantReportSet = (ReportSet) dominantReportSetsById.get( recessiveReportSet.getId() );
|
|
||||||
|
|
||||||
ReportSet merged = recessiveReportSet;
|
|
||||||
|
|
||||||
if ( dominantReportSet != null )
|
|
||||||
{
|
|
||||||
merged = dominantReportSet;
|
|
||||||
|
|
||||||
Xpp3Dom recessiveRSConfig = (Xpp3Dom) recessiveReportSet.getConfiguration();
|
|
||||||
Xpp3Dom mergedRSConfig = (Xpp3Dom) merged.getConfiguration();
|
|
||||||
|
|
||||||
merged.setConfiguration( Xpp3Dom.mergeXpp3Dom( mergedRSConfig, recessiveRSConfig ) );
|
|
||||||
|
|
||||||
List mergedReports = merged.getReports();
|
|
||||||
|
|
||||||
if ( mergedReports == null )
|
|
||||||
{
|
|
||||||
mergedReports = new ArrayList();
|
|
||||||
|
|
||||||
merged.setReports( mergedReports );
|
|
||||||
}
|
|
||||||
|
|
||||||
List recessiveRSReports = recessiveReportSet.getReports();
|
|
||||||
|
|
||||||
if ( recessiveRSReports != null )
|
|
||||||
{
|
|
||||||
for ( Iterator reportIterator = recessiveRSReports.iterator(); reportIterator.hasNext(); )
|
|
||||||
{
|
|
||||||
String report = (String) reportIterator.next();
|
|
||||||
|
|
||||||
if ( !mergedReports.contains( report ) )
|
|
||||||
{
|
|
||||||
mergedReports.add( report );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( StringUtils.isEmpty( inherited ) )
|
|
||||||
{
|
|
||||||
merged.unsetInheritanceApplied();
|
|
||||||
}
|
|
||||||
|
|
||||||
mergedReportSets.put( merged.getId(), merged );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( Iterator rsIterator = dominantReportSetsById.entrySet().iterator(); rsIterator.hasNext(); )
|
|
||||||
{
|
|
||||||
Map.Entry entry = (Map.Entry) rsIterator.next();
|
|
||||||
|
|
||||||
String key = (String) entry.getKey();
|
|
||||||
|
|
||||||
if ( !mergedReportSets.containsKey( key ) )
|
|
||||||
{
|
|
||||||
mergedReportSets.put( key, entry.getValue() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dominant.setReportSets( new ArrayList( mergedReportSets.values() ) );
|
|
||||||
|
|
||||||
dominant.flushReportSetMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void mergeBuildBases( BuildBase dominant, BuildBase recessive )
|
|
||||||
{
|
|
||||||
// NOTE: This assumes that the dominant build is not null.
|
|
||||||
//If it is null, the action taken should have been external to this method.
|
|
||||||
|
|
||||||
// if the parent build is null, obviously we cannot inherit from it...
|
|
||||||
if ( recessive != null )
|
|
||||||
{
|
|
||||||
if ( dominant.getDirectory() == null )
|
|
||||||
{
|
|
||||||
dominant.setDirectory( recessive.getDirectory() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( dominant.getDefaultGoal() == null )
|
|
||||||
{
|
|
||||||
dominant.setDefaultGoal( recessive.getDefaultGoal() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( dominant.getFinalName() == null )
|
|
||||||
{
|
|
||||||
dominant.setFinalName( recessive.getFinalName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
List resources = dominant.getResources();
|
|
||||||
if ( resources == null || resources.isEmpty() )
|
|
||||||
{
|
|
||||||
dominant.setResources( recessive.getResources() );
|
|
||||||
}
|
|
||||||
|
|
||||||
resources = dominant.getTestResources();
|
|
||||||
if ( resources == null || resources.isEmpty() )
|
|
||||||
{
|
|
||||||
dominant.setTestResources( recessive.getTestResources() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Plugins are aggregated if Plugin.inherit != false
|
|
||||||
ModelUtils.mergePluginLists( dominant, recessive, true );
|
|
||||||
|
|
||||||
// Plugin management :: aggregate
|
|
||||||
PluginManagement dominantPM = dominant.getPluginManagement();
|
|
||||||
PluginManagement recessivePM = recessive.getPluginManagement();
|
|
||||||
|
|
||||||
if ( dominantPM == null && recessivePM != null )
|
|
||||||
{
|
|
||||||
dominant.setPluginManagement( recessivePM );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ModelUtils.mergePluginLists( dominant.getPluginManagement(), recessive.getPluginManagement(),
|
|
||||||
false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static Model cloneModel( Model model )
|
static Model cloneModel( Model model )
|
||||||
{
|
{
|
||||||
// TODO: would be nice for the modello:java code to generate this as a copy constructor
|
// TODO: would be nice for the modello:java code to generate this as a copy constructor
|
||||||
|
@ -676,27 +294,27 @@ public final class ModelUtils
|
||||||
return newModel;
|
return newModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void overrideModelBase( Model target, ModelBase overrides )
|
public static List mergeRepositoryLists( List dominant, List recessive )
|
||||||
{
|
{
|
||||||
target.setDependencies( overrides.getDependencies() );
|
List repositories = new ArrayList();
|
||||||
target.setDependencyManagement( overrides.getDependencyManagement() );
|
|
||||||
target.setDistributionManagement( overrides.getDistributionManagement() );
|
|
||||||
target.setModules( overrides.getModules() );
|
|
||||||
target.setPluginRepositories( overrides.getPluginRepositories() );
|
|
||||||
target.setReporting( overrides.getReporting() );
|
|
||||||
target.setRepositories( overrides.getRepositories() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void overrideBuildBase( Build target, BuildBase overrides )
|
|
||||||
{
|
|
||||||
target.setDefaultGoal( overrides.getDefaultGoal() );
|
|
||||||
target.setFinalName( overrides.getFinalName() );
|
|
||||||
target.setPluginManagement( overrides.getPluginManagement() );
|
|
||||||
|
|
||||||
target.setPlugins( overrides.getPlugins() );
|
for ( Iterator it = dominant.iterator(); it.hasNext(); )
|
||||||
target.flushPluginMap();
|
{
|
||||||
|
Repository repository = (Repository) it.next();
|
||||||
|
|
||||||
|
repositories.add( repository );
|
||||||
|
}
|
||||||
|
|
||||||
target.setResources( overrides.getResources() );
|
for ( Iterator it = recessive.iterator(); it.hasNext(); )
|
||||||
target.setTestResources( overrides.getTestResources() );
|
{
|
||||||
|
Repository repository = (Repository) it.next();
|
||||||
|
|
||||||
|
if ( !repositories.contains( repository ) )
|
||||||
|
{
|
||||||
|
repositories.add( repository );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return repositories;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,16 +17,28 @@ package org.apache.maven.project.inheritance;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.model.Build;
|
import org.apache.maven.model.Build;
|
||||||
|
import org.apache.maven.model.Dependency;
|
||||||
|
import org.apache.maven.model.DependencyManagement;
|
||||||
import org.apache.maven.model.DistributionManagement;
|
import org.apache.maven.model.DistributionManagement;
|
||||||
import org.apache.maven.model.Extension;
|
import org.apache.maven.model.Extension;
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
|
import org.apache.maven.model.PluginManagement;
|
||||||
|
import org.apache.maven.model.ReportPlugin;
|
||||||
|
import org.apache.maven.model.ReportSet;
|
||||||
|
import org.apache.maven.model.Reporting;
|
||||||
import org.apache.maven.model.Repository;
|
import org.apache.maven.model.Repository;
|
||||||
import org.apache.maven.model.Scm;
|
import org.apache.maven.model.Scm;
|
||||||
import org.apache.maven.model.Site;
|
import org.apache.maven.model.Site;
|
||||||
import org.apache.maven.project.ModelUtils;
|
import org.apache.maven.project.ModelUtils;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
||||||
|
@ -141,8 +153,276 @@ public class DefaultModelInheritanceAssembler
|
||||||
|
|
||||||
// Build
|
// Build
|
||||||
assembleBuildInheritance( child, parent.getBuild() );
|
assembleBuildInheritance( child, parent.getBuild() );
|
||||||
|
|
||||||
|
assembleDependencyInheritance( child, parent );
|
||||||
|
|
||||||
ModelUtils.mergeModelBases( child, parent, false );
|
child.setRepositories( ModelUtils.mergeRepositoryLists( child.getRepositories(), parent.getRepositories() ) );
|
||||||
|
child.setPluginRepositories( ModelUtils.mergeRepositoryLists( child.getPluginRepositories(), parent.getPluginRepositories() ) );
|
||||||
|
|
||||||
|
assembleReportingInheritance( child, parent );
|
||||||
|
|
||||||
|
assembleDependencyManagementInheritance( child, parent );
|
||||||
|
|
||||||
|
assembleDistributionManagementInheritance( child, parent );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assembleDistributionManagementInheritance( Model child, Model parent )
|
||||||
|
{
|
||||||
|
DistributionManagement cDistMgmt = child.getDistributionManagement();
|
||||||
|
DistributionManagement pDistMgmt = parent.getDistributionManagement();
|
||||||
|
|
||||||
|
if ( cDistMgmt == null )
|
||||||
|
{
|
||||||
|
child.setDistributionManagement( pDistMgmt );
|
||||||
|
}
|
||||||
|
else if ( pDistMgmt != null )
|
||||||
|
{
|
||||||
|
if ( cDistMgmt.getRepository() == null )
|
||||||
|
{
|
||||||
|
cDistMgmt.setRepository( pDistMgmt.getRepository() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( cDistMgmt.getSnapshotRepository() == null )
|
||||||
|
{
|
||||||
|
cDistMgmt.setSnapshotRepository( pDistMgmt.getSnapshotRepository() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( StringUtils.isEmpty( cDistMgmt.getDownloadUrl() ) )
|
||||||
|
{
|
||||||
|
cDistMgmt.setDownloadUrl( pDistMgmt.getDownloadUrl() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( cDistMgmt.getRelocation() == null )
|
||||||
|
{
|
||||||
|
cDistMgmt.setRelocation( pDistMgmt.getRelocation() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( cDistMgmt.getSite() == null )
|
||||||
|
{
|
||||||
|
cDistMgmt.setSite( pDistMgmt.getSite() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: We SHOULD NOT be inheriting status, since this is an assessment of the POM quality.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assembleDependencyManagementInheritance( Model child, Model parent )
|
||||||
|
{
|
||||||
|
DependencyManagement parentDepMgmt = parent.getDependencyManagement();
|
||||||
|
|
||||||
|
DependencyManagement childDepMgmt = child.getDependencyManagement();
|
||||||
|
|
||||||
|
if ( parentDepMgmt != null )
|
||||||
|
{
|
||||||
|
if ( childDepMgmt == null )
|
||||||
|
{
|
||||||
|
child.setDependencyManagement( parentDepMgmt );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
List childDeps = childDepMgmt.getDependencies();
|
||||||
|
|
||||||
|
Map mappedChildDeps = new TreeMap();
|
||||||
|
for ( Iterator it = childDeps.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Dependency dep = (Dependency) it.next();
|
||||||
|
mappedChildDeps.put( dep.getManagementKey(), dep );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( Iterator it = parentDepMgmt.getDependencies().iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Dependency dep = (Dependency) it.next();
|
||||||
|
if ( !mappedChildDeps.containsKey( dep.getManagementKey() ) )
|
||||||
|
{
|
||||||
|
childDepMgmt.addDependency( dep );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assembleReportingInheritance( Model child, Model parent )
|
||||||
|
{
|
||||||
|
// Reports :: aggregate
|
||||||
|
Reporting childReporting = child.getReporting();
|
||||||
|
Reporting parentReporting = parent.getReporting();
|
||||||
|
|
||||||
|
if ( childReporting != null && parentReporting != null )
|
||||||
|
{
|
||||||
|
if ( StringUtils.isEmpty( childReporting.getOutputDirectory() ) )
|
||||||
|
{
|
||||||
|
childReporting.setOutputDirectory( parentReporting.getOutputDirectory() );
|
||||||
|
}
|
||||||
|
|
||||||
|
Map mergedReportPlugins = new HashMap();
|
||||||
|
|
||||||
|
Map childReportersByKey = childReporting.getReportPluginsAsMap();
|
||||||
|
|
||||||
|
List parentReportPlugins = parentReporting.getPlugins();
|
||||||
|
|
||||||
|
if ( parentReportPlugins != null )
|
||||||
|
{
|
||||||
|
for ( Iterator it = parentReportPlugins.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
ReportPlugin parentReportPlugin = (ReportPlugin) it.next();
|
||||||
|
|
||||||
|
String inherited = parentReportPlugin.getInherited();
|
||||||
|
|
||||||
|
if ( StringUtils.isEmpty( inherited ) || Boolean.valueOf( inherited ).booleanValue() )
|
||||||
|
{
|
||||||
|
ReportPlugin childReportPlugin = (ReportPlugin) childReportersByKey.get(
|
||||||
|
parentReportPlugin.getKey() );
|
||||||
|
|
||||||
|
ReportPlugin mergedReportPlugin = parentReportPlugin;
|
||||||
|
|
||||||
|
if ( childReportPlugin != null )
|
||||||
|
{
|
||||||
|
mergedReportPlugin = childReportPlugin;
|
||||||
|
|
||||||
|
mergeReportPlugins( childReportPlugin, parentReportPlugin );
|
||||||
|
}
|
||||||
|
else if ( StringUtils.isEmpty( inherited ) )
|
||||||
|
{
|
||||||
|
mergedReportPlugin.unsetInheritanceApplied();
|
||||||
|
}
|
||||||
|
|
||||||
|
mergedReportPlugins.put( mergedReportPlugin.getKey(), mergedReportPlugin );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( Iterator it = childReportersByKey.entrySet().iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Map.Entry entry = (Map.Entry) it.next();
|
||||||
|
|
||||||
|
String key = (String) entry.getKey();
|
||||||
|
|
||||||
|
if ( !mergedReportPlugins.containsKey( key ) )
|
||||||
|
{
|
||||||
|
mergedReportPlugins.put( key, entry.getValue() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
childReporting.setPlugins( new ArrayList( mergedReportPlugins.values() ) );
|
||||||
|
|
||||||
|
childReporting.flushReportPluginMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mergeReportPlugins( ReportPlugin childReportPlugin, ReportPlugin parentReportPlugin )
|
||||||
|
{
|
||||||
|
if ( StringUtils.isEmpty( childReportPlugin.getVersion() ) )
|
||||||
|
{
|
||||||
|
childReportPlugin.setVersion( parentReportPlugin.getVersion() );
|
||||||
|
}
|
||||||
|
|
||||||
|
Xpp3Dom childConfig = (Xpp3Dom) childReportPlugin.getConfiguration();
|
||||||
|
Xpp3Dom parentConfig = (Xpp3Dom) parentReportPlugin.getConfiguration();
|
||||||
|
|
||||||
|
childReportPlugin.setConfiguration( Xpp3Dom.mergeXpp3Dom( childConfig, parentConfig ) );
|
||||||
|
|
||||||
|
Map mergedReportSets = new HashMap();
|
||||||
|
|
||||||
|
Map childReportSetsById = childReportPlugin.getReportSetsAsMap();
|
||||||
|
|
||||||
|
for ( Iterator it = parentReportPlugin.getReportSets().iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
ReportSet parentReportSet = (ReportSet) it.next();
|
||||||
|
|
||||||
|
String inherited = parentReportSet.getInherited();
|
||||||
|
|
||||||
|
if ( StringUtils.isEmpty( inherited ) || Boolean.valueOf( inherited ).booleanValue() )
|
||||||
|
{
|
||||||
|
ReportSet childReportSet = (ReportSet) childReportSetsById.get( parentReportSet.getId() );
|
||||||
|
|
||||||
|
ReportSet merged = parentReportSet;
|
||||||
|
|
||||||
|
if ( childReportSet != null )
|
||||||
|
{
|
||||||
|
merged = childReportSet;
|
||||||
|
|
||||||
|
Xpp3Dom parentRSConfig = (Xpp3Dom) parentReportSet.getConfiguration();
|
||||||
|
Xpp3Dom mergedRSConfig = (Xpp3Dom) merged.getConfiguration();
|
||||||
|
|
||||||
|
merged.setConfiguration( Xpp3Dom.mergeXpp3Dom( mergedRSConfig, parentRSConfig ) );
|
||||||
|
|
||||||
|
List mergedReports = merged.getReports();
|
||||||
|
|
||||||
|
if ( mergedReports == null )
|
||||||
|
{
|
||||||
|
mergedReports = new ArrayList();
|
||||||
|
|
||||||
|
merged.setReports( mergedReports );
|
||||||
|
}
|
||||||
|
|
||||||
|
List parentRSReports = parentReportSet.getReports();
|
||||||
|
|
||||||
|
if ( parentRSReports != null )
|
||||||
|
{
|
||||||
|
for ( Iterator reportIterator = parentRSReports.iterator(); reportIterator.hasNext(); )
|
||||||
|
{
|
||||||
|
String report = (String) reportIterator.next();
|
||||||
|
|
||||||
|
if ( !mergedReports.contains( report ) )
|
||||||
|
{
|
||||||
|
mergedReports.add( report );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( StringUtils.isEmpty( inherited ) )
|
||||||
|
{
|
||||||
|
merged.unsetInheritanceApplied();
|
||||||
|
}
|
||||||
|
|
||||||
|
mergedReportSets.put( merged.getId(), merged );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( Iterator rsIterator = childReportSetsById.entrySet().iterator(); rsIterator.hasNext(); )
|
||||||
|
{
|
||||||
|
Map.Entry entry = (Map.Entry) rsIterator.next();
|
||||||
|
|
||||||
|
String key = (String) entry.getKey();
|
||||||
|
|
||||||
|
if ( !mergedReportSets.containsKey( key ) )
|
||||||
|
{
|
||||||
|
mergedReportSets.put( key, entry.getValue() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
childReportPlugin.setReportSets( new ArrayList( mergedReportSets.values() ) );
|
||||||
|
|
||||||
|
childReportPlugin.flushReportSetMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assembleDependencyInheritance( Model child, Model parent )
|
||||||
|
{
|
||||||
|
Map depsMap = new HashMap();
|
||||||
|
|
||||||
|
List deps = parent.getDependencies();
|
||||||
|
|
||||||
|
if ( deps != null )
|
||||||
|
{
|
||||||
|
for ( Iterator it = deps.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Dependency dependency = (Dependency) it.next();
|
||||||
|
depsMap.put( dependency.getManagementKey(), dependency );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deps = child.getDependencies();
|
||||||
|
|
||||||
|
if ( deps != null )
|
||||||
|
{
|
||||||
|
for ( Iterator it = deps.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Dependency dependency = (Dependency) it.next();
|
||||||
|
depsMap.put( dependency.getManagementKey(), dependency );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
child.setDependencies( new ArrayList( depsMap.values() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assembleBuildInheritance( Model child, Build parentBuild )
|
private void assembleBuildInheritance( Model child, Build parentBuild )
|
||||||
|
@ -188,7 +468,49 @@ public class DefaultModelInheritanceAssembler
|
||||||
// Extensions are accumlated
|
// Extensions are accumlated
|
||||||
mergeExtensionLists( childBuild, parentBuild );
|
mergeExtensionLists( childBuild, parentBuild );
|
||||||
|
|
||||||
ModelUtils.mergeBuildBases( childBuild, parentBuild );
|
if ( childBuild.getDirectory() == null )
|
||||||
|
{
|
||||||
|
childBuild.setDirectory( parentBuild.getDirectory() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( childBuild.getDefaultGoal() == null )
|
||||||
|
{
|
||||||
|
childBuild.setDefaultGoal( parentBuild.getDefaultGoal() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( childBuild.getFinalName() == null )
|
||||||
|
{
|
||||||
|
childBuild.setFinalName( parentBuild.getFinalName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
List resources = childBuild.getResources();
|
||||||
|
if ( resources == null || resources.isEmpty() )
|
||||||
|
{
|
||||||
|
childBuild.setResources( parentBuild.getResources() );
|
||||||
|
}
|
||||||
|
|
||||||
|
resources = childBuild.getTestResources();
|
||||||
|
if ( resources == null || resources.isEmpty() )
|
||||||
|
{
|
||||||
|
childBuild.setTestResources( parentBuild.getTestResources() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Plugins are aggregated if Plugin.inherit != false
|
||||||
|
ModelUtils.mergePluginLists( childBuild, parentBuild, true );
|
||||||
|
|
||||||
|
// Plugin management :: aggregate
|
||||||
|
PluginManagement dominantPM = childBuild.getPluginManagement();
|
||||||
|
PluginManagement recessivePM = parentBuild.getPluginManagement();
|
||||||
|
|
||||||
|
if ( dominantPM == null && recessivePM != null )
|
||||||
|
{
|
||||||
|
childBuild.setPluginManagement( recessivePM );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(),
|
||||||
|
false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +619,7 @@ public class DefaultModelInheritanceAssembler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String appendPath( String url, String path )
|
private String appendPath( String url, String path )
|
||||||
{
|
{
|
||||||
if ( url.endsWith( "/" ) )
|
if ( url.endsWith( "/" ) )
|
||||||
{
|
{
|
||||||
|
@ -309,7 +631,7 @@ public class DefaultModelInheritanceAssembler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void mergeExtensionLists( Build childBuild, Build parentBuild )
|
private void mergeExtensionLists( Build childBuild, Build parentBuild )
|
||||||
{
|
{
|
||||||
for ( Iterator i = parentBuild.getExtensions().iterator(); i.hasNext(); )
|
for ( Iterator i = parentBuild.getExtensions().iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,32 +2,575 @@ package org.apache.maven.project.injection;
|
||||||
|
|
||||||
import org.apache.maven.model.Build;
|
import org.apache.maven.model.Build;
|
||||||
import org.apache.maven.model.BuildBase;
|
import org.apache.maven.model.BuildBase;
|
||||||
|
import org.apache.maven.model.ConfigurationContainer;
|
||||||
|
import org.apache.maven.model.Dependency;
|
||||||
|
import org.apache.maven.model.DependencyManagement;
|
||||||
|
import org.apache.maven.model.DistributionManagement;
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
|
import org.apache.maven.model.Plugin;
|
||||||
|
import org.apache.maven.model.PluginContainer;
|
||||||
|
import org.apache.maven.model.PluginExecution;
|
||||||
|
import org.apache.maven.model.PluginManagement;
|
||||||
import org.apache.maven.model.Profile;
|
import org.apache.maven.model.Profile;
|
||||||
|
import org.apache.maven.model.ReportPlugin;
|
||||||
|
import org.apache.maven.model.ReportSet;
|
||||||
|
import org.apache.maven.model.Reporting;
|
||||||
import org.apache.maven.project.ModelUtils;
|
import org.apache.maven.project.ModelUtils;
|
||||||
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inject profile data into a Model, using the profile as the dominant data source, and
|
||||||
|
* persisting results of the injection in the Model.
|
||||||
|
*
|
||||||
|
* This will look similar to the ModelUtils/DefaultModelInheritanceAssembler code, but
|
||||||
|
* they are distinct. In model inheritance, the child provides data dominance AND persists
|
||||||
|
* the results of the merge...sort of a 'merge-out' system.
|
||||||
|
*
|
||||||
|
* In this system, the profile is dominant, but the model receives the merge result...sort
|
||||||
|
* of a 'merge-in' system. The two pieces of code look like they could be combined with a
|
||||||
|
* set of flags to determine which direction to merge 'to', but there are enough differences
|
||||||
|
* in the code to justify the extra code involved with separating them, in order to simplify
|
||||||
|
* the logic.
|
||||||
|
*/
|
||||||
public class DefaultProfileInjector
|
public class DefaultProfileInjector
|
||||||
implements ProfileInjector
|
implements ProfileInjector
|
||||||
{
|
{
|
||||||
|
|
||||||
public void inject( Profile profile, Model model )
|
public void inject( Profile profile, Model model )
|
||||||
{
|
{
|
||||||
// [jc 11-aug-2005] NOTE: the following merge-then-override procedure is used to preserve proper dominance
|
injectDependencies( profile, model );
|
||||||
// (profile wins), while ensuring that any changes are pushed to the model.
|
|
||||||
ModelUtils.mergeModelBases( profile, model, true );
|
injectModules( profile, model );
|
||||||
|
|
||||||
ModelUtils.overrideModelBase( model, profile );
|
model.setRepositories( ModelUtils.mergeRepositoryLists( profile.getRepositories(), model.getRepositories() ) );
|
||||||
|
model.setPluginRepositories( ModelUtils.mergeRepositoryLists( profile.getPluginRepositories(), model
|
||||||
|
.getPluginRepositories() ) );
|
||||||
|
|
||||||
|
injectReporting( profile, model );
|
||||||
|
|
||||||
|
injectDependencyManagement( profile, model );
|
||||||
|
|
||||||
|
injectDistributionManagement( profile, model );
|
||||||
|
|
||||||
|
injectBuild( profile, model );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void injectBuild( Profile profile, Model model )
|
||||||
|
{
|
||||||
BuildBase profileBuild = profile.getBuild();
|
BuildBase profileBuild = profile.getBuild();
|
||||||
|
Build modelBuild = model.getBuild();
|
||||||
|
|
||||||
|
// if the parent build is null, obviously we cannot inherit from it...
|
||||||
if ( profileBuild != null )
|
if ( profileBuild != null )
|
||||||
{
|
{
|
||||||
ModelUtils.mergeBuildBases( profile.getBuild(), model.getBuild() );
|
if ( modelBuild == null )
|
||||||
|
{
|
||||||
|
modelBuild = new Build();
|
||||||
|
model.setBuild( modelBuild );
|
||||||
|
}
|
||||||
|
|
||||||
Build modelBuild = model.getBuild();
|
if ( profileBuild.getDirectory() != null )
|
||||||
|
{
|
||||||
|
modelBuild.setDirectory( profileBuild.getDirectory() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( profileBuild.getDefaultGoal() != null )
|
||||||
|
{
|
||||||
|
modelBuild.setDefaultGoal( profileBuild.getDefaultGoal() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( profileBuild.getFinalName() != null )
|
||||||
|
{
|
||||||
|
modelBuild.setFinalName( profileBuild.getFinalName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
List profileResources = profileBuild.getResources();
|
||||||
|
|
||||||
ModelUtils.overrideBuildBase( modelBuild, profileBuild );
|
if ( profileResources != null )
|
||||||
|
{
|
||||||
|
modelBuild.setResources( profileResources );
|
||||||
|
}
|
||||||
|
|
||||||
|
List profileTestResources = profileBuild.getTestResources();
|
||||||
|
|
||||||
|
if ( profileTestResources != null )
|
||||||
|
{
|
||||||
|
modelBuild.setTestResources( profileTestResources );
|
||||||
|
}
|
||||||
|
|
||||||
|
injectPlugins( profileBuild, modelBuild );
|
||||||
|
|
||||||
|
// Plugin management :: aggregate
|
||||||
|
PluginManagement profilePM = profileBuild.getPluginManagement();
|
||||||
|
PluginManagement modelPM = modelBuild.getPluginManagement();
|
||||||
|
|
||||||
|
if ( modelPM == null )
|
||||||
|
{
|
||||||
|
modelBuild.setPluginManagement( profilePM );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
injectPlugins( profilePM, modelPM );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void injectPlugins( PluginContainer profileContainer, PluginContainer modelContainer )
|
||||||
|
{
|
||||||
|
List modelPlugins = modelContainer.getPlugins();
|
||||||
|
|
||||||
|
if ( modelPlugins == null )
|
||||||
|
{
|
||||||
|
modelContainer.setPlugins( profileContainer.getPlugins() );
|
||||||
|
}
|
||||||
|
else if ( profileContainer.getPlugins() != null )
|
||||||
|
{
|
||||||
|
Map mergedPlugins = new TreeMap();
|
||||||
|
|
||||||
|
Map profilePlugins = profileContainer.getPluginsAsMap();
|
||||||
|
|
||||||
|
for ( Iterator it = modelPlugins.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Plugin modelPlugin = (Plugin) it.next();
|
||||||
|
|
||||||
|
Plugin mergedPlugin = modelPlugin;
|
||||||
|
|
||||||
|
Plugin profilePlugin = (Plugin) profilePlugins.get( modelPlugin.getKey() );
|
||||||
|
|
||||||
|
if ( profilePlugin != null )
|
||||||
|
{
|
||||||
|
mergedPlugin = profilePlugin;
|
||||||
|
|
||||||
|
injectPluginDefinition( profilePlugin, modelPlugin );
|
||||||
|
}
|
||||||
|
|
||||||
|
mergedPlugins.put( mergedPlugin.getKey(), mergedPlugin );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( Iterator it = profilePlugins.values().iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Plugin profilePlugin = (Plugin) it.next();
|
||||||
|
|
||||||
|
if ( !mergedPlugins.containsKey( profilePlugin.getKey() ) )
|
||||||
|
{
|
||||||
|
mergedPlugins.put( profilePlugin.getKey(), profilePlugin );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
modelContainer.setPlugins( new ArrayList( mergedPlugins.values() ) );
|
||||||
|
|
||||||
|
modelContainer.flushPluginMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void injectPluginDefinition( Plugin profilePlugin, Plugin modelPlugin )
|
||||||
|
{
|
||||||
|
if ( profilePlugin == null || modelPlugin == null )
|
||||||
|
{
|
||||||
|
// nothing to do.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( profilePlugin.isExtensions() )
|
||||||
|
{
|
||||||
|
modelPlugin.setExtensions( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( profilePlugin.getVersion() != null )
|
||||||
|
{
|
||||||
|
modelPlugin.setVersion( profilePlugin.getVersion() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// merge the lists of goals that are not attached to an <execution/>
|
||||||
|
injectConfigurationContainer( profilePlugin, modelPlugin );
|
||||||
|
|
||||||
|
// from here to the end of the method is dealing with merging of the <executions/> section.
|
||||||
|
List modelExecutions = modelPlugin.getExecutions();
|
||||||
|
|
||||||
|
if ( modelExecutions == null || modelExecutions.isEmpty() )
|
||||||
|
{
|
||||||
|
modelPlugin.setExecutions( profilePlugin.getExecutions() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Map executions = new TreeMap();
|
||||||
|
|
||||||
|
Map profileExecutions = profilePlugin.getExecutionsAsMap();
|
||||||
|
|
||||||
|
for ( Iterator it = modelExecutions.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
PluginExecution modelExecution = (PluginExecution) it.next();
|
||||||
|
|
||||||
|
PluginExecution profileExecution = (PluginExecution) profileExecutions.get( modelExecution.getId() );
|
||||||
|
|
||||||
|
if ( profileExecution != null )
|
||||||
|
{
|
||||||
|
injectConfigurationContainer( profileExecution, modelExecution );
|
||||||
|
|
||||||
|
if ( profileExecution.getPhase() != null )
|
||||||
|
{
|
||||||
|
modelExecution.setPhase( profileExecution.getPhase() );
|
||||||
|
}
|
||||||
|
|
||||||
|
List profileGoals = profileExecution.getGoals();
|
||||||
|
List modelGoals = modelExecution.getGoals();
|
||||||
|
|
||||||
|
List goals = new ArrayList();
|
||||||
|
|
||||||
|
if ( modelGoals != null && !modelGoals.isEmpty() )
|
||||||
|
{
|
||||||
|
goals.addAll( modelGoals );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( profileGoals != null )
|
||||||
|
{
|
||||||
|
for ( Iterator goalIterator = profileGoals.iterator(); goalIterator.hasNext(); )
|
||||||
|
{
|
||||||
|
String goal = (String) goalIterator.next();
|
||||||
|
|
||||||
|
if ( !goals.contains( goal ) )
|
||||||
|
{
|
||||||
|
goals.add( goal );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
modelExecution.setGoals( goals );
|
||||||
|
}
|
||||||
|
|
||||||
|
executions.put( modelExecution.getId(), modelExecution );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( Iterator it = profileExecutions.entrySet().iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Map.Entry entry = (Map.Entry) it.next();
|
||||||
|
|
||||||
|
String id = (String) entry.getKey();
|
||||||
|
|
||||||
|
if ( !executions.containsKey( id ) )
|
||||||
|
{
|
||||||
|
executions.put( id, entry.getValue() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
modelPlugin.setExecutions( new ArrayList( executions.values() ) );
|
||||||
|
|
||||||
|
modelPlugin.flushExecutionMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void injectConfigurationContainer( ConfigurationContainer profileContainer,
|
||||||
|
ConfigurationContainer modelContainer )
|
||||||
|
{
|
||||||
|
Xpp3Dom configuration = (Xpp3Dom) profileContainer.getConfiguration();
|
||||||
|
Xpp3Dom parentConfiguration = (Xpp3Dom) modelContainer.getConfiguration();
|
||||||
|
|
||||||
|
configuration = Xpp3Dom.mergeXpp3Dom( configuration, parentConfiguration );
|
||||||
|
|
||||||
|
modelContainer.setConfiguration( configuration );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void injectModules( Profile profile, Model model )
|
||||||
|
{
|
||||||
|
List modules = new ArrayList();
|
||||||
|
|
||||||
|
List profileModules = profile.getModules();
|
||||||
|
|
||||||
|
if ( profileModules != null && !profileModules.isEmpty() )
|
||||||
|
{
|
||||||
|
modules.addAll( profileModules );
|
||||||
|
}
|
||||||
|
|
||||||
|
List modelModules = model.getModules();
|
||||||
|
|
||||||
|
if ( modelModules != null )
|
||||||
|
{
|
||||||
|
for ( Iterator it = modelModules.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
String module = (String) it.next();
|
||||||
|
|
||||||
|
if ( !modules.contains( module ) )
|
||||||
|
{
|
||||||
|
modules.add( module );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
model.setModules( modules );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void injectDistributionManagement( Profile profile, Model model )
|
||||||
|
{
|
||||||
|
DistributionManagement pDistMgmt = profile.getDistributionManagement();
|
||||||
|
DistributionManagement mDistMgmt = model.getDistributionManagement();
|
||||||
|
|
||||||
|
if ( mDistMgmt == null )
|
||||||
|
{
|
||||||
|
model.setDistributionManagement( pDistMgmt );
|
||||||
|
}
|
||||||
|
else if ( pDistMgmt != null )
|
||||||
|
{
|
||||||
|
if ( pDistMgmt.getRepository() != null )
|
||||||
|
{
|
||||||
|
mDistMgmt.setRepository( pDistMgmt.getRepository() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( pDistMgmt.getSnapshotRepository() != null )
|
||||||
|
{
|
||||||
|
mDistMgmt.setSnapshotRepository( pDistMgmt.getSnapshotRepository() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( StringUtils.isNotEmpty( pDistMgmt.getDownloadUrl() ) )
|
||||||
|
{
|
||||||
|
mDistMgmt.setDownloadUrl( pDistMgmt.getDownloadUrl() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( pDistMgmt.getRelocation() != null )
|
||||||
|
{
|
||||||
|
mDistMgmt.setRelocation( pDistMgmt.getRelocation() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( pDistMgmt.getSite() != null )
|
||||||
|
{
|
||||||
|
mDistMgmt.setSite( pDistMgmt.getSite() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: We SHOULD NOT be inheriting status, since this is an assessment of the POM quality.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void injectDependencyManagement( Profile profile, Model model )
|
||||||
|
{
|
||||||
|
DependencyManagement modelDepMgmt = model.getDependencyManagement();
|
||||||
|
|
||||||
|
DependencyManagement profileDepMgmt = profile.getDependencyManagement();
|
||||||
|
|
||||||
|
if ( profileDepMgmt != null )
|
||||||
|
{
|
||||||
|
if ( modelDepMgmt == null )
|
||||||
|
{
|
||||||
|
model.setDependencyManagement( profileDepMgmt );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Map depsMap = new HashMap();
|
||||||
|
|
||||||
|
List deps = modelDepMgmt.getDependencies();
|
||||||
|
|
||||||
|
if ( deps != null )
|
||||||
|
{
|
||||||
|
for ( Iterator it = deps.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Dependency dependency = (Dependency) it.next();
|
||||||
|
depsMap.put( dependency.getManagementKey(), dependency );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deps = profileDepMgmt.getDependencies();
|
||||||
|
|
||||||
|
if ( deps != null )
|
||||||
|
{
|
||||||
|
for ( Iterator it = deps.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Dependency dependency = (Dependency) it.next();
|
||||||
|
depsMap.put( dependency.getManagementKey(), dependency );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
modelDepMgmt.setDependencies( new ArrayList( depsMap.values() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void injectReporting( Profile profile, Model model )
|
||||||
|
{
|
||||||
|
// Reports :: aggregate
|
||||||
|
Reporting profileReporting = profile.getReporting();
|
||||||
|
Reporting modelReporting = model.getReporting();
|
||||||
|
|
||||||
|
if ( profileReporting != null )
|
||||||
|
{
|
||||||
|
if ( modelReporting == null )
|
||||||
|
{
|
||||||
|
model.setReporting( profileReporting );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( StringUtils.isEmpty( modelReporting.getOutputDirectory() ) )
|
||||||
|
{
|
||||||
|
modelReporting.setOutputDirectory( profileReporting.getOutputDirectory() );
|
||||||
|
}
|
||||||
|
|
||||||
|
Map mergedReportPlugins = new HashMap();
|
||||||
|
|
||||||
|
Map profileReportersByKey = profileReporting.getReportPluginsAsMap();
|
||||||
|
|
||||||
|
List modelReportPlugins = modelReporting.getPlugins();
|
||||||
|
|
||||||
|
if ( modelReportPlugins != null )
|
||||||
|
{
|
||||||
|
for ( Iterator it = modelReportPlugins.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
ReportPlugin modelReportPlugin = (ReportPlugin) it.next();
|
||||||
|
|
||||||
|
String inherited = modelReportPlugin.getInherited();
|
||||||
|
|
||||||
|
if ( StringUtils.isEmpty( inherited ) || Boolean.valueOf( inherited ).booleanValue() )
|
||||||
|
{
|
||||||
|
ReportPlugin profileReportPlugin = (ReportPlugin) profileReportersByKey
|
||||||
|
.get( modelReportPlugin.getKey() );
|
||||||
|
|
||||||
|
ReportPlugin mergedReportPlugin = modelReportPlugin;
|
||||||
|
|
||||||
|
if ( profileReportPlugin != null )
|
||||||
|
{
|
||||||
|
mergedReportPlugin = profileReportPlugin;
|
||||||
|
|
||||||
|
mergeReportPlugins( profileReportPlugin, modelReportPlugin );
|
||||||
|
}
|
||||||
|
else if ( StringUtils.isEmpty( inherited ) )
|
||||||
|
{
|
||||||
|
mergedReportPlugin.unsetInheritanceApplied();
|
||||||
|
}
|
||||||
|
|
||||||
|
mergedReportPlugins.put( mergedReportPlugin.getKey(), mergedReportPlugin );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( Iterator it = profileReportersByKey.entrySet().iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Map.Entry entry = (Map.Entry) it.next();
|
||||||
|
|
||||||
|
String key = (String) entry.getKey();
|
||||||
|
|
||||||
|
if ( !mergedReportPlugins.containsKey( key ) )
|
||||||
|
{
|
||||||
|
mergedReportPlugins.put( key, entry.getValue() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
profileReporting.setPlugins( new ArrayList( mergedReportPlugins.values() ) );
|
||||||
|
|
||||||
|
profileReporting.flushReportPluginMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mergeReportPlugins( ReportPlugin dominant, ReportPlugin recessive )
|
||||||
|
{
|
||||||
|
if ( StringUtils.isEmpty( recessive.getVersion() ) )
|
||||||
|
{
|
||||||
|
recessive.setVersion( dominant.getVersion() );
|
||||||
|
}
|
||||||
|
|
||||||
|
Xpp3Dom dominantConfig = (Xpp3Dom) dominant.getConfiguration();
|
||||||
|
Xpp3Dom recessiveConfig = (Xpp3Dom) recessive.getConfiguration();
|
||||||
|
|
||||||
|
recessive.setConfiguration( Xpp3Dom.mergeXpp3Dom( dominantConfig, recessiveConfig ) );
|
||||||
|
|
||||||
|
Map mergedReportSets = new HashMap();
|
||||||
|
|
||||||
|
Map dominantReportSetsById = dominant.getReportSetsAsMap();
|
||||||
|
|
||||||
|
for ( Iterator it = recessive.getReportSets().iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
ReportSet recessiveReportSet = (ReportSet) it.next();
|
||||||
|
|
||||||
|
ReportSet dominantReportSet = (ReportSet) dominantReportSetsById.get( recessiveReportSet.getId() );
|
||||||
|
|
||||||
|
ReportSet merged = recessiveReportSet;
|
||||||
|
|
||||||
|
if ( dominantReportSet != null )
|
||||||
|
{
|
||||||
|
merged = recessiveReportSet;
|
||||||
|
|
||||||
|
Xpp3Dom dominantRSConfig = (Xpp3Dom) dominantReportSet.getConfiguration();
|
||||||
|
Xpp3Dom mergedRSConfig = (Xpp3Dom) merged.getConfiguration();
|
||||||
|
|
||||||
|
merged.setConfiguration( Xpp3Dom.mergeXpp3Dom( dominantRSConfig, mergedRSConfig ) );
|
||||||
|
|
||||||
|
List mergedReports = merged.getReports();
|
||||||
|
|
||||||
|
if ( mergedReports == null )
|
||||||
|
{
|
||||||
|
mergedReports = new ArrayList();
|
||||||
|
|
||||||
|
merged.setReports( mergedReports );
|
||||||
|
}
|
||||||
|
|
||||||
|
List dominantRSReports = dominantReportSet.getReports();
|
||||||
|
|
||||||
|
if ( dominantRSReports != null )
|
||||||
|
{
|
||||||
|
for ( Iterator reportIterator = dominantRSReports.iterator(); reportIterator.hasNext(); )
|
||||||
|
{
|
||||||
|
String report = (String) reportIterator.next();
|
||||||
|
|
||||||
|
if ( !mergedReports.contains( report ) )
|
||||||
|
{
|
||||||
|
mergedReports.add( report );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mergedReportSets.put( merged.getId(), merged );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( Iterator rsIterator = dominantReportSetsById.entrySet().iterator(); rsIterator.hasNext(); )
|
||||||
|
{
|
||||||
|
Map.Entry entry = (Map.Entry) rsIterator.next();
|
||||||
|
|
||||||
|
String key = (String) entry.getKey();
|
||||||
|
|
||||||
|
if ( !mergedReportSets.containsKey( key ) )
|
||||||
|
{
|
||||||
|
mergedReportSets.put( key, entry.getValue() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
recessive.setReportSets( new ArrayList( mergedReportSets.values() ) );
|
||||||
|
|
||||||
|
recessive.flushReportSetMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void injectDependencies( Profile profile, Model model )
|
||||||
|
{
|
||||||
|
Map depsMap = new HashMap();
|
||||||
|
|
||||||
|
List deps = model.getDependencies();
|
||||||
|
|
||||||
|
if ( deps != null )
|
||||||
|
{
|
||||||
|
for ( Iterator it = deps.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Dependency dependency = (Dependency) it.next();
|
||||||
|
depsMap.put( dependency.getManagementKey(), dependency );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deps = profile.getDependencies();
|
||||||
|
|
||||||
|
if ( deps != null )
|
||||||
|
{
|
||||||
|
for ( Iterator it = deps.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Dependency dependency = (Dependency) it.next();
|
||||||
|
depsMap.put( dependency.getManagementKey(), dependency );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
model.setDependencies( new ArrayList( depsMap.values() ) );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue