mirror of https://github.com/apache/maven.git
Removed a number of uneeded clone methods. Moved others out of ModelUtils and made them private.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@694573 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
727e4e7cb1
commit
0cf4ca3be5
|
@ -22,11 +22,11 @@ package org.apache.maven.profiles;
|
|||
import org.apache.maven.model.Activation;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.model.Parent;
|
||||
import org.apache.maven.profiles.activation.DefaultProfileActivationContext;
|
||||
import org.apache.maven.profiles.activation.ProfileActivationContext;
|
||||
import org.apache.maven.profiles.activation.ProfileActivationException;
|
||||
import org.apache.maven.profiles.activation.ProfileActivator;
|
||||
import org.apache.maven.project.ModelUtils;
|
||||
import org.apache.maven.realm.DefaultMavenRealmManager;
|
||||
import org.apache.maven.realm.MavenRealmManager;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
|
@ -197,8 +197,8 @@ public class DefaultProfileManager
|
|||
|
||||
if ( ( model != null ) && ( realmManager != null ) )
|
||||
{
|
||||
projectRealm = realmManager.getProjectRealm( ModelUtils.getGroupId( model ), model.getArtifactId(),
|
||||
ModelUtils.getVersion( model ) );
|
||||
projectRealm = realmManager.getProjectRealm( getGroupId( model ), model.getArtifactId(),
|
||||
getVersion( model ) );
|
||||
oldLookupRealm = container.setLookupRealm( projectRealm );
|
||||
}
|
||||
|
||||
|
@ -362,4 +362,30 @@ public class DefaultProfileManager
|
|||
{
|
||||
return profileActivationContext.getActiveByDefaultProfileIds();
|
||||
}
|
||||
|
||||
private static String getVersion( Model model )
|
||||
{
|
||||
Parent parent = model.getParent();
|
||||
|
||||
String version = model.getVersion();
|
||||
if ( ( parent != null ) && ( version == null ) )
|
||||
{
|
||||
version = parent.getVersion();
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
public static String getGroupId( Model model )
|
||||
{
|
||||
Parent parent = model.getParent();
|
||||
|
||||
String groupId = model.getGroupId();
|
||||
if ( ( parent != null ) && ( groupId == null ) )
|
||||
{
|
||||
groupId = parent.getGroupId();
|
||||
}
|
||||
|
||||
return groupId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,21 +19,7 @@ package org.apache.maven.profiles.injection;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.model.Build;
|
||||
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.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.ReportPlugin;
|
||||
import org.apache.maven.model.ReportSet;
|
||||
import org.apache.maven.model.Reporting;
|
||||
import org.apache.maven.model.*;
|
||||
import org.apache.maven.project.ModelUtils;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
@ -120,8 +106,8 @@ public class DefaultProfileInjector
|
|||
}
|
||||
|
||||
ModelUtils.mergeFilterLists( modelBuild.getFilters(), profileBuild.getFilters() );
|
||||
ModelUtils.mergeResourceLists( modelBuild.getResources(), profileBuild.getResources() );
|
||||
ModelUtils.mergeResourceLists( modelBuild.getTestResources(), profileBuild.getTestResources() );
|
||||
mergeResourceLists( modelBuild.getResources(), profileBuild.getResources() );
|
||||
mergeResourceLists( modelBuild.getTestResources(), profileBuild.getTestResources() );
|
||||
|
||||
injectPlugins( profileBuild, modelBuild );
|
||||
|
||||
|
@ -619,4 +605,15 @@ public class DefaultProfileInjector
|
|||
return new ArrayList( depsMap.values() );
|
||||
}
|
||||
|
||||
private static void mergeResourceLists( List childResources, List parentResources )
|
||||
{
|
||||
for ( Iterator i = parentResources.iterator(); i.hasNext(); )
|
||||
{
|
||||
Resource r = (Resource) i.next();
|
||||
if ( !childResources.contains( r ) )
|
||||
{
|
||||
childResources.add( r );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,8 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
|
|||
import org.apache.maven.project.artifact.ActiveProjectArtifact;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||
import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
|
||||
import org.apache.maven.project.inheritance.DefaultModelInheritanceAssembler;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
|
@ -359,8 +361,8 @@ public class MavenProject
|
|||
|
||||
if ( project.isConcrete() )
|
||||
{
|
||||
setDynamicBuild( ModelUtils.cloneBuild( project.getDynamicBuild() ) );
|
||||
setOriginalInterpolatedBuild( ModelUtils.cloneBuild( project.getOriginalInterpolatedBuild() ) );
|
||||
setDynamicBuild( cloneBuild( project.getDynamicBuild() ) );
|
||||
setOriginalInterpolatedBuild( cloneBuild( project.getOriginalInterpolatedBuild() ) );
|
||||
|
||||
List dynamicRoots = project.getDynamicCompileSourceRoots();
|
||||
if ( dynamicRoots != null )
|
||||
|
@ -2318,4 +2320,14 @@ public class MavenProject
|
|||
this.originalInterpolatedScriptSourceRoots = originalInterpolatedScriptSourceRoots;
|
||||
}
|
||||
|
||||
private static Build cloneBuild( Build build )
|
||||
{
|
||||
ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
|
||||
|
||||
Build clone = new Build();
|
||||
|
||||
assembler.assembleBuildInheritance( clone, build, false );
|
||||
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,44 +19,12 @@ package org.apache.maven.project;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.model.Activation;
|
||||
import org.apache.maven.model.ActivationFile;
|
||||
import org.apache.maven.model.ActivationProperty;
|
||||
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.DeploymentRepository;
|
||||
import org.apache.maven.model.DistributionManagement;
|
||||
import org.apache.maven.model.Exclusion;
|
||||
import org.apache.maven.model.Extension;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Parent;
|
||||
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.Relocation;
|
||||
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.RepositoryBase;
|
||||
import org.apache.maven.model.RepositoryPolicy;
|
||||
import org.apache.maven.model.Resource;
|
||||
import org.apache.maven.model.Site;
|
||||
import org.apache.maven.project.inheritance.DefaultModelInheritanceAssembler;
|
||||
import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
|
||||
import org.apache.maven.model.*;
|
||||
import org.apache.maven.project.builder.PomClassicDomainModel;
|
||||
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.Properties;
|
||||
import java.util.TreeMap;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public final class ModelUtils
|
||||
{
|
||||
|
@ -346,544 +314,12 @@ public final class ModelUtils
|
|||
|
||||
public static Model cloneModel( Model model )
|
||||
{
|
||||
// TODO: would be nice for the modello:java code to generate this as a copy constructor
|
||||
// FIXME: Fix deep cloning issues with existing plugin instances (setting
|
||||
// a version when resolved will pollute the original model instance)
|
||||
Model newModel = new Model();
|
||||
ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
|
||||
newModel.setModelVersion( model.getModelVersion() );
|
||||
newModel.setName( model.getName() );
|
||||
newModel.setParent( cloneParent( model.getParent() ) );
|
||||
newModel.setVersion( model.getVersion() );
|
||||
newModel.setArtifactId( model.getArtifactId() );
|
||||
newModel.setProperties( new Properties( model.getProperties() ) );
|
||||
newModel.setGroupId( model.getGroupId() );
|
||||
newModel.setPackaging( model.getPackaging() );
|
||||
newModel.setModules( cloneModules( model.getModules() ) );
|
||||
|
||||
newModel.setProfiles( cloneProfiles( model.getProfiles() ) );
|
||||
|
||||
assembler.copyModel( newModel, model );
|
||||
|
||||
return newModel;
|
||||
try {
|
||||
return new PomClassicDomainModel(model).getModel();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return model;
|
||||
}
|
||||
|
||||
public static Build cloneBuild( Build build )
|
||||
{
|
||||
ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
|
||||
|
||||
Build clone = new Build();
|
||||
|
||||
assembler.assembleBuildInheritance( clone, build, false );
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
private static List cloneProfiles( List profiles )
|
||||
{
|
||||
if ( profiles == null )
|
||||
{
|
||||
return profiles;
|
||||
}
|
||||
|
||||
List newProfiles = new ArrayList( profiles.size() );
|
||||
|
||||
for ( Iterator it = profiles.iterator(); it.hasNext(); )
|
||||
{
|
||||
Profile profile = (Profile) it.next();
|
||||
|
||||
Profile newProfile = new Profile();
|
||||
|
||||
newProfile.setId( profile.getId() );
|
||||
|
||||
newProfile.setActivation( cloneProfileActivation( profile.getActivation() ) );
|
||||
|
||||
newProfile.setBuild( cloneProfileBuild( profile.getBuild() ) );
|
||||
|
||||
newProfile.setDependencies( cloneProfileDependencies( profile.getDependencies() ) );
|
||||
|
||||
DependencyManagement dm = profile.getDependencyManagement();
|
||||
|
||||
if ( dm != null )
|
||||
{
|
||||
DependencyManagement newDM = new DependencyManagement();
|
||||
|
||||
newDM.setDependencies( cloneProfileDependencies( dm.getDependencies() ) );
|
||||
|
||||
newProfile.setDependencyManagement( newDM );
|
||||
}
|
||||
|
||||
newProfile.setDistributionManagement( cloneProfileDistributionManagement( profile
|
||||
.getDistributionManagement() ) );
|
||||
|
||||
List modules = profile.getModules();
|
||||
|
||||
if ( ( modules != null ) && !modules.isEmpty() )
|
||||
{
|
||||
newProfile.setModules( new ArrayList( modules ) );
|
||||
}
|
||||
|
||||
// newProfile.setPluginRepositories( cloneProfileRepositories( profile.getPluginRepositories() ) );
|
||||
|
||||
Properties props = profile.getProperties();
|
||||
|
||||
if ( props != null )
|
||||
{
|
||||
Properties newProps = new Properties();
|
||||
newProps.putAll( props );
|
||||
|
||||
newProfile.setProperties( newProps );
|
||||
}
|
||||
|
||||
newProfile.setReporting( cloneProfileReporting( profile.getReporting() ) );
|
||||
|
||||
newProfile.setReports( profile.getReports() );
|
||||
|
||||
newProfile.setRepositories( cloneProfileRepositories( profile.getRepositories() ) );
|
||||
|
||||
newProfile.setSource( profile.getSource() );
|
||||
|
||||
newProfiles.add( newProfile );
|
||||
}
|
||||
|
||||
return newProfiles;
|
||||
}
|
||||
|
||||
private static Reporting cloneProfileReporting( Reporting reporting )
|
||||
{
|
||||
Reporting newR = null;
|
||||
|
||||
if ( reporting != null )
|
||||
{
|
||||
newR = new Reporting();
|
||||
|
||||
newR.setOutputDirectory( reporting.getOutputDirectory() );
|
||||
|
||||
List plugins = reporting.getPlugins();
|
||||
|
||||
if ( plugins != null )
|
||||
{
|
||||
List newP = new ArrayList( plugins.size() );
|
||||
|
||||
for ( Iterator it = plugins.iterator(); it.hasNext(); )
|
||||
{
|
||||
ReportPlugin plugin = (ReportPlugin) it.next();
|
||||
|
||||
ReportPlugin newPlugin = new ReportPlugin();
|
||||
|
||||
newPlugin.setArtifactId( plugin.getArtifactId() );
|
||||
newPlugin.setGroupId( plugin.getGroupId() );
|
||||
newPlugin.setVersion( plugin.getVersion() );
|
||||
newPlugin.setInherited( plugin.getInherited() );
|
||||
newPlugin.setReportSets( cloneReportSets( plugin.getReportSets() ) );
|
||||
|
||||
// TODO: Implement deep-copy of configuration.
|
||||
newPlugin.setConfiguration( plugin.getConfiguration() );
|
||||
|
||||
newP.add( newPlugin );
|
||||
}
|
||||
|
||||
newR.setPlugins( newP );
|
||||
}
|
||||
}
|
||||
|
||||
return newR;
|
||||
}
|
||||
|
||||
private static List cloneReportSets( List sets )
|
||||
{
|
||||
List newSets = null;
|
||||
|
||||
if ( sets != null )
|
||||
{
|
||||
newSets = new ArrayList( sets.size() );
|
||||
|
||||
for ( Iterator it = sets.iterator(); it.hasNext(); )
|
||||
{
|
||||
ReportSet set = (ReportSet) it.next();
|
||||
|
||||
ReportSet newSet = new ReportSet();
|
||||
|
||||
// TODO: Deep-copy config.
|
||||
newSet.setConfiguration( set.getConfiguration() );
|
||||
|
||||
newSet.setId( set.getId() );
|
||||
newSet.setInherited( set.getInherited() );
|
||||
|
||||
newSet.setReports( new ArrayList( set.getReports() ) );
|
||||
|
||||
newSets.add( newSet );
|
||||
}
|
||||
}
|
||||
|
||||
return newSets;
|
||||
}
|
||||
|
||||
private static List cloneProfileRepositories( List repos )
|
||||
{
|
||||
List newRepos = null;
|
||||
|
||||
if ( repos != null )
|
||||
{
|
||||
newRepos = new ArrayList( repos.size() );
|
||||
|
||||
for ( Iterator it = repos.iterator(); it.hasNext(); )
|
||||
{
|
||||
Repository repo = (Repository) it.next();
|
||||
|
||||
Repository newRepo = new Repository();
|
||||
|
||||
newRepo.setId( repo.getId() );
|
||||
newRepo.setLayout( repo.getLayout() );
|
||||
newRepo.setName( repo.getName() );
|
||||
|
||||
RepositoryPolicy releasePolicy = repo.getReleases();
|
||||
|
||||
if ( releasePolicy != null )
|
||||
{
|
||||
RepositoryPolicy newPolicy = new RepositoryPolicy();
|
||||
newPolicy.setEnabled( releasePolicy.isEnabled() );
|
||||
newPolicy.setChecksumPolicy( releasePolicy.getChecksumPolicy() );
|
||||
newPolicy.setUpdatePolicy( releasePolicy.getUpdatePolicy() );
|
||||
|
||||
newRepo.setReleases( newPolicy );
|
||||
}
|
||||
|
||||
RepositoryPolicy snapPolicy = repo.getSnapshots();
|
||||
|
||||
if ( snapPolicy != null )
|
||||
{
|
||||
RepositoryPolicy newPolicy = new RepositoryPolicy();
|
||||
newPolicy.setEnabled( snapPolicy.isEnabled() );
|
||||
newPolicy.setChecksumPolicy( snapPolicy.getChecksumPolicy() );
|
||||
newPolicy.setUpdatePolicy( snapPolicy.getUpdatePolicy() );
|
||||
|
||||
newRepo.setSnapshots( newPolicy );
|
||||
}
|
||||
|
||||
newRepo.setUrl( repo.getUrl() );
|
||||
|
||||
newRepos.add( newRepo );
|
||||
}
|
||||
}
|
||||
|
||||
return newRepos;
|
||||
}
|
||||
|
||||
private static DistributionManagement cloneProfileDistributionManagement( DistributionManagement dm )
|
||||
{
|
||||
DistributionManagement newDM = null;
|
||||
|
||||
if ( dm != null )
|
||||
{
|
||||
newDM = new DistributionManagement();
|
||||
|
||||
newDM.setDownloadUrl( dm.getDownloadUrl() );
|
||||
newDM.setStatus( dm.getStatus() );
|
||||
|
||||
Relocation relocation = dm.getRelocation();
|
||||
|
||||
if ( relocation != null )
|
||||
{
|
||||
Relocation newR = new Relocation();
|
||||
|
||||
newR.setArtifactId( relocation.getArtifactId() );
|
||||
newR.setGroupId( relocation.getGroupId() );
|
||||
newR.setMessage( relocation.getMessage() );
|
||||
newR.setVersion( relocation.getVersion() );
|
||||
|
||||
newDM.setRelocation( newR );
|
||||
}
|
||||
|
||||
RepositoryBase repo = dm.getRepository();
|
||||
|
||||
if ( repo != null )
|
||||
{
|
||||
DeploymentRepository newRepo = new DeploymentRepository();
|
||||
|
||||
newRepo.setId( repo.getId() );
|
||||
newRepo.setLayout( repo.getLayout() );
|
||||
newRepo.setName( repo.getName() );
|
||||
newRepo.setUrl( repo.getUrl() );
|
||||
|
||||
newDM.setRepository( newRepo );
|
||||
}
|
||||
|
||||
Site site = dm.getSite();
|
||||
|
||||
if ( site != null )
|
||||
{
|
||||
Site newSite = new Site();
|
||||
|
||||
newSite.setId( site.getId() );
|
||||
newSite.setName( site.getName() );
|
||||
newSite.setUrl( site.getUrl() );
|
||||
|
||||
newDM.setSite( newSite );
|
||||
}
|
||||
|
||||
RepositoryBase sRepo = dm.getSnapshotRepository();
|
||||
|
||||
if ( sRepo != null )
|
||||
{
|
||||
DeploymentRepository newRepo = new DeploymentRepository();
|
||||
|
||||
newRepo.setId( sRepo.getId() );
|
||||
newRepo.setLayout( sRepo.getLayout() );
|
||||
newRepo.setName( sRepo.getName() );
|
||||
newRepo.setUrl( sRepo.getUrl() );
|
||||
|
||||
newDM.setSnapshotRepository( newRepo );
|
||||
}
|
||||
}
|
||||
|
||||
return newDM;
|
||||
}
|
||||
|
||||
private static List cloneProfileDependencies( List dependencies )
|
||||
{
|
||||
List newDependencies = null;
|
||||
|
||||
if ( dependencies != null )
|
||||
{
|
||||
newDependencies = new ArrayList( dependencies.size() );
|
||||
|
||||
for ( Iterator it = dependencies.iterator(); it.hasNext(); )
|
||||
{
|
||||
Dependency dep = (Dependency) it.next();
|
||||
|
||||
Dependency newDep = new Dependency();
|
||||
|
||||
newDep.setArtifactId( dep.getArtifactId() );
|
||||
newDep.setClassifier( dep.getClassifier() );
|
||||
newDep.setExclusions( cloneDependencyExclusions( dep.getExclusions() ) );
|
||||
newDep.setGroupId( dep.getGroupId() );
|
||||
newDep.setScope( dep.getScope() );
|
||||
newDep.setSystemPath( dep.getSystemPath() );
|
||||
newDep.setType( dep.getType() );
|
||||
newDep.setVersion( dep.getVersion() );
|
||||
|
||||
newDependencies.add( newDep );
|
||||
}
|
||||
}
|
||||
|
||||
return newDependencies;
|
||||
}
|
||||
|
||||
private static List cloneDependencyExclusions( List ex )
|
||||
{
|
||||
List newEx = null;
|
||||
|
||||
if ( ex != null )
|
||||
{
|
||||
newEx = new ArrayList( ex.size() );
|
||||
|
||||
for ( Iterator it = ex.iterator(); it.hasNext(); )
|
||||
{
|
||||
Exclusion exclusion = (Exclusion) it.next();
|
||||
|
||||
Exclusion newExclusion = new Exclusion();
|
||||
|
||||
newExclusion.setArtifactId( exclusion.getArtifactId() );
|
||||
newExclusion.setGroupId( exclusion.getGroupId() );
|
||||
|
||||
newEx.add( newExclusion );
|
||||
}
|
||||
}
|
||||
|
||||
return newEx;
|
||||
}
|
||||
|
||||
private static BuildBase cloneProfileBuild( BuildBase build )
|
||||
{
|
||||
BuildBase newBuild = null;
|
||||
if ( build != null )
|
||||
{
|
||||
newBuild = new BuildBase();
|
||||
|
||||
newBuild.setDefaultGoal( build.getDefaultGoal() );
|
||||
newBuild.setDirectory( build.getDirectory() );
|
||||
newBuild.setFinalName( build.getFinalName() );
|
||||
|
||||
newBuild.setPluginManagement( cloneProfilePluginManagement( build.getPluginManagement() ) );
|
||||
newBuild.setPlugins( cloneProfilePlugins( build.getPlugins() ) );
|
||||
newBuild.setResources( cloneProfileResources( build.getResources() ) );
|
||||
newBuild.setTestResources( cloneProfileResources( build.getTestResources() ) );
|
||||
}
|
||||
|
||||
return newBuild;
|
||||
}
|
||||
|
||||
private static List cloneProfileResources( List resources )
|
||||
{
|
||||
List newResources = null;
|
||||
|
||||
if ( resources != null )
|
||||
{
|
||||
newResources = new ArrayList( resources.size() );
|
||||
|
||||
for ( Iterator it = resources.iterator(); it.hasNext(); )
|
||||
{
|
||||
Resource resource = (Resource) it.next();
|
||||
|
||||
Resource newResource = new Resource();
|
||||
|
||||
newResource.setDirectory( resource.getDirectory() );
|
||||
newResource.setExcludes( new ArrayList( resource.getExcludes() ) );
|
||||
newResource.setFiltering( resource.isFiltering() );
|
||||
newResource.setIncludes( new ArrayList( resource.getIncludes() ) );
|
||||
newResource.setTargetPath( resource.getTargetPath() );
|
||||
|
||||
newResources.add( newResource );
|
||||
}
|
||||
}
|
||||
|
||||
return newResources;
|
||||
}
|
||||
|
||||
private static PluginManagement cloneProfilePluginManagement( PluginManagement pluginManagement )
|
||||
{
|
||||
PluginManagement newPM = null;
|
||||
|
||||
if ( pluginManagement != null )
|
||||
{
|
||||
newPM = new PluginManagement();
|
||||
|
||||
List plugins = pluginManagement.getPlugins();
|
||||
|
||||
newPM.setPlugins( cloneProfilePlugins( plugins ) );
|
||||
}
|
||||
|
||||
return newPM;
|
||||
}
|
||||
|
||||
private static List cloneProfilePlugins( List plugins )
|
||||
{
|
||||
List newPlugins = null;
|
||||
|
||||
if ( plugins != null )
|
||||
{
|
||||
newPlugins = new ArrayList( plugins.size() );
|
||||
|
||||
for ( Iterator it = plugins.iterator(); it.hasNext(); )
|
||||
{
|
||||
Plugin plugin = (Plugin) it.next();
|
||||
|
||||
Plugin newPlugin = new Plugin();
|
||||
|
||||
newPlugin.setArtifactId( plugin.getArtifactId() );
|
||||
newPlugin.setExtensions( plugin.isExtensions() );
|
||||
newPlugin.setGroupId( plugin.getGroupId() );
|
||||
newPlugin.setInherited( plugin.getInherited() );
|
||||
newPlugin.setVersion( plugin.getVersion() );
|
||||
|
||||
// TODO: Deep-copy this!
|
||||
newPlugin.setConfiguration( plugin.getConfiguration() );
|
||||
|
||||
newPlugin.setExecutions( cloneExecutions( plugin.getExecutions() ) );
|
||||
|
||||
newPlugins.add( newPlugin );
|
||||
}
|
||||
}
|
||||
|
||||
return newPlugins;
|
||||
}
|
||||
|
||||
private static List cloneExecutions( List executions )
|
||||
{
|
||||
List newExecs = null;
|
||||
|
||||
if ( executions != null )
|
||||
{
|
||||
newExecs = new ArrayList( executions.size() );
|
||||
|
||||
for ( Iterator it = executions.iterator(); it.hasNext(); )
|
||||
{
|
||||
PluginExecution exec = (PluginExecution) it.next();
|
||||
|
||||
PluginExecution newExec = new PluginExecution();
|
||||
|
||||
// TODO: Deep-copy configs.
|
||||
newExec.setConfiguration( exec.getConfiguration() );
|
||||
|
||||
newExec.setId( exec.getId() );
|
||||
newExec.setInherited( exec.getInherited() );
|
||||
newExec.setPhase( exec.getPhase() );
|
||||
|
||||
List goals = exec.getGoals();
|
||||
|
||||
if ( ( goals != null ) && !goals.isEmpty() )
|
||||
{
|
||||
newExec.setGoals( new ArrayList( goals ) );
|
||||
}
|
||||
|
||||
newExecs.add( newExec );
|
||||
}
|
||||
}
|
||||
|
||||
return newExecs;
|
||||
}
|
||||
|
||||
private static Activation cloneProfileActivation( Activation activation )
|
||||
{
|
||||
Activation newActivation = null;
|
||||
if ( activation != null )
|
||||
{
|
||||
newActivation = new Activation();
|
||||
|
||||
newActivation.setActiveByDefault( activation.isActiveByDefault() );
|
||||
|
||||
ActivationFile af = activation.getFile();
|
||||
|
||||
if ( af != null )
|
||||
{
|
||||
ActivationFile afNew = new ActivationFile();
|
||||
afNew.setExists( af.getExists() );
|
||||
afNew.setMissing( af.getMissing() );
|
||||
|
||||
newActivation.setFile( afNew );
|
||||
}
|
||||
|
||||
newActivation.setJdk( activation.getJdk() );
|
||||
|
||||
ActivationProperty ap = activation.getProperty();
|
||||
|
||||
if ( ap != null )
|
||||
{
|
||||
ActivationProperty newAp = new ActivationProperty();
|
||||
|
||||
newAp.setName( ap.getName() );
|
||||
newAp.setValue( ap.getValue() );
|
||||
|
||||
newActivation.setProperty( newAp );
|
||||
}
|
||||
}
|
||||
|
||||
return newActivation;
|
||||
}
|
||||
|
||||
private static List cloneModules( List modules )
|
||||
{
|
||||
if ( modules == null )
|
||||
{
|
||||
return modules;
|
||||
}
|
||||
return new ArrayList( modules );
|
||||
}
|
||||
|
||||
private static Parent cloneParent( Parent parent )
|
||||
{
|
||||
if ( parent == null )
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
Parent newParent = new Parent();
|
||||
newParent.setArtifactId( parent.getArtifactId() );
|
||||
newParent.setGroupId( parent.getGroupId() );
|
||||
newParent.setRelativePath( parent.getRelativePath() );
|
||||
newParent.setVersion( parent.getVersion() );
|
||||
return newParent;
|
||||
}
|
||||
|
||||
public static List mergeRepositoryLists( List dominant, List recessive )
|
||||
|
@ -910,30 +346,6 @@ public final class ModelUtils
|
|||
return repositories;
|
||||
}
|
||||
|
||||
public static void mergeExtensionLists( Build childBuild, Build parentBuild )
|
||||
{
|
||||
for ( Iterator i = parentBuild.getExtensions().iterator(); i.hasNext(); )
|
||||
{
|
||||
Extension e = (Extension) i.next();
|
||||
if ( !childBuild.getExtensions().contains( e ) )
|
||||
{
|
||||
childBuild.addExtension( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void mergeResourceLists( List childResources, List parentResources )
|
||||
{
|
||||
for ( Iterator i = parentResources.iterator(); i.hasNext(); )
|
||||
{
|
||||
Resource r = (Resource) i.next();
|
||||
if ( !childResources.contains( r ) )
|
||||
{
|
||||
childResources.add( r );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void mergeFilterLists( List childFilters, List parentFilters )
|
||||
{
|
||||
for ( Iterator i = parentFilters.iterator(); i.hasNext(); )
|
||||
|
@ -946,7 +358,7 @@ public final class ModelUtils
|
|||
}
|
||||
}
|
||||
|
||||
public static List mergeDependencyList( List child, List parent )
|
||||
private static List mergeDependencyList( List child, List parent )
|
||||
{
|
||||
Map depsMap = new HashMap();
|
||||
|
||||
|
@ -971,30 +383,4 @@ public final class ModelUtils
|
|||
return new ArrayList( depsMap.values() );
|
||||
}
|
||||
|
||||
public static String getGroupId( Model model )
|
||||
{
|
||||
Parent parent = model.getParent();
|
||||
|
||||
String groupId = model.getGroupId();
|
||||
if ( ( parent != null ) && ( groupId == null ) )
|
||||
{
|
||||
groupId = parent.getGroupId();
|
||||
}
|
||||
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public static String getVersion( Model model )
|
||||
{
|
||||
Parent parent = model.getParent();
|
||||
|
||||
String version = model.getVersion();
|
||||
if ( ( parent != null ) && ( version == null ) )
|
||||
{
|
||||
version = parent.getVersion();
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,19 +19,7 @@ package org.apache.maven.project.inheritance;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.DependencyManagement;
|
||||
import org.apache.maven.model.DeploymentRepository;
|
||||
import org.apache.maven.model.DistributionManagement;
|
||||
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.Resource;
|
||||
import org.apache.maven.model.Scm;
|
||||
import org.apache.maven.model.Site;
|
||||
import org.apache.maven.model.*;
|
||||
import org.apache.maven.project.ModelUtils;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
@ -89,7 +77,7 @@ public class DefaultModelInheritanceAssembler
|
|||
}
|
||||
|
||||
// Extensions are accumlated
|
||||
ModelUtils.mergeExtensionLists( childBuild, parentBuild );
|
||||
mergeExtensionLists( childBuild, parentBuild );
|
||||
|
||||
if ( childBuild.getDirectory() == null )
|
||||
{
|
||||
|
@ -745,4 +733,15 @@ public class DefaultModelInheritanceAssembler
|
|||
return cleanedPath.toString();
|
||||
}
|
||||
|
||||
private static void mergeExtensionLists( Build childBuild, Build parentBuild )
|
||||
{
|
||||
for ( Iterator i = parentBuild.getExtensions().iterator(); i.hasNext(); )
|
||||
{
|
||||
Extension e = (Extension) i.next();
|
||||
if ( !childBuild.getExtensions().contains( e ) )
|
||||
{
|
||||
childBuild.addExtension( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue