Resolving: MNG-684

o Split profile injection out into its own component away from the defaults assembler
o Moved code common to the defaults assembler and the profile injector into ModelUtils
o Removed the profile-related method from ModelIntheritanceAssembler
o added it0048 to test that profile values will override POM values.



git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@231294 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-08-10 19:21:34 +00:00
parent 6db67ef76e
commit 013d4039fb
11 changed files with 461 additions and 312 deletions

View File

@ -0,0 +1 @@
target/replacedPluginItem.txt

View File

@ -0,0 +1 @@
core-it:touch

View File

@ -0,0 +1,53 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-it0023</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-core-it-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<pluginItem>pluginItem.txt</pluginItem>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>snapshots</id>
<name>Maven Central Plugins Development Repository</name>
<url>http://snapshots.maven.codehaus.org/maven2/plugins</url>
</pluginRepository>
</pluginRepositories>
<profiles>
<profile>
<id>test-profile</id>
<activation>
<property>
<!-- always active... -->
<name>java.version</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-core-it-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<pluginItem>replacedPluginItem.txt</pluginItem>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,16 @@
package org.apache.maven.it0023;
public class Person
{
private String name;
public void setName( String name )
{
this.name = name;
}
public String getName()
{
return name;
}
}

View File

@ -43,6 +43,7 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.profiles.activation.ProfileActivationCalculator;
import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
import org.apache.maven.project.injection.ModelDefaultsInjector;
import org.apache.maven.project.injection.ProfileInjector;
import org.apache.maven.project.interpolation.ModelInterpolationException;
import org.apache.maven.project.interpolation.ModelInterpolator;
import org.apache.maven.project.path.PathTranslator;
@ -97,6 +98,8 @@ public class DefaultMavenProjectBuilder
private ModelInheritanceAssembler modelInheritanceAssembler;
private ProfileInjector profileInjector;
private ModelValidator validator;
// TODO: make it a component
@ -481,7 +484,7 @@ public class DefaultMavenProjectBuilder
{
Profile profile = (Profile) it.next();
modelInheritanceAssembler.mergeProfileWithModel( model, profile );
profileInjector.inject( profile, model );
profileProperties.putAll( profile.getProperties() );
}

View File

@ -16,16 +16,27 @@ package org.apache.maven.project;
* limitations under the License.
*/
import org.apache.maven.model.BuildBase;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Goal;
import org.apache.maven.model.Model;
import org.apache.maven.model.ModelBase;
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.ReportPlugin;
import org.apache.maven.model.ReportSet;
import org.apache.maven.model.Reporting;
import org.apache.maven.model.Repository;
import org.apache.maven.project.inheritance.DefaultModelInheritanceAssembler;
import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
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;
@ -266,6 +277,310 @@ public final class ModelUtils
child.setConfiguration( childConfiguration );
}
public static void mergeModelBases( ModelBase dominant, ModelBase recessive )
{
mergeDependencies( dominant, recessive );
dominant.setRepositories( mergeRepositoryLists( dominant.getRepositories(), recessive.getRepositories() ) );
dominant.setPluginRepositories( mergeRepositoryLists( dominant.getPluginRepositories(), recessive.getPluginRepositories() ) );
mergeReporting( dominant, recessive );
mergeDependencyManagementSections( dominant, recessive );
}
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.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 )
{
// TODO: would be nice for the modello:java code to generate this as a copy constructor

View File

@ -17,31 +17,16 @@ package org.apache.maven.project.inheritance;
*/
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.Extension;
import org.apache.maven.model.Model;
import org.apache.maven.model.ModelBase;
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.Scm;
import org.apache.maven.model.Site;
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;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
@ -157,253 +142,7 @@ public class DefaultModelInheritanceAssembler
// Build
assembleBuildInheritance( child, parent.getBuild() );
assembleModelBaseInheritance( child, parent );
}
public void mergeProfileWithModel( Model model, Profile profile )
{
assembleModelBaseInheritance( model, profile );
assembleBuildBaseInheritance( model.getBuild(), profile.getBuild() );
}
private void assembleModelBaseInheritance( ModelBase child, ModelBase parent )
{
// Dependencies :: aggregate
Map mappedChildDeps = new TreeMap();
for ( Iterator it = child.getDependencies().iterator(); it.hasNext(); )
{
Dependency dep = (Dependency) it.next();
mappedChildDeps.put( dep.getManagementKey(), dep );
}
for ( Iterator it = parent.getDependencies().iterator(); it.hasNext(); )
{
Dependency dep = (Dependency) it.next();
if ( !mappedChildDeps.containsKey( dep.getManagementKey() ) )
{
child.addDependency( dep );
}
}
// Repositories :: aggregate
List parentRepositories = parent.getRepositories();
List childRepositories = child.getRepositories();
for ( Iterator iterator = parentRepositories.iterator(); iterator.hasNext(); )
{
Repository repository = (Repository) iterator.next();
// child will always override parent repositories if there are duplicates
if ( !childRepositories.contains( repository ) )
{
child.addRepository( repository );
}
}
// Mojo Repositories :: aggregate
List parentPluginRepositories = parent.getPluginRepositories();
List childPluginRepositories = child.getPluginRepositories();
for ( Iterator iterator = parentPluginRepositories.iterator(); iterator.hasNext(); )
{
Repository repository = (Repository) iterator.next();
if ( !childPluginRepositories.contains( repository ) )
{
child.addPluginRepository( repository );
}
}
// 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();
}
assembleDependencyManagementInheritance( child, parent );
}
private 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();
}
private void assembleDependencyManagementInheritance( ModelBase child, ModelBase 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 );
}
}
}
}
ModelUtils.mergeModelBases( child, parent );
}
private void assembleBuildInheritance( Model child, Build parentBuild )
@ -454,55 +193,10 @@ public class DefaultModelInheritanceAssembler
// Extensions are accumlated
mergeExtensionLists( childBuild, parentBuild );
assembleBuildBaseInheritance( childBuild, parentBuild );
ModelUtils.mergeBuildBases( childBuild, parentBuild );
}
}
private void assembleBuildBaseInheritance( BuildBase childBuild, BuildBase parentBuild )
{
// if the parent build is null, obviously we cannot inherit from it...
if ( parentBuild != null )
{
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 childPM = childBuild.getPluginManagement();
PluginManagement parentPM = parentBuild.getPluginManagement();
if ( childPM == null && parentPM != null )
{
childBuild.setPluginManagement( parentPM );
}
else
{
ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(),
false );
}
}
}
private void assembleScmInheritance( Model child, Model parent )
{

View File

@ -17,7 +17,6 @@ package org.apache.maven.project.inheritance;
*/
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@ -28,6 +27,4 @@ public interface ModelInheritanceAssembler
String ROLE = ModelInheritanceAssembler.class.getName();
void assembleModelInheritance( Model child, Model parent );
void mergeProfileWithModel( Model model, Profile profile );
}

View File

@ -0,0 +1,44 @@
package org.apache.maven.project.injection;
import org.apache.maven.model.Build;
import org.apache.maven.model.BuildBase;
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
import org.apache.maven.project.ModelUtils;
public class DefaultProfileInjector
implements ProfileInjector
{
public void inject( Profile profile, Model model )
{
ModelUtils.mergeModelBases( profile, model );
model.setDependencies( profile.getDependencies() );
model.setDependencyManagement( profile.getDependencyManagement() );
model.setDistributionManagement( profile.getDistributionManagement() );
model.setModules( profile.getModules() );
model.setPluginRepositories( profile.getPluginRepositories() );
model.setReporting( profile.getReporting() );
model.setRepositories( profile.getRepositories() );
BuildBase profileBuild = profile.getBuild();
if ( profileBuild != null )
{
ModelUtils.mergeBuildBases( profile.getBuild(), model.getBuild() );
Build modelBuild = model.getBuild();
modelBuild.setDefaultGoal( profileBuild.getDefaultGoal() );
modelBuild.setFinalName( profileBuild.getFinalName() );
modelBuild.setPluginManagement( profileBuild.getPluginManagement() );
modelBuild.setPlugins( profileBuild.getPlugins() );
modelBuild.flushPluginMap();
modelBuild.setResources( profileBuild.getResources() );
modelBuild.setTestResources( profileBuild.getTestResources() );
}
}
}

View File

@ -0,0 +1,13 @@
package org.apache.maven.project.injection;
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
public interface ProfileInjector
{
String ROLE = ProfileInjector.class.getName();
void inject( Profile profile, Model model );
}

View File

@ -18,6 +18,15 @@
<role>org.apache.maven.project.injection.ModelDefaultsInjector</role>
<implementation>org.apache.maven.project.injection.DefaultModelDefaultsInjector</implementation>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.project.injection.ProfileInjector</role>
<implementation>org.apache.maven.project.injection.DefaultProfileInjector</implementation>
</component>
<!--
|
|
@ -27,6 +36,9 @@
<role>org.apache.maven.project.MavenProjectBuilder</role>
<implementation>org.apache.maven.project.DefaultMavenProjectBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.project.injection.ProfileInjector</role>
</requirement>
<requirement>
<role>org.apache.maven.project.injection.ModelDefaultsInjector</role>
</requirement>